struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Hale Boyes <kcbo...@gmail.com>
Subject Re: Struts 1 - Initialization versus validation
Date Mon, 14 Sep 2009 20:35:01 GMT
Yes, I'm using form.reset() to initialize my fields but the problem is
I don't want to initialize
the fields if I'm coming into the SetupAction because of a validation error.

I've worked around it for now by looking checking
        ActionErrors errors = (ActionErrors)
request.getAttribute(Globals.ERROR_KEY);
        boolean haveErrors = (errors != null && !errors.isEmpty());
and then switch on haveErrors.

Kevin.

2009/9/14 Paweł Wielgus <poulwiel@gmail.com>:
> Hi Kevin,
> as far as i know form.reset(...) should be used to reset form fields,
> one good example is checkbox field that needs to be reseted. I don't
> know if using reset method in order to initialize objects in form. Can
> You do it with some kind of initialize/prepare method in SetupAction
> or CrudAction?
>
> Best greetings,
> Pawel Wielgus.
>
> 2009/9/14, Kevin Hale Boyes <kcboyes@gmail.com>:
>> I have a setup action defined:
>>
>> <action path="/setup"
>>         type="package.SetupAction"
>>         name="MyForm" validate="false">
>>     <forward name="success" path="/path/Form.jsp" />
>> </action>
>>
>> This action is responsible for setting up values in my (dyna) form
>> before getting to the JSP page.
>>
>> I have a second action which is where the JSP will POST to:
>>
>> <action path="/crud"
>>         type="package.CrudAction"
>>         name="MyForm" validate="true" input="/setup">
>>     <forward name="success" path="/setup"/>
>> </action>
>>
>>
>> The idea is that if a validation error occurs then I'll be forwarded
>> back the setup action
>> and the page will be displayed again.  On success of the form POST I
>> will actually
>> come back to the same page to allow the user to input and POST again.
>>
>> The validation error could either happen from the (client-side)
>> validator framework or
>> it could happen from the CrudAction when it returns to
>> mapping.getInputForward().
>>
>> Here's my problem though.  I would like to initialize the form fields
>> (form.reset()) when
>> the user first comes to the page or for success navigations but don't
>> want to reset the
>> form when coming to the action as a result of an error.
>>
>> Is there any way to do that?
>>
>> As noted in the subject, this is on Struts 1 and I'm using
>> struts-validation.
>>
>> Thanks,
>> Kevin.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message