How to put <s: select ...> and <s: textfield> on the same line - struts2?
It's kind of awkward. I use Struts2 in my small project. In JSP, when I add 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 am a new user, so I can not add images): http://i.stack.imgur.com/ZA2Wg.png
--dropdown_-- [ ] < textfield I want the text box to be next to the drop-down list on the same line. Is there a way to do this without creating my own theme?
Thank you in advance!
Struts2 tags are thematically used with FreeMarker. You can either go from the default XHTML theme to a simple theme by specifying the following in your struts.properties:
struts.ui.theme=simple Or you can override the theme for these tags only by adding a 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 is more information on topics .
Note for struts.properties not recommended :
"It is also possible to define constants in our web.xml file, this is useful when we do not need an XML-based configuration. Or acceptable: it is used depending on your needs and preferences. We can also define constants in a file called struts.properties, also on the way to classes, which is not preferred. " - Apache Struts2 p. 21.
To position the 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 the parameter for the whole page :
Maybe not for everyone, but personally, if I donโt want what will ever be the default, I want to use a different theme for the whole page, so it's convenient.
<s:set var="theme" value="'simple'" scope="page" /> How to set a parameter in struts.xml :
Just under the root tag "struts" you can define constants like this ...
<constant name="struts.ui.theme" value="simple" />