> -----Original Message----- > From: Jesus Rodriguez [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 25, 2004 2:02 PM > To: Struts Users Mailing List > Subject: 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
You mean as in the jsp form? and not the ActionForm? If I'm using the same form in multiple places, I'll put it into it's own jsp file, and either include it using tiles, or jsp:include. But only if everything is the same. more below.... > 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"> Why not do the include for the fields after the html:form... just the fields on the page... so your main page would be vaguley like: <html:form blah> <jsp:include dah fields page/> </html:form> > ... > > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]