You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fea jabi <zy...@hotmail.com> on 2006/01/06 17:34:54 UTC
Re: reset method with DyanValidatorForm
Thanks you all for responding. It's much clear now.
I have created a DynaValidatorForm in strutsconfig.xml which has about 20
form properties for my jsp. I can see the components I need in my jsp.
This form is session scoped which has radio's and checkboxes.
So, I might have to reset the checkboxes now.
Do, I have no other choice but to create a formbean Class with all the
setter's and getter's and then add reset method too for it.
or is there an easier way to do this using DynaValidatorForm?
Thanks.
>From: Andre Van Klaveren <ny...@gmail.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: Re: reset method in ActionForm
>Date: Tue, 3 Jan 2006 12:49:55 -0600
>
>Q: When exactly this method has to be used and when does this get called?
>
>A: The reset method is called for each new request, for both request
>and session scoped ActionForms, before the ActionForm is populated
>from the request. Here's the sequence of events:
>
>1. Request received by controller.
>2. Create or recycle ActionForm (create request-scoped, recycle
>session-scoped)
>3. Call reset() method on ActionForm.
>4. Store ActionForm in scope as defined in stuts-config.xml
>5. Populate ActionForm from request.
>6. Validate the ActionForm if defined in struts-config.xml.
>Assuming no validation errors:
>7a. Call execute() method of the Action passing ActionForm
>With validation errors:
>7b. Go back to input with ActionForm in proper scope.
>
>Q: Why do the checkboxes have to be reset?
>
>A: The reset() method was originally designed to reset boolean
>variables that represent checkbox values in the HTML form. When an
>HTML form contains checkboxes, only the values for the checkboxes that
>are chedked are sent in the request (see HTTP spec). The reset()
>method was designed to reset the boolean properties in the ActionForm
>that represent checkboxes to false. This is necessary because false
>values aren't sent in the request, only true ones. If you have a
>session-scoped ActionForm, the boolean values for the checkboxes could
>be set to true from a previous request. Without resetting them they
>would always stay true.
>
>With a request-scoped ActionForm you don't have to implement the reset
>method unless you need your ActionForm properties to default to some
>value other than the default or that of which you defined when you
>declared the property on the ActionForm.
>
>Basically, the reset method is called before the request reaches the
>Action.
>
>Hope that answers your questions.
>
>
>On 1/3/06, fea jabi <zy...@hotmail.com> wrote:
> > When exactly this method has to be used and when does this get called?
> >
> > Why do the checkboxes have to be reset?
> >
> > Prepopulating the formbean is done in Action class. hence, it's not
>clear to
> > me the exact use of using the reset method.
> >
> > Thanks.
> >
> > _________________________________________________________________
> > Is your PC infected? Get a FREE online computer virus scan from
>McAfee(r)
> > Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
>
>--
>Virtually,
>Andre Van Klaveren
>Architect III, SCP
>Global Public Sector
>Unisys Corporation
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: reset method with DyanValidatorForm
Posted by fea jabi <zy...@hotmail.com>.
Great. thanks a lot for your help.
>From: "Wendy Smoak" <ws...@gmail.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: "Struts Users Mailing List" <us...@struts.apache.org>
>Subject: Re: reset method with DyanValidatorForm
>Date: Wed, 1 Nov 2006 08:21:41 -0700
>
>On 11/1/06, fea jabi <zy...@hotmail.com> wrote:
>
>>may I know the reason why do we have to use Serializable in the below.
>
>> >package com.example.myapp;
>> >public final class AccountForm extends DynaValidatorActionForm
>> >implements Serializable {...}
>
>You don't. DynaValidatorActionForm is already Serializable.
>
>http://struts.apache.org/1.2.9/api/org/apache/struts/validator/DynaValidatorActionForm.html
>
>http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html
>
>--
>Wendy
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
All-in-one security and maintenance for your PC. Get a free 90-day trial!
http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http://www.windowsonecare.com/?sc_cid=msn_hotmail
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: reset method with DyanValidatorForm
Posted by Wendy Smoak <ws...@gmail.com>.
On 11/1/06, fea jabi <zy...@hotmail.com> wrote:
> may I know the reason why do we have to use Serializable in the below.
> >package com.example.myapp;
> >public final class AccountForm extends DynaValidatorActionForm
> >implements Serializable {...}
You don't. DynaValidatorActionForm is already Serializable.
http://struts.apache.org/1.2.9/api/org/apache/struts/validator/DynaValidatorActionForm.html
http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: reset method with DyanValidatorForm
Posted by Niall Pemberton <ni...@gmail.com>.
Woops, sorry download link should have been:
http://struts.apache.org/downloads.html
On 11/1/06, Niall Pemberton <ni...@gmail.com> wrote:
> On 11/1/06, fea jabi <zy...@hotmail.com> wrote:
> > Thanks. This forum has been great help to me.
> >
> > we are using 1.2.7 so, can't use this nice feature yet.
> >
> > But where can I get the new features added after 1.2.7 version from?
>
> Its in the Struts 1.3.x series - the only "ga" (or production) quality
> version is Struts 1.3.5 - so if you were looking to upgrade from 1.2.x
> - that is currently the best option. You can download it here:
> http://download.java.net/jdk6/docs/api/
>
> Notes on Upgrading to 1.3.x are here:
> http://wiki.apache.org/struts/StrutsUpgrade
>
> Niall
>
> > >From: "Niall Pemberton" <ni...@gmail.com>
> > >Date: Wed, 1 Nov 2006 15:35:44 +0000
> > >
> > >On 1/6/06, Wendy Smoak <ws...@gmail.com> wrote:
> > >>On 1/6/06, fea jabi <zy...@hotmail.com> wrote:
> > >>
> > >> > So, I might have to reset the checkboxes now.
> > >> >
> > >> > Do, I have no other choice but to create a formbean Class with all the
> > >> > setter's and getter's and then add reset method too for it.
> > >> >
> > >> > or is there an easier way to do this using DynaValidatorForm?
> > >>
> > >>You don't have to add the get/set methods. Just extend
> > >>DynaValidatorForm and add the reset method -- then be sure to change
> > >>the type of the form in struts-config.xml to your new form type.
> > >>
> > >>package com.example.myapp;
> > >>public final class AccountForm extends DynaValidatorActionForm
> > >>implements Serializable {...}
> > >>
> > >> <form-bean
> > >> name="accountForm"
> > >> type="com.example.myapp.AccountForm">
> > >
> > >Hubert added a new feature in Struts 1.3.x that allows you to
> > >configure "reset" behaviour on a property-by-property basis in the
> > >struts-config.xml - I believe you just add reset="true" attributes to
> > >your <form-property> elements and it will reset the values to whatever
> > >is (or isn't) specified by the "initial" attribute. Something like the
> > >following:
> > >
> > ><form-beans>
> > >
> > > <form-bean name="fooForm"
> > >type="org.apache.struts.action.DynaActionForm">
> > > <form-property name="state" type="java.lang.String"
> > >initial="INITIAL" reset="true"/>
> > > <form-property name="unsubscribe" type="java.lang.String"
> > >initial="true" reset="true"/>
> > > </form-bean>
> > >
> > > </form-beans>
> > >
> > >Niall
> > >
> > >>--
> > >>Wendy
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: reset method with DyanValidatorForm
Posted by Niall Pemberton <ni...@gmail.com>.
On 11/1/06, fea jabi <zy...@hotmail.com> wrote:
> Thanks. This forum has been great help to me.
>
> we are using 1.2.7 so, can't use this nice feature yet.
>
> But where can I get the new features added after 1.2.7 version from?
Its in the Struts 1.3.x series - the only "ga" (or production) quality
version is Struts 1.3.5 - so if you were looking to upgrade from 1.2.x
- that is currently the best option. You can download it here:
http://download.java.net/jdk6/docs/api/
Notes on Upgrading to 1.3.x are here:
http://wiki.apache.org/struts/StrutsUpgrade
Niall
> >From: "Niall Pemberton" <ni...@gmail.com>
> >Date: Wed, 1 Nov 2006 15:35:44 +0000
> >
> >On 1/6/06, Wendy Smoak <ws...@gmail.com> wrote:
> >>On 1/6/06, fea jabi <zy...@hotmail.com> wrote:
> >>
> >> > So, I might have to reset the checkboxes now.
> >> >
> >> > Do, I have no other choice but to create a formbean Class with all the
> >> > setter's and getter's and then add reset method too for it.
> >> >
> >> > or is there an easier way to do this using DynaValidatorForm?
> >>
> >>You don't have to add the get/set methods. Just extend
> >>DynaValidatorForm and add the reset method -- then be sure to change
> >>the type of the form in struts-config.xml to your new form type.
> >>
> >>package com.example.myapp;
> >>public final class AccountForm extends DynaValidatorActionForm
> >>implements Serializable {...}
> >>
> >> <form-bean
> >> name="accountForm"
> >> type="com.example.myapp.AccountForm">
> >
> >Hubert added a new feature in Struts 1.3.x that allows you to
> >configure "reset" behaviour on a property-by-property basis in the
> >struts-config.xml - I believe you just add reset="true" attributes to
> >your <form-property> elements and it will reset the values to whatever
> >is (or isn't) specified by the "initial" attribute. Something like the
> >following:
> >
> ><form-beans>
> >
> > <form-bean name="fooForm"
> >type="org.apache.struts.action.DynaActionForm">
> > <form-property name="state" type="java.lang.String"
> >initial="INITIAL" reset="true"/>
> > <form-property name="unsubscribe" type="java.lang.String"
> >initial="true" reset="true"/>
> > </form-bean>
> >
> > </form-beans>
> >
> >Niall
> >
> >>--
> >>Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: reset method with DyanValidatorForm
Posted by fea jabi <zy...@hotmail.com>.
Thanks. This forum has been great help to me.
we are using 1.2.7 so, can't use this nice feature yet.
But where can I get the new features added after 1.2.7 version from?
>From: "Niall Pemberton" <ni...@gmail.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: "Struts Users Mailing List" <us...@struts.apache.org>
>Subject: Re: reset method with DyanValidatorForm
>Date: Wed, 1 Nov 2006 15:35:44 +0000
>
>On 1/6/06, Wendy Smoak <ws...@gmail.com> wrote:
>>On 1/6/06, fea jabi <zy...@hotmail.com> wrote:
>>
>> > So, I might have to reset the checkboxes now.
>> >
>> > Do, I have no other choice but to create a formbean Class with all the
>> > setter's and getter's and then add reset method too for it.
>> >
>> > or is there an easier way to do this using DynaValidatorForm?
>>
>>You don't have to add the get/set methods. Just extend
>>DynaValidatorForm and add the reset method -- then be sure to change
>>the type of the form in struts-config.xml to your new form type.
>>
>>package com.example.myapp;
>>public final class AccountForm extends DynaValidatorActionForm
>>implements Serializable {...}
>>
>> <form-bean
>> name="accountForm"
>> type="com.example.myapp.AccountForm">
>
>Hubert added a new feature in Struts 1.3.x that allows you to
>configure "reset" behaviour on a property-by-property basis in the
>struts-config.xml - I believe you just add reset="true" attributes to
>your <form-property> elements and it will reset the values to whatever
>is (or isn't) specified by the "initial" attribute. Something like the
>following:
>
><form-beans>
>
> <form-bean name="fooForm"
>type="org.apache.struts.action.DynaActionForm">
> <form-property name="state" type="java.lang.String"
>initial="INITIAL" reset="true"/>
> <form-property name="unsubscribe" type="java.lang.String"
>initial="true" reset="true"/>
> </form-bean>
>
> </form-beans>
>
>Niall
>
>>--
>>Wendy
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
Get FREE company branded e-mail accounts and business Web site from
Microsoft Office Live
http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: reset method with DyanValidatorForm
Posted by Niall Pemberton <ni...@gmail.com>.
On 1/6/06, Wendy Smoak <ws...@gmail.com> wrote:
> On 1/6/06, fea jabi <zy...@hotmail.com> wrote:
>
> > So, I might have to reset the checkboxes now.
> >
> > Do, I have no other choice but to create a formbean Class with all the
> > setter's and getter's and then add reset method too for it.
> >
> > or is there an easier way to do this using DynaValidatorForm?
>
> You don't have to add the get/set methods. Just extend
> DynaValidatorForm and add the reset method -- then be sure to change
> the type of the form in struts-config.xml to your new form type.
>
> package com.example.myapp;
> public final class AccountForm extends DynaValidatorActionForm
> implements Serializable {...}
>
> <form-bean
> name="accountForm"
> type="com.example.myapp.AccountForm">
Hubert added a new feature in Struts 1.3.x that allows you to
configure "reset" behaviour on a property-by-property basis in the
struts-config.xml - I believe you just add reset="true" attributes to
your <form-property> elements and it will reset the values to whatever
is (or isn't) specified by the "initial" attribute. Something like the
following:
<form-beans>
<form-bean name="fooForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="state" type="java.lang.String"
initial="INITIAL" reset="true"/>
<form-property name="unsubscribe" type="java.lang.String"
initial="true" reset="true"/>
</form-bean>
</form-beans>
Niall
> --
> Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: reset method with DyanValidatorForm
Posted by Wendy Smoak <ws...@gmail.com>.
On 1/6/06, fea jabi <zy...@hotmail.com> wrote:
> So, I might have to reset the checkboxes now.
>
> Do, I have no other choice but to create a formbean Class with all the
> setter's and getter's and then add reset method too for it.
>
> or is there an easier way to do this using DynaValidatorForm?
You don't have to add the get/set methods. Just extend
DynaValidatorForm and add the reset method -- then be sure to change
the type of the form in struts-config.xml to your new form type.
package com.example.myapp;
public final class AccountForm extends DynaValidatorActionForm
implements Serializable {...}
<form-bean
name="accountForm"
type="com.example.myapp.AccountForm">
...
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org