2012-03-22 48 views
4
<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
    ... 
    template="inputLayout.xhtml"> 

    <composite:interface> 
     <composite:attribute name="name" /> 
     <composite:attribute name="value" /> 
    </composite:interface> 

    <composite:implementation> 
     <!-- <ui:define name="content"> --> 
      <h:message for="textPanel" style="color:red;" /> 
      #{cc.attrs.name} : 
      <h:inputText id="name" value="#{cc.attrs.value}" /> 
     <!-- <ui:define> --> 
    </composite:implementation> 
</ui:composition> 

问题是,即使ui:define被评论为内容呈现。 所以这就像用户界面:定义被忽略或我缺少一些东西? 谢谢。是否有可能在JSF 2中使用复合组件的模板?

回答

6

这确实不行。相反,您需要在执行内部使用<ui:decorate>

<ui:component 
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:cc="http://java.sun.com/jsf/composite" 
> 
    <cc:interface> 
     ... 
    </cc:interface> 
    <cc:implementation> 
     <ui:decorate template="/WEB-INF/inputLayout.xhtml"> 
      <ui:define name="content"> 
       ... 
      </ui:define> 
     </ui:decorate> 
    </cc:implementation> 
</ui:component> 
+0

thanks @BalusC。我不知道 kycdev 2012-03-22 11:15:12

相关问题