<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">When you use a Struts 2 tag such as s:select in your web page, the Struts 2 framework generates HTML that styles the appearance and controls the layout of the select control. The style and layout is determined by which Struts 2 theme is set for the tag. Struts 2 comes with three built-in themes: simple, xhtml, and css_xhtml. If you don’t specify a theme, then Struts 2 will use the xhtml theme by default.</p>
<p> Thus in our case, Struts 2 automatically rendered the controls using default xhtml theme.<br />
<b><br />
 Specifying The Theme in Struts 2</b><br />
The Struts 2 tags have a theme attribute you can use to specify which Struts 2 theme should be used when creating the HTML for that tag. The values for the theme attribute are simple, xhtml, css_xhtml, and ajax.</p>
<p> You can specify the theme on a per Struts 2 tag basis or you can use one of the following methods to specify what theme Struts 2 should use:</p>
<ul style="text-align: left;">
<li>The theme attribute on the specific tag</li>
<li>The theme attribute on a tag’s surrounding form tag</li>
<li>The page-scoped attribute named “theme”</li>
<li>The request-scoped attribute named “theme”</li>
<li>The session-scoped attribute named “theme”</li>
<li>The application-scoped attribute named “theme”</li>
<li>The struts.ui.theme property in struts.properties (defaults to xhtml)</li>
</ul>
<div align='center' id="ads-id"></div>
<p>Thus, you can specify what theme you want to use at any level. Tag level, enclosed tag lever, form level, page level or at application level.</p>
<p> I preferred specifying theme at the application level. To override the default scheme you can create (or update existing) <b>struts.xml </b>file in your project.</p>
<p>Create <b>struts.xml</b> file and add following line into it:</p>
<pre class="highlight" name="code"><;constant name="struts.ui.theme" value="css_xhtml" />;
<;constant name="struts.ui.templateDir" value="template" />;
</pre>
<p>
So if you want to take full control for your user interface and want to align all controls yourself, I would suggest you to use css_xhtml theme instead of default xhtml.</p>
<p> The theme for above JSP code when changed into css_xhtml would generate following HTML code.</p></div>
<pre class="highlight" name="code"><;%@ page contentType="text/html; charset=UTF-8"%>;
<;%@ taglib prefix="s" uri="/struts-tags"%>;
<;html>;
<;head>;
<;title>;<;s:property value="getText('global.form')" />; - Struts2 Demo | dineshonjava.com<;/title>;
<;s:head />;
<;/head>;
 
<;body>;
<;h2>;<;s:property value="getText('global.form')" />;<;/h2>;
 
<;s:form action="employee" method="post" validate="true" theme="css_xhtml">;
 <;s:textfield name="name" key="global.name" size="20" theme="css_xhtml"/>;
 <;s:textfield name="age" key="global.age" size="20" theme="css_xhtml"/>;
 <;s:textfield name="email" key="global.email" size="20" theme="css_xhtml"/>;
 <;s:textfield name="telephone" key="global.telephone" size="20" theme="css_xhtml"/>;
 <;s:submit name="submit" key="global.submit" align="center" theme="css_xhtml"/>;
<;/s:form>;

<;s:url id="localeEN" namespace="/" action="locale" >;
 <;s:param name="request_locale" >;en<;/s:param>;
<;/s:url>;
<;s:url id="localeHN" namespace="/" action="locale" >;
 <;s:param name="request_locale" >;hn<;/s:param>;
<;/s:url>;
<;s:url id="localeES" namespace="/" action="locale" >;
 <;s:param name="request_locale" >;es<;/s:param>;
<;/s:url>;
<;s:url id="localezhCN" namespace="/" action="locale" >;
 <;s:param name="request_locale" >;zh_CN<;/s:param>;
<;/s:url>;
<;s:url id="localeDE" namespace="/" action="locale" >;
 <;s:param name="request_locale" >;de<;/s:param>;
<;/s:url>;
<;s:url id="localeFR" namespace="/" action="locale" >;
 <;s:param name="request_locale" >;fr<;/s:param>;
<;/s:url>;
 
<;s:a href="%{localeEN}" >;English<;/s:a>;
<;s:a href="%{localeHN}" >;Hindi<;/s:a>;
<;s:a href="%{localeES}" >;Spanish<;/s:a>;
<;s:a href="%{localezhCN}" >;Chinese<;/s:a>;
<;s:a href="%{localeDE}" >;German<;/s:a>;
<;s:a href="%{localeFR}" >;France<;/s:a>;
<;/body>;
<;/html>;
</pre>
</div>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/2013/08/localization-i18n-in-struts2.html">Previous</a> <;<; ; ; || <a href="https://dineshonjava.com/2013/07/struts-2-baby-step-to-learn.html">Index </a>||  ; >;>;<a href="https://dineshonjava.com/2013/08/struts-2-exception-handling.html">Next</a> >;>;</b></div>
<p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/localization-i18n-in-struts2/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/struts-2-exception-handling/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '380'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…