You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jesus Rodriguez <je...@redhat.com> on 2004/08/25 23:02:02 UTC
Reusing forms and configuring struts-config.xml
Is there a good way of reusing forms? I have several pages which are
the exact same form but different URLS and headings. So I've broken it
up as follows:
1) preferences.jsp contains the form which is common.
2) yourpreferences.jsp has some stuff then includes preferences.jsp and
is referenced by http://.../network/account/yourpreferences
3) userpreferences.jsp has some other stuff then includes
preferences.jsp and is referenced by
http://.../network/users/userpreferences
In my struts-config I have a formbean defined for the preferences.jsp
form. Then I have 4 actions defined (this is where my problem lies).
One action which sets up the values of the form,
<action path="/network/account/yourpreferences"
name="userPrefForm"
scope="request"
input="/WEB-INF/yourpreferences.jsp"
type="app.userprefeditaction">
<forward name="success" path="/WEB-INF/yourpreferences.jsp" />
</action>
The other action is for userpreferences
<action path="/network/users/userpreferences"
name="userPrefForm"
scope="request"
input="/WEB-INF/userpreferences.jsp"
type="app.userprefeditaction">
<forward name="success" path="/WEB-INF/userpreferences.jsp" />
</action>
Ok now the problem begins. The form in preferences.jsp is declared as
follows:
<html:form action="/network/users/PrefSubmit">
...
Well in struts-config, /network/users/PrefSubmit is defined as follows:
<action path="/network/users/PrefSubmit"
name="userPrefForm"
scope="request"
input="/WEB-INF/userpreferences.jsp"
type="app.UserPreferencesAction">
<forward name="success"
path="/network/users/userpreferences.do"
redirect="true" />
<forward name="failure"
path="/network/users/userpreferences.do" />
</action>
What I want is for the submit button of the form to redirect to the file
which it was called from. So if the user invokes
/network/account/yourpreferences and clicks the submit, they should be
returned to the /network/account/yourpreferences page instead of
/network/users/userpreferences.
Is there a way to dynamically define the action in the form? How about
the location of where the submit goes to?
Sincerely,
Jesus M. Rodriguez
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org