gpt4 book ai didi

templates - 是否可以在 JSF 2 中使用带有复合组件的模板?

转载 作者:行者123 更新时间:2023-12-02 22:42:24 25 4
gpt4 key购买 nike

<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 被忽略了或者我错过了一些东西吗?谢谢。

最佳答案

这确实行不通。您需要 <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>

关于templates - 是否可以在 JSF 2 中使用带有复合组件的模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9817851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com