【问题标题】:Is it possible to use template with composite component in JSF 2?是否可以在 JSF 2 中使用带有复合组件的模板?
【发布时间】:2023-03-08 16:40:01
【问题描述】:
<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 被注释,内容也会被渲染。 所以就像 ui:define 被忽略或者我错过了什么? 谢谢。

【问题讨论】:

    标签: templates jsf-2 composite-component


    【解决方案1】:

    这确实行不通。您需要在实现中使用&lt;ui:decorate&gt;

    <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>
    

    【讨论】:

      猜你喜欢
      • 2013-12-01
      • 1970-01-01
      • 2014-02-21
      • 1970-01-01
      • 2015-08-29
      • 2018-04-25
      • 1970-01-01
      • 1970-01-01
      • 2013-11-10
      相关资源
      最近更新 更多