You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Troy Bull <tr...@gmail.com> on 2006/05/04 20:37:41 UTC

Change Input parameter at run time

Greetings

I have an application i have inherited.  There is a situation where 2 
jsp's submit to the same action with the same form bean.  In the 
validation function inside the form bean if there is one type of error I 
want to set the input parameter to /jsp1.jsp and put an ActionError on 
the ActionErrors.  If there is an error of type 2 I want to set the 
input parameter to /jsp2.jsp and put an error on the ActionsErrors.

The just of all this is: the input parameter is set in struts-config.xml 
and it validation fails it goes back to this jsp for the user to fix 
it.  I need to change the input jsp page dynamically from inside the 
form bean.

Please help
thanks
troy

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


Re: Change Input parameter at run time

Posted by Michael Jouravlev <jm...@gmail.com>.
Frank's way is simple, declarative and it works. You can also try the
one that I replied with two days ago:

---------- Forwarded message starts ----------
From: Michael Jouravlev <jm...@gmail.com>
Date: May 4, 2006 12:25 PM
Subject: Re: Change Input parameter at run time part 2...
To: Struts Users Mailing List <us...@struts.apache.org>

I suggest that instead of hacking "input" property
you abandon it altogether as well as autovalidation. If you turn
autovalidation off, your action.execute() method will always be
called, so you can call actionform.validate() manually and then make a
decision where to forward.
---------- Forwarded message ends ----------

On 5/6/06, Frank W. Zammetti <fz...@omnytex.com> wrote:
> Not sure if anyone said this already, but... if the validation failures
> are mutually exclusive, i.e., type 1 cannot occur when submission was
> from page 2, and type 2 cannot occur when submission was from page 1,
> then I think all you need to do is create another mapping in
> struts-config, both identical except for different input parameters.
>
> Even if the errors are not mutually exclusive, you can interrogate the
> incoming request to see which mapping was triggered, and only perform
> the validation appropriate to the mapping.
>
> Frank
>
> Jakub Milkiewicz wrote:
> > Hi
> > I am not sure if you can do it easily. Maybe some plubing will be needed.
> > Anyway
> > concern validation in Action and then forward or redirect wherever you
> > want.
> >
> >
> > 2006/5/4, Troy Bull <tr...@gmail.com>:
> >>
> >> Greetings
> >>
> >> I have an application i have inherited.  There is a situation where 2
> >> jsp's submit to the same action with the same form bean.  In the
> >> validation function inside the form bean if there is one type of error I
> >> want to set the input parameter to /jsp1.jsp and put an ActionError on
> >> the ActionErrors.  If there is an error of type 2 I want to set the
> >> input parameter to /jsp2.jsp and put an error on the ActionsErrors.
> >>
> >> The just of all this is: the input parameter is set in struts-config.xml
> >> and it validation fails it goes back to this jsp for the user to fix
> >> it.  I need to change the input jsp page dynamically from inside the
> >> form bean.
> >>
> >> Please help
> >> thanks
> >> troy
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM: fzammetti
> Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Java Web Parts -
> http://javawebparts.sourceforge.net
> Supplying the wheel, so you don't have to reinvent it!
>
> ---------------------------------------------------------------------
> 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


Re: Change Input parameter at run time

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Not sure if anyone said this already, but... if the validation failures 
are mutually exclusive, i.e., type 1 cannot occur when submission was 
from page 2, and type 2 cannot occur when submission was from page 1, 
then I think all you need to do is create another mapping in 
struts-config, both identical except for different input parameters.

Even if the errors are not mutually exclusive, you can interrogate the 
incoming request to see which mapping was triggered, and only perform 
the validation appropriate to the mapping.

Frank

Jakub Milkiewicz wrote:
> Hi
> I am not sure if you can do it easily. Maybe some plubing will be needed.
> Anyway
> concern validation in Action and then forward or redirect wherever you 
> want.
> 
> 
> 2006/5/4, Troy Bull <tr...@gmail.com>:
>>
>> Greetings
>>
>> I have an application i have inherited.  There is a situation where 2
>> jsp's submit to the same action with the same form bean.  In the
>> validation function inside the form bean if there is one type of error I
>> want to set the input parameter to /jsp1.jsp and put an ActionError on
>> the ActionErrors.  If there is an error of type 2 I want to set the
>> input parameter to /jsp2.jsp and put an error on the ActionsErrors.
>>
>> The just of all this is: the input parameter is set in struts-config.xml
>> and it validation fails it goes back to this jsp for the user to fix
>> it.  I need to change the input jsp page dynamically from inside the
>> form bean.
>>
>> Please help
>> thanks
>> troy
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Java Web Parts -
http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!

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


Re: Change Input parameter at run time

