This is somehow embarrassing. I'm using Struts2 in a small project of mine. In the JSP, when I put something like this:
<s:select list="keywords" key="label.search" name="selectedKeyword"/>
<s:textfield name="searchparams" size="20" cssClass="label"/>
I get this (sorry, I'm a new user, so I can't add images): http://i.stack.imgur.com/ZA2Wg.png
--dropdown_--
[ ] < textfield
What I want is that the textfield is next to the dropdown, in the same line. Is there a way to do this without creating my own theme?
Thank you in advance!
The Struts2 tags are themed using FreeMarker. You can either change from the default XHTML theme to the simple theme by specifying the following in your struts.properties:
struts.ui.theme=simple
Or you can override the theme for just those tags by adding the theme attribute as follows:
<s:select list="keywords" key="label.search" name="selectedKeyword" theme="simple"/>
<s:textfield name="searchparams" size="20" cssClass="label" theme="simple"/>
Here's some additional information about themes.
Note for struts.properties not preferred:
"It's also possible to define constants in our web.xml file; this is useful when we don't need an XML-based configuration. Either is acceptable: which is used depends on your needs and preferences. We can also define constants in a file named struts.properties, also on the classpath, that this is not preferred." - Apache Struts2 pg 21.
To struts configuration in web.xml:
<filter>
<filter-name>action</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.ui.theme</param-name>
<param-value>simple</param-value>
</init-param>
</filter>
How to set parameter for a whole page:
Maybe not for everyone but personally if I don't want what ever is the default I will want to use another theme for the whole page, so this is convenient.
<s:set var="theme" value="'simple'" scope="page" />
How to set parameter in struts.xml:
Just under the root 'struts' tag you can define constants like so...
<constant name="struts.ui.theme" value="simple" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With