File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes how to add 2 submit buttons of different form actions in same row in jsp page in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to add 2 submit buttons of different form actions in same row in jsp page in struts2" Watch "how to add 2 submit buttons of different form actions in same row in jsp page in struts2" New topic
Author

how to add 2 submit buttons of different form actions in same row in jsp page in struts2

dhaval tamboli
Greenhorn

Joined: Aug 02, 2010
Posts: 25
Hi,

I am trying to put 2 submit buttons in same form and they both calls different actions from struts.xml
My problem is I want to put that buttons in same row. but, I am not able to do that.

my code is



I tried many ways to put in same row but as such they both belongs to different actions, I am not able to put in same row.
Let me know if any of you have idea to accomplish it

Thanks,
Dhaval
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Use simple theme with both forms, that way Struts won't generate any tables so you can have both buttons in the same row. More info on themes can be found here...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
dhaval tamboli
Greenhorn

Joined: Aug 02, 2010
Posts: 25
hi,

first of all let me tell you about this form. This form fetches agency information from database and we can edit information from here and also it shows users of this agency through another submit button.

Here I tried to use simple theme but still it gives me button at different rows.

Here is the whole code.




chris locke
Greenhorn

Joined: Aug 13, 2010
Posts: 17
I'm running into the same problem as well. Does anyone have a solution to this?

Is there maybe another way of invoking an action via a button without using the <s:form> tag?
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

chris locke wrote:Is there maybe another way of invoking an action via a button without using the <s:form> tag?

Yup. Using action attribute. Have you tried this.


A.A.Anbarasu
chris locke
Greenhorn

Joined: Aug 13, 2010
Posts: 17
How can the action attribute prevent the buttons from being on different rows?
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

chris locke wrote:How can the action attribute prevent the buttons from being on different rows?

As 'Ankit Garg' said use simple theme for this issue. Use action attribute of submit button for calling different actions from same form.
chris locke
Greenhorn

Joined: Aug 13, 2010
Posts: 17
Yes, I tried the simple theme as was originally suggested back on August 10...I wouldn't have responded to this thread otherwise. The issue is that when adding 'theme="simple"' to the form tag, tables are no longer generated but that still won't bring the buttons into the same row.
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

chris locke wrote:The issue is that when adding 'theme="simple"' to the form tag, tables are no longer generated but that still won't bring the buttons into the same row.
Can you please post your code
chris locke
Greenhorn

Joined: Aug 13, 2010
Posts: 17
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

chris locke wrote:
Main question is usign two buttons in a form, which are supposed to call different actions.

For this using two different forms are NOT an solution.

use one form with theme as 'simple' and keep two buttons inside the same form and use the action attribute of those buttons to call respective actions.
chris locke
Greenhorn

Joined: Aug 13, 2010
Posts: 17
Hmm.. Okay, I found another example on google which supported the original code (2 forms) with a simple theme, but it had as an addendum that you must manipulate the css stylesheet to incorporate the generated ID and add the line "display: inline;"

I tried it out and found that it works, but I like your way better. Thank you
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to add 2 submit buttons of different form actions in same row in jsp page in struts2