如何在JSF 2.0中将节点值作为属性传递给Composite Component [英] How to pass the node value as the attribute in Composite Component in JSF 2.0

查看:74
本文介绍了如何在JSF 2.0中将节点值作为属性传递给Composite Component的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发JSF 2.0复合组件.我正在尝试创建一个框组件,将所需的HTML设置为该框组件.

I am developing a JSF 2.0 composite component. I am trying to create a box component to which my required HTML will be set as attribute.

有些像..

<composite:interface>
    <composite:attribute name="value" />
</composite:interface>
<composite:implementation>
    <table cellpadding="0" cellspacing="0" border="1" width="100%">
        <tr>
            <td></td>
            <td>#{cc.attrs.value}</td>
            <td></td>
        </tr>
    </table>
</composite:implementation>

当我要使用此组件并将所需的HTML传递给属性值"时,如下所示:

When I want to use this component and pass the required HTML to the attribute "value", like so:

<someDir:boxComp>Hello</someDir:boxComp>

"Hello"不被视为属性值. 我如何将节点值作为属性值??

the "Hello" is not taken as attribute value. How i can make the node value as an attribute value.?

推荐答案

您没有将其作为标记属性传递.您只是在标签正文中将其作为子项传递.在这种情况下,您需要使用 插入它.因此,代替

You aren't passing it as tag attribute. You are just passing it as child in the tag body. In that case you need to use <composite:insertChildren /> to insert it. So, instead of

<td>#{cc.attrs.value}</td>

你应该做的

<td><composite:insertChildren /></td>


,如果您实际上要使用#{cc.attrs.value},则应从头开始将其定义为 real 标签属性.而不是作为标签主体:


Or if you actually want to use #{cc.attrs.value}, then you should be defining it as a real tag attribute from the beginning on instead of as tag body:

<someDir:boxComp value="Hello" />

这篇关于如何在JSF 2.0中将节点值作为属性传递给Composite Component的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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