• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What Does This Action Mapping Do?

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have problem to understand the action mapping shown below. I am trying to figure out what the mapping does:

As I remember, when the forward property is specified, the servlet will not pass the request to an Action class but will make a call to RequestDispatcher.forward to the context-relative path of the resource. Therefore, the request will be passed to .article.Menu.
My questions are:
1. Apparently, name="success" is a condition. I am confused about to 'what' does this condition apply. E.g. the control will be passed to .article.Menu under the condition 'what' = "success"?
2. What is the meaning of name="menuForm"?
3. What is the meaning of parameter="application;HOURS"?
[ September 17, 2003: Message edited by: JiaPei Jen ]
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1. Apparently, name="success" is a condition. I am confused about to 'what' does this condition apply. E.g. the control will be passed to .article.Menu under the condition 'what' = "success"?


Yes... success is a condition. You would have to determine what is
your success condition. This is typically done in your action class.
So, in ur action class, (which is denoted by the type that is present in
your action), you would have some logic which will deetermine is the
condition is a success or failure.
When there is a condition of success, you want your code to go to a particular page or execute another piece of code. This is identified by
what is specified in the forward within the action.
IN your action class code, you would then include something like:
forward = mapping.findForward("success");

2. What is the meaning of name="menuForm"


This is the action that you try to execute. ie. either from code or in
the browser you would try to access the action in the form
http://... menuForm.do

QUOTE]3. What is the meaning of parameter="application;HOURS"?[
Actions can have parameters. This means that when menuForm is executed,
the parameters mentioned are available to you. You could use these to
evaluate conditions within the action class.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just some clarifications to the previous reply:
1. "success" is a logical name used in your application. As the Nagendra explained, you determine what criteria need to be met for this condition. In code, you would have something like:

In your code, you don't worry about the actual URI for success. All you have to worry about is getting the forward name right. Figuring out the actual URI is left to Struts. This allows you to change the URI without having to change code.
2. Actions and ActionForms are tightly coupled. That is, an Action will usually expect a specific type of ActionForm to be passed to its execute/perform method. The action-mapping attribute name="menuForm" tells Struts that this particular Action expects the ActionForm specified in the <form ...> section of struts-config.xml that has the name "menuForm".
3. The value for the parameter attribute specified goes to an ActionMapping. This value is accessed by invoking the ActionMapping.getParameter() method. It looks like your application expects a value in the given format and parses out two values: "application" and "HOURS". You'll have to go through your code to find how these two values are used--it's specific to your application.
[ September 18, 2003: Message edited by: Junilu Lacar ]
 
My cellmate was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic