Reputation: 57176
Here's the .jsp code:
<table>
<s:iterator value="allAgents">
<tr>
<td><s:property value="firstName" /></td>
<td><s:property value="middleName" /></td>
<td><s:property value="lastName" /></td>
<td><s:checkbox name="ss"/></td>
</tr>
</s:iterator>
</table>
When rendered, the checkbox would occupy a whole row below the 'names', centered. Here's the generated html for what's supposed to be a single row:
<tr>
<td>first</td>
<td>middle</td>
<td>last</td>
<td>
<tr>
<td valign="top" align="right"></td>
<td valign="top" align="left"><input type="checkbox" name="ss"
value="true" id="agent_ss" /> <input type="hidden"
name="__checkbox_ss" value="true" /></td>
</tr>
</td>
</tr>
Is it me or struts? TIA.
Upvotes: 5
Views: 9969
Reputation:
When defining your checkbox, use "theme = simple" attribute as shown in the following:
The "simple" theme will put your checkbox in the same row as the other fields of your. Cheers.
Upvotes: 2
Reputation:
Struts2 renders s:checkbox as a table cell itself.The reason is tht struts2 uses a template system for tag rendering. The default is (as defined in struts-default.properties)
struts.ui.theme=xhtml
struts.ui.templateDir=template
struts.ui.templateSuffix=ftl
You need to make this change -- struts.ui.theme:simple
It can be done by adding
constant name="struts.ui.theme" value="simple" /> tag
in the "struts.xml".This wil suffice.
Upvotes: 5
Reputation: 8054
The problem is that with the default struts theme, s:checkbox
is a table cell itself.
(Struts 2 renders it as a table cell)
In your jsp you include it in <td>
tags again (which is not needed)
Try removing the <td>
tags around the checkbox tag.
Upvotes: 0
Reputation: 46
You need to look into the theme that is being used for your form tag rendering. Struts2 uses a template system (defined in struts.properties). It looks like you are using the xhtml template by default which is designed to output a two-column table. You can default to simple in the app or override it on the tag-level (or five other hierarchies in between).
Here's some more info: http://struts.apache.org/2.0.14/docs/themes-and-templates.html
Upvotes: 3