user1828016
user1828016

Reputation: 29

New Rows being inserted automatically in a table in JSP

I have a table (inside a div) containing some input fields in my JSP. Having trouble with one of the rows. I have 3 dropdowns in 3 different cells in my second row. These 3 dropdowns are being displayed on top of each other instead of being next to each other. So instead of

[Select 1] [Select 2] [Select 3]

I am getting:

FIRST
SECOND
THIRD

When I view the rendered HTML, it appears that new rows are being inserted automatically after each drop down. Need help displaying the 3 drop downs next to each other.

Code:

 <s:form action="insNewAct" namespace="/">
   <table>
     <tr> 
      <td><s:textfield name="jobName" label = "Job Name" size="20" /></td>
      <td>&nbsp;</td><td>&nbsp;</td>
     </tr>
     <tr>
      <td>          
        <s:select 
        label = "Job Schedule"
        headerKey="-1" headerValue="Hour"
        list="{'1', '2', '3', '4'}" 
        name="hour"/>
      </td>
      <td>
        <s:select 
        headerKey="-1" headerValue="Minute"
        list="{'01', '02', '03', '04', '05' }" 
        name="minute"/>   
    </td>
    <td>      
        <s:select 
        headerKey="-1" headerValue="AM/PM"
        list="#{'A':'AM', 'P':'PM'}" 
        name="ampm"/>
    </td>
    </tr>
      <tr>
        <td><s:submit value="Submit" name="submit" align="center"/></td><td>&nbsp;</td><td>&nbsp;</td>
      </tr>
 </table>
 </s:form>  

Upvotes: 1

Views: 1353

Answers (1)

Dave Newton
Dave Newton

Reputation: 160261

The default Struts 2 theme "xhtml" puts form elements in table rows.

If you want to use the "simple" theme:

<s:select label = "Job Schedule"
          headerKey="-1" headerValue="Hour"
          list="{'1', '2', '3', '4'}" 
          name="hour"
          theme="simple"
          />

The caveat is that this will then not support the built-in error messages provided by the validation framework, although they can be handled manually for small chunks of "simple" theme functionality.

Upvotes: 1

Related Questions