Struts2 comes with three themes: xhtml, simple and css_xhtml. The beginner usually starts using xhmtl theme which is very straightforward. The main disadvantages of xhtml theme is that default functionality puts one textfield in a row.
I was looking for a way to display two textfields in a row. I did the following attempts:
1.I used a simple theme and standard html tags (table, tr, td). The simple theme does not have several features comparing to xhtml (tooltip, validation, required…)
2.I developed a new theme qxhtml according to vitarara tutorial. The biggest disadvantages was designing a form. I missed a standard html functionality how to span table cells, align error messages etc. I had many problems because I was an absolute beginner and I did not know how to modify freemarker ftl templates.
3.I developed my custom extend_simple theme. I copied a simple theme and I did some modifications (support for validation according to annaskawinska.blogspot)
I was very frustrated about my experience with struts2 and I wanted to get advice from others. I posted a question at design-form-real-life-application. And I get the answer from Anbarasu Aladiyan. Thank you Anbarasu, If I would know for your answer I would use my spare time usefully than googling around and be frustrated…
Anbarasu Aladiyan has suggested: IMHO css_xhtml is the much flexible theme to use.
I have also read two books about struts: Struts 2 in Action and Struts 2 Design and Programming but I did not find any detail information about css_xhtml theme. The content at cssxhtml-theme is a little bit misleading about the feature “Standard two-column CSS-based layout”. I mistakenly thought that css_xhtml is almost the same as xhtml.
OK, I decide to test css_xhmtl.
I did two tests. Both tests try to display three textfields each on the separate row. In the fourth row there should be three textfields on the same row.
——————————–
textfield1
textfield2
textfield3
textfield4 textfield5 textfield6
Test1 uses a css_xhtml theme
<s:form action=javanusAction\" theme=\"css_xhtml\">
<s:textfield label="a1" labelposition="left"/>
<s:textfield label="a2" labelposition="left"/>
<s:textfield label="a3" labelposition="left"/>
<table>
<tr>
<td><s:textfield label="a4" labelposition="left"/></td>
<td><s:textfield label="a5" labelposition="left"/></td>
<td><s:textfield label="a6" labelposition="left"/></td>
</tr>
</table>
</s:form>
We can see that also css_xhmtl has the same standard two-columns layout as xhmtl. The important difference is using html tags(table, tr, td). css_xhtml theme takes html tags into account.
Test2 uses a xhtml theme. The code is the same as in test1, the only difference is used theme xhtml.
<s:form action=javanusAction\" theme=\"xhtml\">
<s:textfield label="a1" labelposition="left"/>
<s:textfield label="a2" labelposition="left"/>
<s:textfield label="a3" labelposition="left"/>
<table>
<tr>
<td><s:textfield label="a4" labelposition="left"/></td>
<td><s:textfield label="a5" labelposition="left"/></td>
<td><s:textfield label="a6" labelposition="left"/></td>
</tr>
</table>
</s:form>
Test2 display 6 textfields in a 6 rows.
I would like to thank to Anbarasu Aladiyan ones more and I hope that my post will help future struts2 developers.






