Announcement Announcement Module
Collapse
No announcement yet.
Spring hooking themes properties file to css file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring hooking themes properties file to css file

    this is how I intialize theme beans:
    Code:
    	<bean id="themeSource"
        class="org.springframework.ui.context.support.ResourceBundleThemeSource">
            <property name="basenamePrefix" value="resources.theme-" />
    	</bean>
    	 
    	<bean id="themeChangeInterceptor"
    	    class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">
    	    <property name="paramName" value="theme" />
    	</bean>
    	
    	<bean id="themeResolver"
    	    class="org.springframework.web.servlet.theme.CookieThemeResolver">
    	    <property name="defaultThemeName" value="default" />
    	</bean>
    	
    		<bean id="handlerMapping"
    	    class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    	    <property name="interceptors">
    	    	<list>
    		        <ref bean="localeChangeInterceptor" />
    	            <ref bean="themeChangeInterceptor" />
                </list>
    	    </property>
    	</bean>

    this is my folder stucture:

    http://i.stack.imgur.com/3DC2q.png


    these are the inside of my 3 properties files:
    Code:
        css=themes/black.css
        css=themes/blue.css
        css=themes/default.css
    I have also tried these:
    1. css=classpath:themes/default.css
    2. css=/themes/default.css
    3. css=./themes/default.css

    Should the css even be in WEB-INF/classes. I've tried moving it out and in etc, but never quite seemed to get it to work.


    Here is how I put it in my JSP:
    Code:
        <link rel="stylesheet" href="<spring:theme code='css'/>" type="text/css" />
    This is now my output looks like:

    http://i.stack.imgur.com/WN90L.png


    This is part of JSP:
    Code:
        <span style="float: left">
        <a href="?theme=default">def</a>
        |
        <a href="?theme=black">blk</a>
        |
        <a href="?theme=blue">blu</a>
        </span>
    This is my black.css.

    Code:
    	body {
    	    background-color: #888;
    	    color: white;
    	}
    My problem is, that the css never seems to go on my JSP file. This is probably caused because properties file can not find css file...
    Feel free to ask further info.

  • #2
    I thas nothing to do with the fact that your properties file cannot find the css it has to do with the fact that your BROWSER cannot find the css files...

    Either move the files to the root of your web app in a the paths as configured (thus themes) or create a resource mapping for /themes to the root of your class path (for the latter I suggest a read of the reference guide).

    Comment


    • #3
      at the moment, I moved resources to my root folder, but in your opinion, which would be the best solution for this? well you gave me 2 ideas, which would be best out of those two..
      Last edited by Charmees; Aug 16th, 2011, 05:21 AM.

      Comment


      • #4
        Both work and both expose the css files to the user... Simply putting the resources in the root is the easiest imho and thus the best... But all IMHO of course...

        Comment

        Working...
        X