-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Arthur Branham opened SPR-1860 and commented
Given: a complex form backing object A which has property B which has property C. (A.B.C)
I have several questions on some issues I have encountered:
-
Upon an initial visit to a view page using a form:form tag, there will be no form backing object. This results in an exception
"java.lang.IllegalStateException: Neither Errors instance nor plain target object for bean name 'command' available as request attribute."
Therefore is it necessary to initially direct the user to an Controller which will create the form backing object and place it in the model under the key "command"? I feel that the form:form tag should handle the case where a form backing object is missing and create it via an optional commandClass attribute or commandBean attribute via the spring bean factory using an id/name. It should then bind the newly created form backing object to requestScope under the "commandName" property specified in the form tag. -
Assume I am fowarding from a controller to a view. I have set object 'A' to be part of my model and use the <form:form commandName="A"> on the view page. If a property B in object A is null and is part of a nested path in a tag such as <spring:bind path="A.B.C"> or any of the <form:input path="B.C">, an exception "org.springframework.beans.NullValueInNestedPathException: Invalid property 'B' of bean class [A]: Value of nested property 'B' is null" is thrown.
There should be some way to fail silently such as in JSTL and simply have status.value return 'null'. -
Given a one of the form:input elements with a path of "B.C", assume I submit its value to a MultiActionController. In the controller I must create a new form backing object (which will be A) and bind the servlet request parameters to it using the binder. Since Property B may be null in object A, there is no way that property C can be set since B is null. We need a strategy to instatiate property B in the case where a nested property C is submitted with a value.
What are your suggestions on these issues? I believe most of these issues have been addressed by Struts.
Affects: 2.0 M3
Issue Links:
- Allow null as modelAttribute on form:form binding [SPR-5867] #10536 Allow null as modelAttribute on form:form binding
- Data Binder: Add support for auto-instantiating null values in nested paths [SPR-6032] #10701 Data Binder: Add support for auto-instantiating null values in nested paths
- Option to expose empty value instead of NullValueInNestedPathException [SPR-1671] #6368 Option to expose empty value instead of NullValueInNestedPathException
4 votes, 6 watchers