Reputation:
I am trying to place three submit buttons in the same line but they keep appearing one below another. The buttons function perfectly fine, I just cannot get them to be on the same line. My code in the .jsp file:
<table>
<tr>
<s:submit value="Save" />
<s:submit value="Cancel" action="cancelAction"/>
<s:submit value="Add" action="requirementValidationAction" />
</tr>
</table>
However, after I build and run the page, the HTML source shows up like this:
<table>
<tr>
<tr>
<td colspan="2"><div align="right"><input type="submit" id="addToParkingLotAction_0" value="Save"/>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="right"><input type="submit" id="addToParkingLotAction_cancelAction" name="action:cancelAction" value="Cancel"/>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="right"><input type="submit" id="addToParkingLotAction_requirementValidationAction" name="action:requirementValidationAction" value="Add"/>
</div></td>
</tr>
</table>
Struts2 is adding its own table row for each of the submit buttons causing them to be one below another. I tried removing the declaration but it still looks the same. I also tried removing the table completely, no dice. Help would be most appreciated.
Upvotes: 4
Views: 9497
Reputation: 23587
Struts2 by default use xhtml theme
The default theme that uses common HTML practices.
in your case you are using that theme so struts underlying system is generating this for you
use simple theme
you can set theme simple per page basis
<s:set name="theme" value="'simple'" scope="page" />
or per tag basis as each tag has theme property like
<s:submit value="Save" theme="simple" />
if you want theme as simple for your entire application so that it should not generate default HTMl for your application you can do it either in struts.property file or in struts config file like
in struts.properties file
struts.ui.theme=simple
or in struts config file as
as a constant
<constant name="struts.ui.theme" value="simple" />
Upvotes: 4
Reputation: 160191
The default theme puts form elements in table rows/cells.
Create the buttons while specifying the "simple" theme:
<s:submit value="Save" theme="simple" />
<s:submit value="Cancel" action="cancelAction" theme="simple" />
<s:submit value="Add" action="requirementValidationAction" theme="simple" />
There are a number of ways to set the theme; doing it in every element may not be the best for your circumstances--probably better to set the theme on the form itself.
If you have app needs that go beyond what's provided in the default, you may want to create your own theme.
Upvotes: 4