是否可以在 JSF 2 中使用带有复合组件的模板? [英] Is it possible to use template with composite component in JSF 2?

查看:22
本文介绍了是否可以在 JSF 2 中使用带有复合组件的模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<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 被忽略了或者我错过了什么?谢谢.

The problem is that even the ui:define is commented the content is rendered. So it is like the ui:define is ignored or Am I missing some thing ? Thanks.

推荐答案

这确实行不通.您需要 在实现中.

This will indeed not work. You need <ui:decorate> inside the implementation instead.

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

这篇关于是否可以在 JSF 2 中使用带有复合组件的模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