Child pages
  • Why do the form tags put table tags around controls

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: add example

...

For example, a form like this Wiki Markup\[TODO]

Code Block
HTML
HTML
tileJSP fragment

<s:form method="post">
    <s:textfield label="Name" name="name"/>
    <s:textfield label="Age" name="age"/>
    <s:textfield label="Favorite color" name="answer"/>
    <s:submit/>
</s:form>

using the default XHTML team, renders like this Wiki Markup\[TODO]

Code Block
HTML
HTML
titleGenerated HTML fragment

<form id="quizBasic" name="quizBasic" onsubmit="return true;"
    action="/struts2-showcase/validation/quizBasic.action" method="post">
    <table class="wwFormTable">
        <tr>
            <td class="tdLabel"><label for="quizBasic_name"
                class="label">Name:</label></td>
            <td><input type="text" name="name" value=""
                id="quizBasic_name" /></td>
        </tr>
    
        <tr>
            <td class="tdLabel"><label for="quizBasic_age"
                class="label">Age:</label></td>
            <td><input type="text" name="age" value="0"
                id="quizBasic_age" /></td>
        </tr>
    
        <tr>
            <td class="tdLabel"><label for="quizBasic_answer"
                class="label">Favorite color:</label></td>
            <td><input type="text" name="answer" value=""
                id="quizBasic_answer" /></td>
        </tr>
    
        <tr>
            <td colspan="2">
            <div align="right"><input type="submit" id="quizBasic_0"
                value="Submit" /></div>
            </td>
        </tr>
    </table>
</form>

Note that the Struts 2 tags include new attributes, like "label". The XHTML (and AJAX) themes will automatically inject a label tag into the form.

...