You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sebastian Ho <se...@bii.a-star.edu.sg> on 2004/08/19 11:19:35 UTC

different inputs in struts-config

hi

I used the same actionform for a few JSP pages, which I guess is good
practice. The problem occurs when I add in validation in my ActionForm. 

Because in the struts-config, only one <input> is specified for every
Action. Therefore, whenever validation fails and struts display the
error messages, struts prints it in the JSP given in <input>.

Ideally, struts should forward and prints out the error messages in the
JSP that calls the ActionForm.

I tried adding in multiple action mapping in my struts-config with
identical settings except <input>, which I hope struts will be smart
enough to decide which mapping to use. Unfortuntely, it doesn't.

I have read online that this strategy is quite popular. Therefore I am
sure there is a solution to this problem.

How do I forward the ActionError to the correct JSP instead of the one
in <input>?

Thanks

Sebastian Ho


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


Re: different inputs in struts-config

Posted by struts lover <st...@yahoo.com>.
Try using the attribute/formAttribute in the action
mapping. I think it should work.



--- Sebastian Ho <se...@bii.a-star.edu.sg> wrote:

> Thanks Susan.
> 
> Refer to my comments below
> 
> Sebastian Ho
> 
> 
> On Thu, 2004-08-19 at 21:23, Susan Bradeen wrote:
> > Sebastian Ho <se...@bii.a-star.edu.sg> wrote
> on 08/19/2004 05:19:35 
> > AM:
> > 
> > > hi
> > > 
> > > I used the same actionform for a few JSP pages,
> which I guess is good
> > > practice. The problem occurs when I add in
> validation in my ActionForm. 
> > > 
> > > Because in the struts-config, only one <input>
> is specified for every
> > > Action. Therefore, whenever validation fails and
> struts display the
> > > error messages, struts prints it in the JSP
> given in <input>.
> > > 
> > > Ideally, struts should forward and prints out
> the error messages in the
> > > JSP that calls the ActionForm.
> > > 
> > > I tried adding in multiple action mapping in my
> struts-config with
> > > identical settings except <input>, which I hope
> struts will be smart
> > > enough to decide which mapping to use.
> Unfortuntely, it doesn't.
> > >
> > 
> > Yes, you can reuse your actionform for multiple
> action mappings, but are 
> > your action mappings really identical except for
> the input? If I 
> > understand what you are trying to do, it sounds
> like you should have:
> > 
> > Action1 specifies ActionForm1 and input JSP1 and
> forwards to JSP1.
> > JSP1 probably then submits to Action2.
> > Action2 specifies ActionForm1 and input JSP2 and
> forwards to JSP2.
> > JSP2 probably then submits to Action3.
> > Action3 specifies ActionForm1 and input JSP3 and
> forwards to JSP3.
> > 
> 
> All of them ues the same action Action because I am
> using
> LookupDispatchAction.
> 
> So the struts-config ideally should be (which
> doesn't work) :
> Action1 specifies ActionFrom1 and input JSP1.
> Action1 specifies ActionForm1 and input JSP2.
> Action1 specifies ActionForm1 and input JSP3.
> 
> How do I achieve this effect?
> 
> > Is that about right? In this case, Validator
> should work fine.
> > 
> > Hth,
> > Susan Bradeen
> >  
> > > I have read online that this strategy is quite
> popular. Therefore I am
> > > sure there is a solution to this problem.
> > > 
> > > How do I forward the ActionError to the correct
> JSP instead of the one
> > > in <input>?
> > > 
> > > Thanks
> > > 
> > > Sebastian Ho
> > > 
> > > 
> > >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail:
> user-help@struts.apache.org
> > > 
> > > 
> > > 
> >
>
_____________________________________________________________________________
> > > Scanned for SoftLanding Systems, Inc. by IBM
> Email Security 
> > > Management Services powered by MessageLabs. 
> > > 
> >
>
_____________________________________________________________________________
> > 
> > 
> >
>
_____________________________________________________________________________
> > Scanned for SoftLanding Systems, Inc. by IBM Email
> Security Management Services powered by MessageLabs.
> 
> >
>
_____________________________________________________________________________
> > 
> >
>
---------------------------------------------------------------------
> > 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
> 
> 



		
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

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


Re: different inputs in struts-config

Posted by struts lover <st...@yahoo.com>.
Hi ,
You can validate using LookupDispatchAction class. The
validation.xml will take care of it. Also if you want
to do other business side validations, you can do it
in your methods in the action class.



--- Susan Bradeen <Su...@softlanding.com> wrote:

> Sebastian Ho <se...@bii.a-star.edu.sg> wrote on
> 08/19/2004 09:25:38 
> PM:
> 
> > Thanks Susan.
> > 
> > Refer to my comments below
> > 
> > Sebastian Ho
> > 
> > 
> > On Thu, 2004-08-19 at 21:23, Susan Bradeen wrote:
> > > Sebastian Ho <se...@bii.a-star.edu.sg>
> wrote on 08/19/2004 
> 05:19:35 
> > > AM:
> > > 
> > > > hi
> > > > 
> > > > I used the same actionform for a few JSP
> pages, which I guess is 
> good
> > > > practice. The problem occurs when I add in
> validation in my 
> ActionForm. 
> > > > 
> > > > Because in the struts-config, only one <input>
> is specified for 
> every
> > > > Action. Therefore, whenever validation fails
> and struts display the
> > > > error messages, struts prints it in the JSP
> given in <input>.
> > > > 
> > > > Ideally, struts should forward and prints out
> the error messages in 
> the
> > > > JSP that calls the ActionForm.
> > > > 
> > > > I tried adding in multiple action mapping in
> my struts-config with
> > > > identical settings except <input>, which I
> hope struts will be smart
> > > > enough to decide which mapping to use.
> Unfortuntely, it doesn't.
> > > >
> > > 
> > > Yes, you can reuse your actionform for multiple
> action mappings, but 
> are 
> > > your action mappings really identical except for
> the input? If I 
> > > understand what you are trying to do, it sounds
> like you should have:
> > > 
> 
> > > Action1 specifies ActionForm1 and input JSP1 and
> forwards to JSP1.
> > > JSP1 probably then submits to Action2.
> > > Action2 specifies ActionForm1 and input JSP2 and
> forwards to JSP2.
> > > JSP2 probably then submits to Action3.
> > > Action3 specifies ActionForm1 and input JSP3 and
> forwards to JSP3.
> > > 
> > 
> > All of them ues the same action Action because I
> am using
> > LookupDispatchAction.
> > 
> > So the struts-config ideally should be (which
> doesn't work) :
> > Action1 specifies ActionFrom1 and input JSP1.
> > Action1 specifies ActionForm1 and input JSP2.
> > Action1 specifies ActionForm1 and input JSP3.
> > 
> > How do I achieve this effect?
> > 
> 
> <snip/>
> 
> Aha, I'm not familiar enough with
> LookupDispatchAction to offer much help 
> off the top of my head. Sorry about that. I don't
> know if you can call the 
> validate() from your LDA methods manually, then if
> errors come back, 
> return a new ActionForward to the proper JSP,
> depending on what JSP you 
> came from (via a hidden field passed in from the
> JSP?)?
> 
> Hopefully someone with more LDA experience will
> offer more suggestions ...
> 
> Susan
> 
>
_____________________________________________________________________________
> Scanned for SoftLanding Systems, Inc. by IBM Email
> Security Management Services powered by MessageLabs.
> 
>
_____________________________________________________________________________
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



		
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

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


Re: different inputs in struts-config

Posted by Susan Bradeen <Su...@softlanding.com>.
Sebastian Ho <se...@bii.a-star.edu.sg> wrote on 08/19/2004 09:25:38 
PM:

> Thanks Susan.
> 
> Refer to my comments below
> 
> Sebastian Ho
> 
> 
> On Thu, 2004-08-19 at 21:23, Susan Bradeen wrote:
> > Sebastian Ho <se...@bii.a-star.edu.sg> wrote on 08/19/2004 
05:19:35 
> > AM:
> > 
> > > hi
> > > 
> > > I used the same actionform for a few JSP pages, which I guess is 
good
> > > practice. The problem occurs when I add in validation in my 
ActionForm. 
> > > 
> > > Because in the struts-config, only one <input> is specified for 
every
> > > Action. Therefore, whenever validation fails and struts display the
> > > error messages, struts prints it in the JSP given in <input>.
> > > 
> > > Ideally, struts should forward and prints out the error messages in 
the
> > > JSP that calls the ActionForm.
> > > 
> > > I tried adding in multiple action mapping in my struts-config with
> > > identical settings except <input>, which I hope struts will be smart
> > > enough to decide which mapping to use. Unfortuntely, it doesn't.
> > >
> > 
> > Yes, you can reuse your actionform for multiple action mappings, but 
are 
> > your action mappings really identical except for the input? If I 
> > understand what you are trying to do, it sounds like you should have:
> > 

> > Action1 specifies ActionForm1 and input JSP1 and forwards to JSP1.
> > JSP1 probably then submits to Action2.
> > Action2 specifies ActionForm1 and input JSP2 and forwards to JSP2.
> > JSP2 probably then submits to Action3.
> > Action3 specifies ActionForm1 and input JSP3 and forwards to JSP3.
> > 
> 
> All of them ues the same action Action because I am using
> LookupDispatchAction.
> 
> So the struts-config ideally should be (which doesn't work) :
> Action1 specifies ActionFrom1 and input JSP1.
> Action1 specifies ActionForm1 and input JSP2.
> Action1 specifies ActionForm1 and input JSP3.
> 
> How do I achieve this effect?
> 

<snip/>

Aha, I'm not familiar enough with LookupDispatchAction to offer much help 
off the top of my head. Sorry about that. I don't know if you can call the 
validate() from your LDA methods manually, then if errors come back, 
return a new ActionForward to the proper JSP, depending on what JSP you 
came from (via a hidden field passed in from the JSP?)?

Hopefully someone with more LDA experience will offer more suggestions ...

Susan

_____________________________________________________________________________
Scanned for SoftLanding Systems, Inc. by IBM Email Security Management Services powered by MessageLabs. 
_____________________________________________________________________________

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


Re: different inputs in struts-config

Posted by Sebastian Ho <se...@bii.a-star.edu.sg>.
Thanks Susan.

Refer to my comments below

Sebastian Ho


On Thu, 2004-08-19 at 21:23, Susan Bradeen wrote:
> Sebastian Ho <se...@bii.a-star.edu.sg> wrote on 08/19/2004 05:19:35 
> AM:
> 
> > hi
> > 
> > I used the same actionform for a few JSP pages, which I guess is good
> > practice. The problem occurs when I add in validation in my ActionForm. 
> > 
> > Because in the struts-config, only one <input> is specified for every
> > Action. Therefore, whenever validation fails and struts display the
> > error messages, struts prints it in the JSP given in <input>.
> > 
> > Ideally, struts should forward and prints out the error messages in the
> > JSP that calls the ActionForm.
> > 
> > I tried adding in multiple action mapping in my struts-config with
> > identical settings except <input>, which I hope struts will be smart
> > enough to decide which mapping to use. Unfortuntely, it doesn't.
> >
> 
> Yes, you can reuse your actionform for multiple action mappings, but are 
> your action mappings really identical except for the input? If I 
> understand what you are trying to do, it sounds like you should have:
> 
> Action1 specifies ActionForm1 and input JSP1 and forwards to JSP1.
> JSP1 probably then submits to Action2.
> Action2 specifies ActionForm1 and input JSP2 and forwards to JSP2.
> JSP2 probably then submits to Action3.
> Action3 specifies ActionForm1 and input JSP3 and forwards to JSP3.
> 

All of them ues the same action Action because I am using
LookupDispatchAction.

So the struts-config ideally should be (which doesn't work) :
Action1 specifies ActionFrom1 and input JSP1.
Action1 specifies ActionForm1 and input JSP2.
Action1 specifies ActionForm1 and input JSP3.

How do I achieve this effect?

> Is that about right? In this case, Validator should work fine.
> 
> Hth,
> Susan Bradeen
>  
> > I have read online that this strategy is quite popular. Therefore I am
> > sure there is a solution to this problem.
> > 
> > How do I forward the ActionError to the correct JSP instead of the one
> > in <input>?
> > 
> > Thanks
> > 
> > Sebastian Ho
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> > 
> _____________________________________________________________________________
> > Scanned for SoftLanding Systems, Inc. by IBM Email Security 
> > Management Services powered by MessageLabs. 
> > 
> _____________________________________________________________________________
> 
> 
> _____________________________________________________________________________
> Scanned for SoftLanding Systems, Inc. by IBM Email Security Management Services powered by MessageLabs. 
> _____________________________________________________________________________
> 
> ---------------------------------------------------------------------
> 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: different inputs in struts-config

Posted by Susan Bradeen <Su...@softlanding.com>.
Sebastian Ho <se...@bii.a-star.edu.sg> wrote on 08/19/2004 05:19:35 
AM:

> hi
> 
> I used the same actionform for a few JSP pages, which I guess is good
> practice. The problem occurs when I add in validation in my ActionForm. 
> 
> Because in the struts-config, only one <input> is specified for every
> Action. Therefore, whenever validation fails and struts display the
> error messages, struts prints it in the JSP given in <input>.
> 
> Ideally, struts should forward and prints out the error messages in the
> JSP that calls the ActionForm.
> 
> I tried adding in multiple action mapping in my struts-config with
> identical settings except <input>, which I hope struts will be smart
> enough to decide which mapping to use. Unfortuntely, it doesn't.
>

Yes, you can reuse your actionform for multiple action mappings, but are 
your action mappings really identical except for the input? If I 
understand what you are trying to do, it sounds like you should have:

Action1 specifies ActionForm1 and input JSP1 and forwards to JSP1.
JSP1 probably then submits to Action2.
Action2 specifies ActionForm1 and input JSP2 and forwards to JSP2.
JSP2 probably then submits to Action3.
Action3 specifies ActionForm1 and input JSP3 and forwards to JSP3.

Is that about right? In this case, Validator should work fine.

Hth,
Susan Bradeen
 
> I have read online that this strategy is quite popular. Therefore I am
> sure there is a solution to this problem.
> 
> How do I forward the ActionError to the correct JSP instead of the one
> in <input>?
> 
> Thanks
> 
> Sebastian Ho
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
_____________________________________________________________________________
> Scanned for SoftLanding Systems, Inc. by IBM Email Security 
> Management Services powered by MessageLabs. 
> 
_____________________________________________________________________________


_____________________________________________________________________________
Scanned for SoftLanding Systems, Inc. by IBM Email Security Management Services powered by MessageLabs. 
_____________________________________________________________________________

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