On Tuesday, September 2, 2003, at 12:33 PM, Adam Hardy wrote:
Sure it works in principle, I use the technique too. I depends on how you've implemented it and what errors you're getting. Off the top of my head I can't think of anything except some serious exception which would disable the call to the action.
The form's scope doesn't need to be session. It depends again on the implementation. The data in the form is sent out in the request and sent back to the server in the next request from the browser. I never bother keeping the form in session.
Adam
On 09/02/2003 12:54 AM David Thielen wrote:Hi;
I tried this below but when I did http://localhost/account/setup/pre it created a form but never called the action class. Any ideas?
Also, shouldn't the scope below be session so the same form is used?
thanks - dave
---------------------------------------------------------------------- ----------
a.. From: Ted Husted b.. Subject: Re: Pre populate c.. Date: Mon, 11 Jun 2001 08:20:16 -0700 ---------------------------------------------------------------------- ----------
Many times pre-processing and post-processing are related, and it can be
convenient to handle both in the same Action class. A good way to implement this is to have a seperate Action Mapping for
each task (pre-process and post-process). Both mappings would point to
the same Action but use different (virtual) paths. Like say <
/account/setup/pre > and < /account/setup/post >. These may both use the
same Action class, which could be < package/account/setup.java >. The Struts mappings accept an extra "parameter" property that you can
easily test in the Action to see which mapping has been chosen. Your
action can
then process each task differently, and even go to separate locations if
successfuly. By managing this all in the struts-config.xml, you gain a
lot of flexbility. In struts-config: <action path="/account/setup/pre"
type="package.account.Setup.java"
name="setupForm"
scope="request"
validate="false"
input="/WEB-INF/jsp/account/setup/Form.jsp"
parameter="pre">
<forward name="success" path="/WEB-INF/jsp/account/setup/Form.jsp"/>
</action>
<action path="/account/setup/post"
type="package.account.Setup.java"
name="setupForm"
scope="request"
validate="true"
input="/WEB-INF/jsp/setup/Form.jsp"
parameter="post">
<forward name="success" path="/WEB-INF/jsp/account/setup/View.jsp"/>
</action>
In your Action: String task = mapping.getParameter();
// handle task for "pre" or task for "post"
// ...
// ...
return (mapping.findForward("success"));
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/
Kiet Nguyen wrote:I need to pre-populate my form and do some business processes prior to load
a page. Where would be the best place for this. I don't want to put it in
the peform method of the "from page". And doing business process at the
form bean does not seen appropriate.
-- struts 1.1 + tomcat 4.1.27 + java 1.4.2 Linux 2.4.20 RH9
--------------------------------------------------------------------- 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]

