0 Replies Latest reply on Aug 28, 2007 5:24 PM by Marcin Misiewicz

    Problem with seam theme-selector and skins

    Marcin Misiewicz Newbie

      Hello,

      In my application I want to change the skin of richfaces using seam theme-selector. I have provided two themes default and modern, default theme uses blueSky skin and modern uses ruby.

      Snippet from components.xml

      <theme:theme-selector cookie-enabled="true">
       <theme:available-themes>
       <value>default</value>
       <value>modern</value>
       </theme:available-themes>
      </theme:theme-selector>
      <web:ajax4jsf-filter enable-cache="false"/>


      In default.properties I have the following line
      skin blueSky


      In modern.properties I have the following line
      skin ruby


      Here is my web.xml
      <context-param>
       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
       <param-value>com.sun.facelets.FaceletViewHandler</param-value>
      </context-param>
      <context-param>
       <param-name>org.ajax4jsf.SKIN</param-name>
       <param-value>#{theme.skin}</param-value>
      </context-param>
      <context-param>
       <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
       <param-value>false</param-value>
      </context-param>
      <!-- Facelets -->
      <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
      </context-param>
      <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
      </context-param>
      <context-param>
       <param-name>facelets.REFRESH_PERIOD</param-name>
       <param-value>2</param-value>
      </context-param>
      <context-param>
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>true</param-value>
      </context-param>
      <context-param>
       <param-name>com.sun.faces.verifyObjects</param-name>
       <param-value>true</param-value>
      </context-param>
      
      <listener>
       <listener-class>
       org.jboss.seam.servlet.SeamListener
       </listener-class>
      </listener>
      <filter>
       <filter-name>Seam Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
      </filter>
      <filter-mapping>
       <filter-name>Seam Filter</filter-name>
       <url-pattern>/*</url-pattern>
      </filter-mapping>
      
      <servlet>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <servlet-class>
       org.jboss.seam.servlet.ResourceServlet
       </servlet-class>
      </servlet>
      <servlet-mapping>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <url-pattern>/seam/resource/*</url-pattern>
      </servlet-mapping>
      
      <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.seam</url-pattern>
      </servlet-mapping>


      Unfortunately during every request I get following error :
      22:27:26,140 ERROR [[default]] Servlet.service() for servlet default threw exception
      org.ajax4jsf.framework.skin.SkinNotFoundException: Name for current Skin calculated as null
       at org.ajax4jsf.framework.skin.SkinFactoryImpl.getSkin(SkinFactoryImpl.java:92)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase$4.getValue(ElementBase.java:302)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase$ValueGetter.getStringOrDefault(ElementBase.java:426)
       at org.ajax4jsf.framework.renderer.compiler.ClassElement.getString(ClassElement.java:87)
       at org.ajax4jsf.framework.renderer.compiler.ClassElement.encode(ClassElement.java:59)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase.encode(ElementBase.java:104)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase.encode(ElementBase.java:104)
       at org.ajax4jsf.framework.renderer.compiler.RootElement.encode(RootElement.java:64)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase.encode(ElementBase.java:72)
       at org.ajax4jsf.framework.resource.TemplateCSSRenderer.send(TemplateCSSRenderer.java:79)
       at org.ajax4jsf.framework.resource.InternetResourceBase.send(InternetResourceBase.java:369)
       at org.ajax4jsf.framework.resource.ResourceLifecycle.send(ResourceLifecycle.java:86)
       at org.ajax4jsf.framework.resource.InternetResourceService.sendResource(InternetResourceService.java:256)
       at org.ajax4jsf.framework.resource.InternetResourceService.serviceResource(InternetResourceService.java:240)
       at org.ajax4jsf.framework.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:261)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Unknown Source)
      22:27:26,171 ERROR [[default]] Servlet.service() for servlet default threw exception
      org.ajax4jsf.framework.skin.SkinNotFoundException: Name for current Skin calculated as null
       at org.ajax4jsf.framework.skin.SkinFactoryImpl.getSkin(SkinFactoryImpl.java:92)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase$4.getValue(ElementBase.java:302)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase$ValueGetter.getStringOrDefault(ElementBase.java:426)
       at org.ajax4jsf.framework.renderer.compiler.ClassElement.getString(ClassElement.java:87)
       at org.ajax4jsf.framework.renderer.compiler.ClassElement.encode(ClassElement.java:59)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase.encode(ElementBase.java:104)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase.encode(ElementBase.java:104)
       at org.ajax4jsf.framework.renderer.compiler.RootElement.encode(RootElement.java:64)
       at org.ajax4jsf.framework.renderer.compiler.ElementBase.encode(ElementBase.java:72)
       at org.ajax4jsf.framework.resource.TemplateCSSRenderer.send(TemplateCSSRenderer.java:79)
       at org.ajax4jsf.framework.resource.InternetResourceBase.send(InternetResourceBase.java:369)
       at org.ajax4jsf.framework.resource.ResourceLifecycle.send(ResourceLifecycle.java:86)
       at org.ajax4jsf.framework.resource.InternetResourceService.sendResource(InternetResourceService.java:256)
       at org.ajax4jsf.framework.resource.InternetResourceService.serviceResource(InternetResourceService.java:240)
       at org.ajax4jsf.framework.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:261)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Unknown Source)


      Of course page looks like plain html without any styling attached to it.
      It looks like ajax4jsf can't resolve el #{theme.skin} to "blueSky" or "ruby" it resolvses this el to string "default" I guess.
      This line suggest this
      22:27:26,140 ERROR [[default]] Servlet.service() for servlet default threw exception
      org.ajax4jsf.framework.skin.SkinNotFoundException: Name for current Skin calculated as null


      Ajax4jsf filter is configured in the components.xml but it also doesn't work when I configure it in web.xml.

      What am I doing wrong ? Do I have to write my own managed bean which holds selected skin name ?
      Can't I just use theme seam component to select proper skin.
      When my web.xml looks like :
      <context-param>
       <param-name>org.ajax4jsf.SKIN</param-name>
       <param-value>blueSky</param-value>
      </context-param>

      everything works fine even skinning non richfaces components through the xcss. Here is code snippet from sample page :
      <a4j:loadStyle src="resource://#{themePath}/#{theme.cssSkinMapper}" />


      What am I doing wrong ?

      Best regards !
      Marcin Misiewicz