There are two solutions that you have available to you (well that I know off
the top of my head):

1) Use the _attribute_ property in the action tag to give each form a
pseudonym:

        <action path="/example1" 
                        type="com.marsh-bourdon.struts.action.ExampleAction"
                        attribute="pseudonymForm1"
                        name="exampleForm"
                        input="example.input"
                        scope="request"
                        validate="false">
                <forward name="success" path="example.confirm"
redirect="false" />
                <forward name="failure" path="example.input"
redirect="false" />
        </action>

        <action path="/example2" 
                        type="com.marsh-bourdon.struts.action.ExampleAction"
                        attribute="pseudonymForm2"
                        name="exampleForm"
                        input="example.input"
                        scope="request"
                        validate="false">
                <forward name="success" path="example.confirm"
redirect="false" />
                <forward name="failure" path="example.input"
redirect="false" />
        </action>

This would label each form _pseudonymForm1_ and _pseudonymForm2_ in turn,
thus removing the clash.

2) Use just one form and incorporate the <html:hidden> tag to add some sort
of switch and depending on the button/link that is clicked, set the hidden
object's value, pick that up as part of the form, and then use it as a flag
in the action that you use.

I hope this helps.

Christopher Marsh-Bourdon
www.marsh-bourdon.com

-----Original Message-----
From: tarek.nabil [mailto:[EMAIL PROTECTED] 
Sent: 30 March 2005 12:03
To: Struts Users Mailing List
Subject: Form name collision


Hi,

I'm facing a problem with having multiple forms that submit to the same
action on the same page.

I have a search page with a few search fields. The user does the search
and gets the paged results in the *SAME* page.
Now, the user can either change the search criteria and search again, or
use the pagination links to go back and forward through the search
results.

As a result, I have to have two forms (or at least that's the solution I
thought of). The first is the seach form and the seconds is the
pagination form. The pagination form has hidden fields containing the
values the user searched for the last time. I need to do this because if
the user changes the search criteria, I can not afford to have the
pagination links retrieve different results.

The problem is, since both forms will submit to the same action, they
both get the same name, and so, I get colliding names in the HTML.

Anyone knows a work around for this issue?

One solution I thought of would be to use only one form and if the user
clicks on the pagination links, I call reset() on the HTML form to get
it back to its original state. I'm reluctant to do this, though, because
if the search takes some time, this action will be visible to the user
and it might look awkward.

Every help is appreciated.

Thanks,
Tarek Nabil

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 ------


----------------------------------------------------------------------
If you have received this e-mail in error or wish to read our e-mail 
disclaimer statement and monitoring policy, please refer to 
http://www.drkw.com/disc/email/ or contact the sender.
----------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to