Posted by Jakub Milkiewicz <jm...@gmail.com>.
Hi
I am not sure if you can do it easily. Maybe some plubing will be needed.
Anyway
concern validation in Action and then forward or redirect wherever you want.


2006/5/4, Troy Bull <tr...@gmail.com>:
>
> Greetings
>
> I have an application i have inherited.  There is a situation where 2
> jsp's submit to the same action with the same form bean.  In the
> validation function inside the form bean if there is one type of error I
> want to set the input parameter to /jsp1.jsp and put an ActionError on
> the ActionErrors.  If there is an error of type 2 I want to set the
> input parameter to /jsp2.jsp and put an error on the ActionsErrors.
>
> The just of all this is: the input parameter is set in struts-config.xml
> and it validation fails it goes back to this jsp for the user to fix
> it.  I need to change the input jsp page dynamically from inside the
> form bean.
>
> Please help
> thanks
> troy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Change Input parameter at run time part 2...

Posted by Michael Jouravlev <jm...@gmail.com>.
Oh, and by the way, I suggest that instead of hacking "input" property
you abandon it altogether as well as autovalidation. If you turn
autovalidation off, your action.execute() method will always be
called, so you can call actionform.validate() manually and then make a
decision where to forward. Much cleaner if you ask me.

On 5/4/06, Michael Jouravlev <jm...@gmail.com> wrote:
> It is not possible (at least legally). You should create a new
> ActionMapping object.
>
> On 5/4/06, Troy Bull <tr...@gmail.com> wrote:
> > I found mapping.setInput but i get an error when i try to change it
> > telling me
> >
> > java.lang.IllegalStateException: Configuration is frozen
> >
> > How do u temporarily unfreeze my configuration so I can change my input ??
> >
> > thanks
> > troy
> >
> >
> >
> > Troy Bull said the following on 5/4/2006 1:37 PM:
> > > Greetings
> > >
> > > I have an application i have inherited.  There is a situation where 2
> > > jsp's submit to the same action with the same form bean.  In the
> > > validation function inside the form bean if there is one type of error
> > > I want to set the input parameter to /jsp1.jsp and put an ActionError
> > > on the ActionErrors.  If there is an error of type 2 I want to set the
> > > input parameter to /jsp2.jsp and put an error on the ActionsErrors.
> > >
> > > The just of all this is: the input parameter is set in
> > > struts-config.xml and it validation fails it goes back to this jsp for
> > > the user to fix it.  I need to change the input jsp page dynamically
> > > from inside the form bean.

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


Re: Change Input parameter at run time part 2...

Posted by Michael Jouravlev <jm...@gmail.com>.
It is not possible (at least legally). You should create a new 
ActionMapping object.

On 5/4/06, Troy Bull <tr...@gmail.com> wrote:
> I found mapping.setInput but i get an error when i try to change it
> telling me
>
> java.lang.IllegalStateException: Configuration is frozen
>
> How do u temporarily unfreeze my configuration so I can change my input ??
>
> thanks
> troy
>
>
>
> Troy Bull said the following on 5/4/2006 1:37 PM:
> > Greetings
> >
> > I have an application i have inherited.  There is a situation where 2
> > jsp's submit to the same action with the same form bean.  In the
> > validation function inside the form bean if there is one type of error
> > I want to set the input parameter to /jsp1.jsp and put an ActionError
> > on the ActionErrors.  If there is an error of type 2 I want to set the
> > input parameter to /jsp2.jsp and put an error on the ActionsErrors.
> >
> > The just of all this is: the input parameter is set in
> > struts-config.xml and it validation fails it goes back to this jsp for
> > the user to fix it.  I need to change the input jsp page dynamically
> > from inside the form bean.
> >
> > Please help
> > thanks
> > troy
> >
> > ---------------------------------------------------------------------
> > 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


Re: Change Input parameter at run time part 2...

Posted by Troy Bull <tr...@gmail.com>.
I found mapping.setInput but i get an error when i try to change it 
telling me

java.lang.IllegalStateException: Configuration is frozen

How do u temporarily unfreeze my configuration so I can change my input ??

thanks
troy



Troy Bull said the following on 5/4/2006 1:37 PM:
> Greetings
>
> I have an application i have inherited.  There is a situation where 2 
> jsp's submit to the same action with the same form bean.  In the 
> validation function inside the form bean if there is one type of error 
> I want to set the input parameter to /jsp1.jsp and put an ActionError 
> on the ActionErrors.  If there is an error of type 2 I want to set the 
> input parameter to /jsp2.jsp and put an error on the ActionsErrors.
>
> The just of all this is: the input parameter is set in 
> struts-config.xml and it validation fails it goes back to this jsp for 
> the user to fix it.  I need to change the input jsp page dynamically 
> from inside the form bean.
>
> Please help
> thanks
> troy
>
> ---------------------------------------------------------------------
> 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