tags:

views:

56

answers:

2

Hello, i found a similar problem like this: http://stackoverflow.com/questions/2314296/struts2-form-elements but no answer is given until now. So here i post my difficulties with a vengeance.

I am using Struts2 with version 2.1.6. When I leave the input elements such as <s:textfield>, <s:textarea>, etc. of a <s:form> with the default theme, the elements are rendered as:

<tr>
    <td class="tdLabel"><label for="firstname" class="label">Firstname:</label></td>
    <td><input type="text" name="firstname" id="firstname"/></td>
</tr>
<tr>
    <td class="tdLabel"><label for="lastname" class="label">Lastname:</label></td>
    <td><input type="text" name="lastname" id="lastname"/></td>
</tr>

Now if i want to add something, say an html label, between the two elements, the result gets messed up as described in the related question above.

Another problem is: for the <s:checkbox> item, it is just not possible to add an extra title. For example, this tag

<s:checkbox id="defaultprinter" name="defaultprinter" key="lbl.defaultprinter"/>

is rendered as:

<tr>
    <td valign="top" align="right"></td>
    <td valign="top" align="left">
<input type="checkbox" name="defaultprinter" value="true" checked="checked" id="defaultprinter"/> <label for="defaultprinter" class="checkboxLabel">Default Printer</label> </td>
</tr>

By only setting the attributes of <s:checkbox>, i can't add any text to the first <td> shown above (here it is empty!).

I don't know if the above rigid UI problems can be solved or there is any workarounds somewhere.

Thanks in advance.

+1  A: 

Just switch your theme. The extra (X)HTML tags are generated because of are using (probably) the xhtml theme. If you want to tweak it, you just use the simple theme and write the surrounding tags yourself. You can do that for the full form, or for some individual tags. You can even write your own themes, if you like.

leonbloy
thank you for the info. But is there any slick way to reuse the default theme while i can tune the UI to get the best of both worlds? I don't want to change all my existing pages (there are many such pages) by switching the theme.
jscoot
themes are extensible. http://struts.apache.org/2.0.14/docs/extending-themes.htmlBut in your scenario, if you have used the default (xhtml) theme in many forms and want to make some individual tunings for a few inputs fields, I'd go the standard way: just change the theme (from default to "simple") for those fields.
leonbloy
A: 

try using Display tag or JQuery using both of these framewok can be used to create great (flexible) GUI

VinAy