Jerry Jalenak wrote:
The doStartTag has a call to initFormBean; in initFormBean there is a call
to RequestUtils.createActionForm, followed by a call to the ActionForms
'reset' method.  In a wizard type of application, this could indeed cause
problems where the reset method may be clearing values from the ActionForm;
I've had to add code to a couple of my projects to check the mapping to see
if I wanted to reset or not.  Maybe one of the guru's could shed some light
on why the <html:form/> tag would instantiate the ActionForm and call reset
when the JSP is rendered, opposed to doing this when the form is actually
submitted....

In the normal course, the ActionForm is instantiated by the controller, and reset is called before autopopulation. Some people use reset for things aside from clearing fields, and so reset is also called if the h html:form tag needs to instatiate the form.


The mistake most people make is resetting properties needlessly. Generally, the one and only property that needs to be cleared by reset is a checkbox in session scope. This is simply because an unchecked box is not submitted. If the bean is in session scope, there is no way to turn it off again, and without reset, it remains forever true.

I would hazard to say that the best practice should be to use code like this in your reset method

if ((SESSION.equals(mapping.getScope())) setMyCheckbox(false);

and to never clear any other property without a specific cause.

-Ted.


-- Ted Husted, Struts in Action <http://husted.com/struts/book.html>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to