Hi Richard
I have aotovalidation turned on - it means that after reset method of my
form bean validate() is called, and if it sucessfull action's execute() is
invoked.
But whatever i do in validate of my form bean is my business. For me
autovalidation means that validate() of form bean is invoked in specific
moment not by me but by struts.
I do alter page (page -- if errors are present) as i described in one of my
previous messages but i just wanna to know if it is a good practice, and
maybe is better solution...
Up to now i find turning off autovalidation a good idea and concerning do
it.

2006/5/8, Richard Yee <[EMAIL PROTECTED]>:

Jakub,
Even though you are using autovalidation, don't you still have a
validate() method in your ActionForm that is getting called? Can you
alter the page attribute appropriately there (ie. if (errors.size() > 0)
page--;


-Richard
Jakub Milkiewicz wrote:
> Hi Richard.
> I can't because of autovalidation. Remember that all my action have
> the same
> actionForm which is storred in session.
> If validation fails i am forwarded to previous action but this action
> is not
> even executed cause before this previous action can be invoked
validation
> process occurs. Page parameter isn't changed and validation process
fails
> again...
> If validation fails i do not enter any action's execute() method.
>
> 2006/5/7, Richard Yee <[EMAIL PROTECTED]>:
>>
>> Jakub,
>> Why can't you reset the page attribute to the appropriate value in your
>> Action classes when validation fails.
>>
>> -Richard
>>
>> Richard Yee wrote:
>> > Jakub,
>> > I think the more elegant solution is to do the validations in the
>> > ActionForm validate method and also use a hidden static  'page'
>> > variable in the JSP. Your Action.execute method should be fairly
small
>> > and mainly have code that calls business delegates and that necessary
>> > for determining where to forward to.
>> >
>> > -Richard
>> >
>> >
>> > Jakub Milkiewicz wrote:
>> >> Hi
>> >> I have a wizzard application with 5 screens. All user inputs are
>> >> collected
>> >> in one bean, which is named: viewBean and is stored in HTTP session.
>> >> So each action has the same formBean - viewBean.
>> >> I use commons-validator and viewBean properties to validate are
>> >> present in
>> >> validation.xml with page attributes.
>> >> ViewBean extends ValidatorForm and it's validation occurs
>> >> automatically - i
>> >> have validation set to true for all ACTIONS.
>> >> The structure of my app is:
>> >> Populate view  -> jsp ->populate view ->jsp ->populate view -> jsp
>> ...
>> >> Population of view happens in ACTION class and can consists of
>> >> retrieving
>> >> some data from DB, sets these data in HTTP request.
>> >> After population process i forward to appropriate jsp to give user a
>> >> chance
>> >> to fill the form and to present population process results as for
>> >> example
>> >> options in <html:select>.
>> >> If form is correct i go to another action which populate view for a
>> next
>> >> screen (jsp).
>> >> If form is not filled correctly i need to show it again, but i can
>> not
>> >> forward to jsp - i need to forward to action that prepares the form
-
>> >> that's
>> >> why i have my input parameter of <action> tag set to action which
>> >> populate
>> >> the view - previous action.
>> >> I have a problem with page attribute. Please take a look at the
>> >> sample of
>> >> processing in my app:
>> >> ACTION1 -> JSP1 ->ACTION2 -> JSP2  ->Action3 ->JSP3 ...
>> >> Let's assume that user submits form in JSP2 to action3. After
>> ActionForm
>> >> bean population, page property is set to 2. Next, validation fails
in
>> >> Action3 and input parameter of <action3> forwards user to ACTION2.
>> >> Before execute method in Action2 is invoked, ActionForm (viewBean)
>> >> validation occurs. The page attribute is still set to 2 ! and
>> >> commons-validator tries to validate properties that has page
>> >> attribute set
>> >> to 2.Obviously validation fails and control is forwarded to Action1.
>> >> Action1
>> >> also has validation set to true and validation of ActionForm occurs
>> >> again
>> >> with page =2.
>> >> Validation fails and control is forwarded to ...
>> >> Does anyone have any idea to solve the problem.
>> >> My idea is to not to use hidden page parameter in each jsp action
but
>> >> set
>> >> page property of viewBean in each Action: for ACTION2 sets it to
>> 2,  for
>> >> Action3 sets it to 3 ...
>> >> and to override validate method in viewBean:
>> >>
>> >> public ActionErrors validate(
>> >>        ActionMapping mapping,
>> >>        HttpServletRequest request) {
>> >>        ActionErrors errors = super.validate(mapping,request);
>> >>        if(errors != null && errors.size() > 0 )
>> >>               page--;
>> >>        return errors;
>> >> }
>> >>
>> >> Maybe someone knows more elegant solution, or maybe architecture of
>> >> my app
>> >> isn't valid.
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>


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


Reply via email to