Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tracking a request in struts

 
Abebe Belew
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My index page has two links "checking" and "saving" and I want to use the same <action-mapping> in the struts-config.xml file since both do the same thing except for one thing, which is

in my jsp page I have a hidden field:
<input type="hidden" name="check_save" value="1">

when clicking on "checking" I want the value of "check_save" to be "1" and
when clicking on "saving" I want the value of "check_save" to be "2", since the query I do in my bean differes according to the value.

the question is since both links use the same action how do I track where the request is coming from "checking" or "saving" to change the value of "check_save" accordingly?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend using two ActionMappings but have them both use the same Action. You can use the different ActionMappings to specify the parameter you desire. This can be done using the parameter attribute of the ActionMappings in struts-config.

Having two Actions really isn't that bad of an idea either.
 
Abebe Belew
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not quite sure what you suggested since I am new to struts.
can you please give me an example?
[ December 03, 2004: Message edited by: Abebe Belew ]
 
Abebe Belew
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does anybody have an example of how to use the property parameter in Action Mapping to solve the above mentioned question?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic