Thanks that was really useful.
I have one final question, what do you specify in the "input" tag? the Action class name or a ActionForward or what?
Qasim
Aaron Longwell wrote:
Qasim,
I actually use separate actions. I have an edit action, an update action (which handles both creation of a new record and updating of an existing record) and a list action (which views data about certain records):
<!-- BAND LIST -->
<action path="/band/list" type="dove.struts.actions.BandAction" parameter="list" validate="false">
</action>
<!-- BAND CREATE -->
<action path="/band/create" type="dove.struts.actions.BandAction" name="BandForm" scope="request" parameter="create" validate="false" input="/WEB-INF/jsp/html/band/edit.jsp">
</action>
<!-- BAND EDIT -->
<action path="/band/edit" type="dove.struts.actions.BandAction" name="BandForm" scope="request" parameter="edit" validate="false" input="/WEB-INF/jsp/html/band/edit.jsp">
</action>
<!-- BAND UPDATE -->
<action path="/band/update" type="dove.struts.actions.BandAction" name="BandForm" scope="request"
parameter="update" validate="true" input="/band/create.action">
</action>
You'll see I have different actions fronting the same JSP. In addition I use a practice of hiding the JSPs behind the WEB-INF directory. The spec indicates that these directories must be secure.... so nobody can go to a JSP without visitng the action first.
A second strategy I use is to build only one action for each of my sub actions (see the type="") are all identical. To differentiate which mode the action is in I assign a different parameter attribute for each. Then within my execute method I check the parameter value:
String param = mapping.getParameter();
and then route to a private method inside the Action class. This keeps all the code in one place (in this case, in the BandAction class).
Qasim Khawaja wrote:
How do you distinguish the when the execute method is being called to populate the form and when it is being called to post the data from the form?
An example for the struts-config would be most useful.
Q
Aaron Longwell wrote:
The Action is called prior to presenting the JSP only if you've set up:
an action mapping to map the user's URL to a an action a forward to the JSP and you set the Action's execute method to return a forward to that JSP
The "entry point" into the action is the execute() method which returns an ActionForward object. To create an ActionForward object use code like the following in your execute() method:
return mapping.findForward("name_of_forward");
Qasim Khawaja wrote:
I need to populate three drop downs in a jsp before presentation. Currently I have writted routines in the ActionForm which access the DAO class and populate the lists. The problem is that the DAO class throws an exception which means that I have to make my ActionForm aware of a hibernateException. I want to do this in the action class and make use of declarative exception handling.
Is the Action called prior to presenting the jsp? If so what is the entry point?
Q
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- ====================================== Qasim Khawaja Computing Officer Oxford Colleges Admissions Office University Offices | Wellington Square |T: (01865) 280128 Oxford OX1 2JD |F: (01865) 280121 Email: [EMAIL PROTECTED] ======================================
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]