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

查看:105
本文介绍了在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.

推荐答案

这确实不起作用.在实现内部,您需要 <ui:decorate> .

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天全站免登陆