2 Replies Latest reply on Jan 22, 2009 6:21 PM by mechtatel

    Switch runtime skins problems

    mechtatel

      I created a new Plug-in skin using maven. After that I successful implement it and work very nice. So I decide to add skinability on runtime, switching skins on the fly, but I have a problem with rendering the styles. This is my code:

      <a4j:outputPanel id="panelToolBar">
       <a4j:form>
       <rich:toolBar id="bar" height="30" itemSeparator="line">
       <rich:toolBarGroup location="right" itemSeparator="line">
       <h:outputText value="skins" />
       <a4j:commandLink value="default" action="#{skin.setExplore}" reRender="panelToolBar" />
       <a4j:commandLink value="classic" action="#{skin.setClassic}" reRender="panelToolBar" />
       <a4j:commandLink value="blueSky" action="#{skin.setBlueSky}" reRender="panelToolBar" />
       </rich:toolBarGroup>
       </rich:toolBar>
       </a4j:form>
       </a4j:outputPanel>
      


      and this is what I have in web.

      <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>#{skin.actual}</param-value>
       </context-param>
      
      
       <context-param>
       <param-name>org.richfaces.CONTROL_SKINNING</param-name>
       <param-value>enable</param-value>
       </context-param>


      and this is my session bean:

      public class Skin {
      
       private String actual;
      
       public String getActual() {
       return actual;
       }
      
       public void setActual(String actual) {
       this.actual = actual;
       }
      
       public String setExplore() {
       setActual("explore");
       return "null";
       }
      
       public String setClassic() {
       setActual("classic");
       return "null";
       }
      
       public String setBlueSky() {
       setActual("blueSky");
       return "null";
       }
      
      }
      


      The first time when I click on a skin link, renders properly, but when I click on some skin that was applied doesn't change the skin. Maybe is nor rendering properly the styles.
      I try window.location.reload() using oncomplete. That is working in Firefox but not in IE7.


        • 1. Re: Switch runtime skins problems

          The skin is belong to the whole page. You are trying to update the part of the page (Ajax with a4j:commandLink). The styles that are loaded already and located in the header of the page are still there and belong to the skin which was set when the page is fully loaded. The result might be unpredictable (depends of the browser)

          Replace a4j:commandLink with h:commandLink to have the whole page reload.

          • 2. Re: Switch runtime skins problems
            mechtatel

            Good point. Now is working. Thank you Sergey