首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Richface 改肌肤两种方法

2012-10-28 
Richface 改皮肤两种方法2008-12-25 18:01第一:rich:togglePanel idskin_chooservalue#{skinBean.sk

Richface 改皮肤两种方法
2008-12-25 18:01

  第一:

<rich:togglePanel id="skin_chooser"
        value="#{skinBean.skinChooserState}" switchType="ajax"
        stateOrder="s,b">
        <f:facet name="s">
         <h:panelGroup>
          <table cellpadding="0" cellspacing="0"
           border="0">
           <tbody>
            <tr>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           BlueSky
           <f:param value="blueSky" name="s" />
              </h:outputLink>
             </td>
             <td>
             <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           Classic
           <f:param value="classic" name="s" />
              </h:outputLink>
             </td>
              <td value="more &#187;" />
             </td>
            </tr>
           </tbody>
          </table>
         </h:panelGroup>
        </f:facet>
        <f:facet name="b">
         <h:panelGroup>
          <table cellpadding="0" cellspacing="0"
           border="0">
           <tbody>
            <tr>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           BlueSky
           <f:param value="blueSky" name="s" />
              </h:outputLink>
             </td>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           Classic
           <f:param value="classic" name="s" />
              </h:outputLink>
             </td>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           Ruby
           <f:param value="ruby" name="s" />
              </h:outputLink>
             </td>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           Wine
           <f:param value="wine" name="s" />
              </h:outputLink>
             </td>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           DeepMarine
           <f:param value="deepMarine" name="s" />
              </h:outputLink>
             </td>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           EmeraldTown
           <f:param value="emeraldTown" name="s" />
              </h:outputLink>
             </td>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           Sakura
           <f:param value="japanCherry" name="s" />
              </h:outputLink>
             </td>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           Plain
           <f:param value="plain" name="s" />
              </h:outputLink>
             </td>
             <td>
              <h:outputLink
               value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           Default
           <f:param value="DEFAULT" name="s" />
              </h:outputLink>
             </td>
             <ui:remove>
              <td>
               <h:outputLink
                value="#{componentNavigator.currentComponent.contextRelativeDemoLocation}">
           Null
           <f:param value="NULL" name="s" />
               </h:outputLink>
              </td>
             </ui:remove>
             <td value="&#171; less" />
             </td>
            </tr>
           </tbody>
          </table>
         </h:panelGroup>
        </f:facet>
       </rich:togglePanel>

后台bean:

private String skin;
private Object skinChooserState;

public String getSkin() {
   String param = getSkinParam();
   if (param!=null) {
    setSkin(param);
   }
   return skin;
}
public void setSkin(String skin) {
   this.skin = skin;
}

private String getSkinParam(){
   FacesContext fc = FacesContext.getCurrentInstance();
   String param = (String) fc.getExternalContext().getRequestParameterMap().get("s");
   if (param!=null && param.trim().length()>0) {
    return param;
   } else {
    return null;
   }
}


public String changeSkin() {
   String param = getSkinParam();
   if (param!=null) {
    setSkin(param);
   }
   return null;
}

public Object getSkinChooserState() {

   return skinChooserState;
 
}
public void setSkinChooserState(Object skinChooserState) {
   this.skinChooserState = skinChooserState;
}


faces-config:

<managed-bean>
<managed-bean-name>skinBean</managed-bean-name>
<managed-bean-class>org.richfaces.samples.SkinBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
   <property-name>skin</property-name>
   <property-class>java.lang.String</property-class>
   <value>blueSky</value>
</managed-property>
</managed-bean>

web.xml

<context-param>
<param-name>org.ajax4jsf.SKIN</param-name>
<param-value>#{skinBean.skin}</param-value>
</context-param>


第二种:

不通过url,通过a4j的参数传递

<h:commandLink value="DeepMarine">
               <a4j:actionparam name="skin" value="deepMarine"
                assignTo="#{skinBean.skin}" />
              </h:commandLink>

热点排行