Postfach 4711 wrote:

Hello Reinhard,

what will happen if the user calls the action from the jsp without
entering any data? If you also get the exception something is wrong
with your validate method.

There is a contract between actions and the forms they use: The form *will* be created. This can be evidenced by the source (see RequestProcessor.java).

Your job, as an application developer, is to communicate to Struts (by placing the name of the form-bean in the name attribute of the action-mapping that needs access to the form) that a particular action needs a particular form. By doing Struts can (and will!) look for that action to be executed and instantiate the form-bean if needed. As such, you should never get an NPE because of a form-bean. If you do, it's *most likely* because you did not tell Struts that the action requires access to a form-bean.

Thursday, November 7, 2002, 3:27:43 PM, you wrote:

RS> Hi all,

RS> i was wondering how to handle correctly the following behaviour:
RS> if a user calls directly from the url an action that has a Jsp in his
RS> input and validate=true, i get a Nullpointerexception inside the
RS> validate().

RS> I think that this happens because the FormBean has never been
RS> initialized with the values from the Jsp (the jsp has not been
RS> displayed). All values in the FormBean are nulls.


RS> I have added an instruction at the beginning of the validate() that
RS> checks if one of the text fields are null, the validate returns null.
RS> Is there a better way to handle this?
RS> Thanks
RS> Reinhard

--
Eddie Bush




--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to