Have you looked at upgrading to CAS v3.4? It already contains a mobile
theme, for example.
Andy
On Tue, 10 Apr 2012, Aaron Chantrill wrote:
Looks like I misunderstood what themes are doing in CAS. As I understand it
now, the "/WEB-INF/view/jsp/default" directory has nothing to do with the
"default" theme. When you create a new theme, all you have to do is create a
new <theme_name>.properties file inside the /WEB-INF/classes directory. Then
you put name/value pairs in there like "foo=bar". Then you modify the
template at /WEB-INF/view/jsp/mobile/ui/casLoginView.jsp (for example) and
put <spring:theme code="foo"/> in, and this will be replaced with the word
"bar" in the HTML output (you must also create a "default.properties" file at
the same time also with a "foo" defined in it, or you get an error when
someone tries to request a page with the default theme).
Now, I have two very different styles of web pages depending on the usage,
but most of the changes are separated out into a header file and a footer
file that are currently included via a jsp:directive.include statement. So if
I could do something like <jsp:directive.include file=<spring:theme
code="template_top" /> /> I would be back in business, but it does not look
like you can embed the theme substitutions in other jsp directives. It also
does not look like I can embed the jsp directive in the .properties files.
I could embed the entire text of the header and footer into the .properties
files, but that's going to be a long and messy bunch of html, css and
javascript.
Does anyone know of a way to do an if/then statement around the value of a
<spring:theme> variable? The differences between the themed pages I would
like to deploy are a lot more complicated than changing a single CSS include.
Thanks,
Aaron
On 04/10/2012 03:51 PM, Aaron Chantrill wrote:
I'm using CAS 3.3.1 and trying to use two different themes depending on
which website is being passed in as "service". If the user is coming from
our test server, the pages should be rendered using the "default" theme,
but if they come from our "m" server, they should get a sign-in page that
is optimized for viewing on a smartphone.
So far, I have
copied the WEB-INF/view/jsp/default directory to
WEB-INF/view/jsp/mobile.
made some changes to the WEB-INF/view/jsp/mobile/ui/casLoginView.jsp so
I can tell which theme I am using.
copied the WEB-INF/classes/default_views.properties file to
WEB-INF/classes/mobile.properties and
WEB-INF/classes/mobile_views.properties (the instructions at
https://wiki.jasig.org/display/CASUM/Theme+Control say to "Add another set
of theme properties file, which must be placed to the root of
/WEB-INF/classes folder, name it as theme_name.properties" but there was no
"default.properties" file in that location, only a
"default_views.properties" file, so I created both.
changed the links in these two files to point to the "mobile" directory
instead of the "default" directory.
updated cas-servlet.xml file to add "servicesManager-ref"
<bean id="themeResolver"
class="org.jasig.cas.services.web.ServiceThemeResolver"
p:defaultThemeName="${cas.themeResolver.defaultThemeName}"
p:servicesManager-ref="servicesManager"
p:argumentExtractors-ref="argumentExtractors" />
changed the theme for my "m" server to "mobile" in
deployerConfigContext.xml:
<bean id="serviceRegistryDao"
class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl">
<property name="registeredServices">
<list>
<bean class="org.jasig.cas.services.RegisteredServiceImpl">
<property name="id" value="0" />
<property name="name" value="m.wvsom.edu" />
<property name="description" value="Allows access via m.wvsom.edu and uses
a non-standard mobile-friendly theme" />
<property name="serviceId" value="http://m.wvsom.edu/**" />
<property name="evaluationOrder" value="10000001" />
<property name="theme" value="mobile" />
<property name="allowedAttributes">
<list>
<value>UDC_IDENTIFIER</value>
</list>
</property>
</bean>
<bean class="org.jasig.cas.services.RegisteredServiceImpl">
<property name="id" value="1" />
<property name="name" value="WVSOM test" />
<property name="description" value="Allows WVSOM Test Server" />
<property name="serviceId" value="http://test.wvsom.edu/**" />
<property name="evaluationOrder" value="10000002" />
<property name="allowedAttributes">
<list>
<value>UDC_IDENTIFIER</value>
</list>
</property>
</bean>
Restarted Tomcat, and the default theme continues to come up.
If I edit WEB-INF/cas.properties and change
cas.themeResolver.defaultThemeName=default
cas.viewResolver.basename=default_views
to
cas.themeResolver.defaultThemeName=mobile
cas.viewResolver.basename=mobile_views
then the new mobile theme comes up for everything.
So it seems like the theme is working, but it's either not reading the
theme information from the serviceRegistry, or not getting the basename
from it. Something's not linking up. I also have all the logs set to DEBUG
and the only time the word "mobile" appears in the logs is when I set
mobile to be the default theme and it rendered correctly. So it does not
seem like CAS is even aware that I am trying to get it to display an
alternate theme.
Any help greatly appreciated,
Aaron
--
You are currently subscribed to [email protected] as: [email protected]
To unsubscribe, change settings or access archives, see
http://www.ja-sig.org/wiki/display/JSG/cas-user
--
You are currently subscribed to [email protected] as:
[email protected]
To unsubscribe, change settings or access archives, see
http://www.ja-sig.org/wiki/display/JSG/cas-user