如何在 JSF 2.0 中将节点值作为复合组件中的属性传递
我正在开发一个 JSF 2.0 复合组件。我正在尝试创建一个框组件,将所需的 HTML 设置为属性。
有些事情就像......
<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 传递给属性“value”时,就像这样:
<someDir:boxComp>Hello</someDir:boxComp>
“Hello”不被视为属性值。 我如何使节点值作为属性值?
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.
Some thing like..
<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>
When I want to use this component and pass the required HTML to the attribute "value", like so:
<someDir:boxComp>Hello</someDir:boxComp>
the "Hello" is not taken as attribute value.
How i can make the node value as an attribute value.?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有将其作为标签属性传递。您只需将其作为标签主体中的子项传递即可。在这种情况下,您需要使用
插入它。因此,定义
如果您实际上想使用
#{cc.attrs.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 ofyou should be doing
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: