In "action mappings" usually an action is found based on the "path" and that's why we usually give different "path" names like "/submit_1", "/submit_2", etc.
What if I use a single same "path" name for all the JSP pages. For example, JSP1-->Servlet-->Action1-->JSP2--->Servlet-->Action2-->JSP3-->... I use path="/submit" for JSP1, JSP2, JSP3,etc, but the thing that distinguish them is the "input" (JSP1, JSP2, or JSP3, or somethimes no input). Does this work for sturts ? i.e. if we use a same "path" name , will the Action servlet correctly find the Action class based on the "input" value ? i.e what works as the "primary key" here ? is it "path" ? or "path" plus "input" ? or whatever ?
Of course I can try it. But I want to know better about the mechanism.
it will not work. the action mapping's path IS the 'primary' key. there isn't a way to pass in the "input" when you call an action...say /submit.do?input=jsp1...or something. what difference does it make using the 'path' vs. 'input'?
if you're looking for 1 mapping with multiple 'actions', consider MappedDispatchAction or DispatchedAction.
if you're looking to reduce the number of action mappings, best to consider using wildcards (see struts guide to action mappings on apache.org).
-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Joined: Jan 26, 2005
Thanks. In my page flow JSP1-->servlet-->action1-->JSP2-->action2-->JSP3-->.... Since they consists of ONE logical task and it is just broken into several pages for some reason, it will be nice that users see the same URI (like "submit.do" when they click "submit" button on JSP1, JSP2) instead of different URI (like "submit1.do", "submit2.do", "submit3.do" when they click "submit" button on JSP1, JSP2, JSP3).
Well, if there is no way to handle it, I guess I have to live with it. Just want to explain why I prefer to have a same "path" name in this scenario.
Joined: Apr 14, 2005
it's quite easy to accomodate what you are asking for...use DispatchAction. your 'parameter' attribute's value (which points to a method in the DispatchAction) would be in a hidden field in each of the forms. your URI will stay the same while each time the action will different.
Joined: Jan 26, 2005
Originally posted by alan do: it's quite easy to accomodate what you are asking for...use DispatchAction. your 'parameter' attribute's value (which points to a method in the DispatchAction) would be in a hidden field in each of the forms. your URI will stay the same while each time the action will different.
Thanks lot. I checked DispatchAction and MappingDispatchAction. They are all one Action class containing multiple action methods. It seems MappingDispatchAction doesn't suit my need because it uses different "path" names for each mapping; the DispatchAction looks good for my case because I can still use the same URI and either append with different "xxx" in "?method=xxx" or just pass it as a hidden variable. Excellent.