Struts2: s: checkbox is not on the same line with s: checkbox

Here is 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 rendering, the flag will occupy a whole line under the "names" centered. This generates html for what should be a single line:

<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 racks? TIA.

+5
source share
5 answers

Add property theme = "simple" as

+6
source

Struts2 displays the s: flag as the table cell itself. The reason is that strts2 uses a template system to render tags. Default value (as defined in struts-default.properties)

Standard UI Theme

= struts.ui.theme XHTML

struts.ui.templateDir = template

struts.ui.templateSuffix = FTL

- struts.ui.theme: simple

,

name= "struts.ui.theme" value = "simple" /" > tag

"struts.xml". .

+5

, . Struts2 ( struts.properties). , xhtml , . ( ).

: http://struts.apache.org/2.0.14/docs/themes-and-templates.html

+3

"theme = simple", :

A “simple” theme will put your flag in the same line as the other fields of yours. Greetings.

+2
source

The problem is that using the theme, struts is by default s:checkboxthe table cell itself. (Struts 2 displays it as a table cell)

In your jsp you include it again in tags <td>(which is not needed)

Try removing tags <td>around the tag tag.

0
source

All Articles