1 Reply Latest reply on Mar 12, 2009 11:50 AM by Alexander Smirnov

    Changing skin in runtime is broken in portlet mode?

    Axel Motyka Newbie

      Hi,

      i am using
      portletbridge-1.0.0.B6.jar
      richfaces-3.3.0.GA.jar
      JBoss Portal 2.7.1


      I've tried to follow 5.10.7. Changing skin in runtime from the documentation, but it doesnt seem to work. I updated my portlet application with all of the settings of the documentation It's a little bit strange.
      When selecting a new skin, my logs show me that the skin was changed but then something happend and the value of my bean is reseted to it's default (i used classic). I dont know why - and i cant find an error message.
      11:47:13,625 INFO [LogbookInterface] getSkin()=ruby
      11:47:13,625 INFO [LogbookInterface] getSkin()=ruby
      11:47:15,046 INFO [LogbookInterface] getSkin()=classic
      11:47:15,046 INFO [LogbookInterface] getSkin()=classic

      Could it be a bug in one of the libs, or maybe i have the wrong configuration?

      This is my web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app id="WebApp_ID" version="2.5"
       xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
       <display-name>jsfDemoPortlet</display-name>
       <context-param>
       <description>Is a comma-separated list of custom ViewHandler instances for inserting in chain. Handlers are inserted BEFORE RichFaces viewhandlers in the given order.
      
       For example, in facelets application this parameter must contain com.sun.facelets.FaceletViewHandler,
      
      instead of declaration in faces-config.xml</description>
       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
       <param-value>org.jboss.portletbridge.application.FaceletPortletViewHandler</param-value>
       </context-param>
       <context-param>
       <description>It doesn't allow framework to reformat JavaScript files (makes it impossible to debug)</description>
       <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
       <param-value>FALSE</param-value>
       </context-param>
       <context-param>
       <description>Defines how the RichFaces script files are loaded to application.
      Possible values are: ALL, DEFAULT, NONE. For more information see "Scripts and Styles Load Strategy".</description>
       <param-name>org.richfaces.LoadScriptStrategy</param-name>
       <param-value>DEFAULT</param-value>
       </context-param>
       <context-param>
       <description>Defines how the RichFaces style files are loaded to application. Possible values are: ALL, DEFAULT, NONE. For more information see "Scripts and Styles Load Strategy".</description>
       <param-name>org.richfaces.LoadStyleStrategy</param-name>
       <param-value>DEFAULT</param-value>
       </context-param>
       <context-param>
       <param-name>org.ajax4jsf.SKIN</param-name>
       <param-value> #{skinBean.skin}</param-value>
       </context-param>
       <context-param>
       <param-name>org.richfaces.CONTROL_SKINNING</param-name>
       <param-value>enable</param-value>
      </context-param>
      <context-param>
       <param-name>javax.portlet.faces.renderPolicy</param-name>
       <param-value>ALWAYS_DELEGATE</param-value>
       <!-- <param-value>NEVER_DELEGATE</param-value> -->
       </context-param>
       <context-param>
       <description>Defines prefix which is added to all URIs of generated resources. This prefix designed to handle RichFaces generated resources requests</description>
       <param-name>org.ajax4jsf.RESOURCE_URI_PREFIX</param-name>
       <param-value>rfRes</param-value>
       </context-param>
       <context-param>
       <description>For generated resources, such as encrypt generation data, it's encoded in the resource URL. For example, URL for an image generated from the mediaOutput component contains a name of a generation method, since for a hacker attack, it is possible to create a request for any JSF baked beans or other attributes. To prevent such attacks, set this parameter to "true" in critical applications (works with JRE > 1.4 )</description>
       <param-name>org.ajax4jsf.ENCRYPT_RESOURCE_DATA</param-name>
       <param-value>FALSE</param-value>
       </context-param>
       <context-param>
       <description>Is an URL to an application or a container log file (if possible). If this parameter is set, content from the given URL is shown on a Debug error page in the iframe window</description>
       <param-name>org.ajax4jsf.LOGFILE</param-name>
       <param-value>none</param-value>
       </context-param>
       <context-param>
       <description>Defines in seconds how long streamed back to browser resources can be cached </description>
       <param-name>org.ajax4jsf.DEFAULT_EXPIRE</param-name>
       <param-value>0</param-value>
       </context-param>
       <context-param>
       <description>If enabled the component state (not the tree) will be serialized before being stored in the session. This may be desirable for applications that may have issues with view state being sensitive to model changes. Instead of this parameter can use com.sun.faces.serializeServerState and org.apache.myfaces.SERIALIZE_STATE_IN_SESSION parameters for corresponding environments. </description>
       <param-name>org.ajax4jsf.SERIALIZE_SERVER_STATE</param-name>
       <param-value>FALSE</param-value>
       </context-param>
       <filter>
       <description></description>
       <display-name>Ajax4jsf Filter</display-name>
       <filter-name>ajax4jsf</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       <init-param>
       <description>Enable caching of framework-generated resources (JavaScript, CSS, images, etc.). For debug purposes development custom JavaScript or Style prevents to use old cached data in a browser</description>
       <param-name>enable-cache</param-name>
       <param-value>TRUE</param-value>
       </init-param>
       </filter>
       <filter-mapping>
       <filter-name>ajax4jsf</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-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>
       <welcome-file-list>
       <welcome-file>index.html</welcome-file>
       <welcome-file>index.htm</welcome-file>
       <welcome-file>index.jsp</welcome-file>
       <welcome-file>default.html</welcome-file>
       <welcome-file>default.htm</welcome-file>
       <welcome-file>default.jsp</welcome-file>
       </welcome-file-list>
       <login-config>
       <auth-method>BASIC</auth-method>
       </login-config>
      </web-app>
      


        • 1. Re: Changing skin in runtime is broken in portlet mode?
          Alexander Smirnov Master

          According to the portlet specification, there are different sessions for portlet and servlet requests. Probably, you change skin bean property in the portlet session, but stylesheet generated from the instance stored in the servlet session scope.
          You can propagate skin bean into servlet session using direct reference to the PortletSession object from ExternalContext and 'APPLICATION_SCOPE' attributes.