primefaces 带参数的组件

分析了一下primefaces extension showcase的源码,总结一下组件传参的方式。

下面定义了一个组件,名为fourTabsDecoratorCustom.xhtml

   1: <html xmlns="http://www.w3.org/1999/xhtml"
   2:       xmlns:h="http://xmlns.jcp.org/jsf/html"
   3:       xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   4:       xmlns:p="http://primefaces.org/ui">
   5: <ui:composition>
   6:     <h:panelGroup layout="block" styleClass="source">
   7:         Source
   8:     </h:panelGroup>
   9:     <p:tabView id="sourceTabView">
  10:         <p:tab title="XHTML page">
  11:             <pre name="code" class="xml"><ui:insert name="contentTab1"/></pre>
  12:         </p:tab>
  13:         <p:tab title="Managed bean">
  14:             <pre name="code" class="java"><ui:insert name="contentTab2"/></pre>
  15:         </p:tab>
  16:         <p:tab title="Model class">
  17:             <pre name="code" class="java"><ui:insert name="contentTab3"/></pre>
  18:         </p:tab>
  19:         <p:tab title="#{customTitle}">
  20:             <pre name="code" class="#{customCode}"><ui:insert name="contentTab4"/></pre>
  21:         </p:tab>
  22:     </p:tabView>
  23: </ui:composition>

使用组件

   1: <ui:decorate template="/templates/fourTabsDecoratorCustom.xhtml">
   2:            <ui:param name="customTitle" value="ClearInputsExecutor"/>
   3:            <ui:param name="customCode" value="java"/>
   4:            <ui:define name="contentTab1">
   5: {showcase:getFileContent('/sections/dynaform/example-visitCallback.xhtml')}
   6:            </ui:define>
   7:            <ui:define name="contentTab2">
   8: {showcase:getFileContent('/org/primefaces/extensions/showcase/controller/dynaform/ClearDynaFormController.java')}
   9:            </ui:define>
  10:            <ui:define name="contentTab3">
  11: {showcase:getFileContent('/org/primefaces/extensions/showcase/model/dynaform/Condition.java')}
  12:            </ui:define>
  13:            <ui:define name="contentTab4">
  14: {showcase:getFileContent('/org/primefaces/extensions/showcase/controller/dynaform/ClearInputsExecutor.java')}
  15:            </ui:define>
  16:        </ui:decorate>

你可能感兴趣的:(primefaces)