This is somewhat related to my previous question in which I was able to display an image getting its URL from a properties file in this way:
<img height="40" src="<s:text name="login.logo"/>" class="pagelogo" alt="Logo" /> Login
And using the same way I was able to edit certain style
/ CSS properties:
<h2 class="ccsBlockTitle" style="background-color: <s:text name="welcome.color" />">Welcome<h2>
Where my content.properties
looks like this one:
login.logo=/oneFolderBefore/resources/media/login.png
login.title=Login
welcome.color=red
gui.theme=blitzer
Here's a list of the available themes and how to use them
However when calling it in this way:
<sj:head locale="es" jqueryui="true" jquerytheme="<s:text name="gui.theme"/>" compressed="false" defaultIndicator="ajax_loading" />
I would expect the above code to be "reduced" / "translated" to:
<sj:head locale="es" jqueryui="true" jquerytheme="blitzer" compressed="false" defaultIndicator="ajax_loading" />
However what I'm getting is an error like this one:
java.lang.RuntimeException: org.apache.jasper.JasperException: /WEB-INF/decorators/PlantillaWeb.jsp (line: [37], column: [73]) equal symbol expected
com.opensymphony.sitemesh.webapp.decorator.BaseWebAppDecorator.render(BaseWebAppDecorator.java:39)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:84)
org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:164)
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:191)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:372)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:276)
com.seguritech.botones.plugin.interceptor.ValidarSesionInterceptor.intercept(ValidarSesionInterceptor.java:51)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.CookieProviderInterceptor.intercept(CookieProviderInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.CookieInterceptor.intercept(CookieInterceptor.java:258)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.CookieInterceptor.intercept(CookieInterceptor.java:258)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:575)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
Where line 37 is the above posted and col 73 is between me
in gui.theme
.
So, I thought in changing the inner double quotes for single quotes:
<sj:head locale="es" jqueryui="true" jquerytheme="<s:text name='gui.theme'/>" compressed="false" defaultIndicator="ajax_loading" />
But then when I inspect my HTML I get this:
<link id="jquery_theme_link" rel="stylesheet" href="/my-project/struts/themes/<s:text name='gui.theme'/>/jquery-ui.css?s2j=3.7.1" type="text/css">
And if I change the outer ones like this:
<sj:head locale="es" jqueryui="true" jquerytheme='<s:text name="gui.theme"/>' compressed="false" defaultIndicator="ajax_loading" />
I get this:
<link id="jquery_theme_link" rel="stylesheet" href="/my-project/struts/themes/<s:text name=" gui.theme"="">
I also tried changing the value for jquerytheme
for ${gui.theme}
but I got the same error as in my previous question which says:
According to TLD or attribute directive in tag file, attribute value does not accept any expressions
So, what could be another way for changing the jquerytheme
property value retrieving it from my content.properties
file?
In the cases above except the first one (using double double-quotes) I was getting the default base
theme.
I ended leaving this line as is:
<sj:head locale="es" jqueryui="true" jquerytheme="base" compressed="false" defaultIndicator="ajax_loading" />
Later on I thought in "concatenating" strings after reading this blog: JQuery UI: Change theme dynamically using a drop-down where they have the following code:
<head>
<link id="stylesheet" rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/le-frog/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
...
<select id="themes">
<option value="http://code.jquery.com/ui/1.10.4/themes/le-frog/jquery-ui.css">Le Frog</option>
<option value="http://code.jquery.com/ui/1.10.4/themes/start/jquery-ui.css">Start</option>
<option value="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">Smoothness</option>
<option value="http://code.jquery.com/ui/1.10.4/themes/redmond/jquery-ui.css">Redmond</option>
<option value="http://code.jquery.com/ui/1.10.4/themes/sunny/jquery-ui.css">Sunny</option>
</select>
...
That gave me the idea of having this line after the one I posted before:
<link id="stylesheet" rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/le-frog/jquery-ui.css">
divided in 3 parts in my content.properties
file like this:
gui.current.theme=south-street
gui.theme.url.part1=//code.jquery.com/ui/1.10.4/themes/
gui.theme.url.part2=/jquery-ui.css
And the above line divided like this:
<link id="stylesheet" rel="stylesheet" href="<s:text name="gui.theme.url.part1" /><s:text name="gui.current.theme" /><s:text name="gui.theme.url.part2" />" />
With these changes I was able to do what I wanted and now my theme changes its CSS styles according to whatever theme (included in the ThemeRoller page) I write in the gui.current.theme
property.