aspose file tools*
The moose likes Struts and the fly likes submit buttons in form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "submit buttons in form" Watch "submit buttons in form" New topic
Author

submit buttons in form

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 370
I have a jsp form looking like --

<s:form action="saveData">
.....

<s:submit value="save" action="saveData" name="submit"></s:submit>
<s:reset value="reset" name="reset"></s:reset>
<s:submit value="display" action="displayData" name="display"></s:submit>

</s:form>

I find that when I click the first button (save) the URL shows the /saveData.action.
But when I click the second button, I still see URL as /saveData.action, but the interesting thing is when I click the second button it is actually doing the right thing, which is displaying the data. I thought it is because I put the buttons inside the form and in the <form> attribute I already defined action="saveData". So I tried removing action="saveDat" in the <form> tag. After I did that, two buttons still did what are supposed to do. But when I clicked the first button it still saved Data but the URL shows the /displayData.

How can I insure that clicking the two buttons can both do the right logics and see the correct (desired) URL ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The URL that's displayed depends on the result configuration--if you're just doing a dispatch the URL won't change.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: submit buttons in form
 
Similar Threads
how to print multiple file uploads in console
s:submit
jQuery AJAX display issue
Struts 2 - Internationalize Submit Text
How to use CSS with Struts Tags?