0

I have one JSP page which has two forms with submit buttons. How to configure different action class those two forms?

For example:

form1 submit button configuration to classA and form2 submit button configuration to classB.

Is it possible?

Roman C
  • 49,761
  • 33
  • 66
  • 176
user2444474
  • 623
  • 8
  • 21
  • 40

2 Answers2

1

As easy as:

<s:form>
    ...
    <s:submit action="Action1" />
</s:form>

<s:form>
    ...
    <s:submit action="Action2" />
</s:form>

You can even use different <s:submit> buttons for the same <s:form>

<s:form>
    ...
    <s:submit action="Action1" />
    <s:submit action="Action2" />
</s:form>
Armaggedon
  • 399
  • 4
  • 14
0

Forms and buttons are mapped to the actions, actions are mapped to the methods of classes.

You have many but not nested forms in the JSP that could map to the action using the action attribute.

The button submit should normally not include any of action or method attribute, that means it might invert the direction the action which communicates dynamically.

To use this feature with the default action mapper you have a DMI turned on.

You could have many actions mapping to the same method with different names, but you couldn't have an action in the same namespace to map different classes or methods. Those classes or methods should be in the different namespaces.

The same thing for the form, you could map the form or button with any action. Many forms could map to the same action, but you couldn't map the form with different action. For this, you have to map the button, or use javascript to modify action attribute with the different action to change the mapping.

Roman C
  • 49,761
  • 33
  • 66
  • 176