Ryan has been working with web technologies since 2004 and is a lover all all things design, especially jQuery and HTML. Big fan of open source. Preferred Languages - Javascript/Java, Preferred Framework-jQuery, Preferred Design Tools - GIMP/Inkscape. Ryan has posted 40 posts at DZone. You can read more from them at their website. View Full User Profile

Simple theming in Struts 2

06.13.2011
| 4938 views |
  • submit to reddit
I was just designing a page in struts. I had already designed the structure of the page using a text editor and also setup the necessary css and javascript for the layout.
But when I introduced a struts tag into the page by replacing the elements with struts tag, somehow the entire layout turned into a huge mess.
Reason? My page contained a form, and struts automatically applies a theme to the form that causes the elements to be rendered in the form of tables. I was like, WTF! When i saw my perfectly looking page utterly distorted coz of no mistake of my own.
If you are facing the same issue, you can simply resolve it by using the simple theme instead of whatever theme struts is using.
In my case, I did the following in my struts form.
<s:form action="my_action" theme="simple">
</s:form>

Yea, that works. Piece of cake. I guess there should be a way to default the theme for the entire project instead of doing it one form at a time, especially since I like to do the styling of the web pages by myslef. Will have to check that.

From http://mycodefixes.blogspot.com/2011/06/simple-theming-in-struts.html

Published at DZone with permission of its author, Ryan Sukale.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Will Hall replied on Tue, 2011/06/14 - 8:18am

Setting this globally is easy.  You can set it in your struts.xml like this:

 <constant name="struts.ui.theme" value="simple"/>

 

Ryan Sukale replied on Tue, 2011/06/14 - 1:07pm

Cool!. Thanks for that Will.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.