You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "SIRAGHER, JOEL" <JO...@appsig.com> on 2006/02/27 18:23:23 UTC

prepopulating check boxes when first form comes up. during reset?

Hi all:

I am trying to pre populate checkboxes on struts 1.1 jsp. When the user
goes to the url, I am setting the default values of the checkboxes in
the reset function. Is this the correct way to go?

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


Re: prepopulating check boxes when first form comes up. during reset?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 2/27/06, SIRAGHER, JOEL <JO...@appsig.com> wrote:
> Hi all:
>
> I am trying to pre populate checkboxes on struts 1.1 jsp. When the user
> goes to the url, I am setting the default values of the checkboxes in
> the reset function. Is this the correct way to go?

The request/response cycle goes like this:
* Create ActionForm if needed
* ActionForm.reset() (I am not sure is it called when form has request
scope, I hope it is)
* populate ActionForm with request data using setters
* ActionForm.validate()
* On error forward to location set in the "input" attribute of the
action mapping; otherwise call Action.execute()

Now you decide is reset() an appropriate place or not. There is no
"correct" way. If you use the same ActionForm in different actions or
for different phases (setup or submit) you want to make sure that you
populate form only on setup phase, and you clear checkboxes only on
submit phase before they are set from request.

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


Re: prepopulating check boxes when first form comes up. during reset?

Posted by Laurie Harper <la...@holoweb.net>.
SIRAGHER, JOEL wrote:
> Hi all:
> 
> I am trying to pre populate checkboxes on struts 1.1 jsp. When the user
> goes to the url, I am setting the default values of the checkboxes in
> the reset function. Is this the correct way to go?

No, reset should be used to clear the checkbox properties to their 
'unchecked' value. Pre-populating them based on model data should happen 
in an action before control is forwarded to the view.

L.


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