如何将动作字符串传递到JSF 2复合组件中? [英] How to pass a action string into a JSF 2 composite component?
问题描述
我正在JSF 2中创建一个简单的菜单复合组件.但是,我无法将String属性传递给复合组件以用于< h:commandLink>的action属性.我的组件看起来像:
I'm creating a simple menuing composite component in JSF 2. However, I am unable to pass a String attribute into the composite component to use in the action attribute of the <h:commandLink>. My component looks like:
<composite:interface>
<composite:attribute name="title" required="true" type="java.lang.String"/>
<composite:attribute name="view" required="true" />
</composite:interface>
<!--implementation-->
<composite:implementation>
<li><h:commandLink action="#{cc.attrs.view}" value="#{cc.attrs.title}" /></li>
</composite:implementation>
如何将动作字符串放入< h:commandLink>的action属性中?
How can I get an action String into the action attribute of the <h:commandLink>?
推荐答案
像这样的东西吸引了Horstmanns :-)
Looks like this attracts the Horstmanns :-)
您必须将属性命名为"action",然后使用重定位.然后,一些特殊的处理方法会以清晰的说明(不是)在
You must name the attribute "action" and use retargeting. Then some special handling kicks in that is described with exquisite clarity (not) at
http://docs. oracle.com/javaee/6/javaserverfaces/2.0/docs/pdldocs/facelets/composite/attribute.html
以及我不允许粘贴其链接的ViewDeclarationLanguage.retargetMethodExpressions(不是ViewHandler)的API文档.
and the API doc of ViewDeclarationLanguage.retargetMethodExpressions (not ViewHandler) whose link I am not allowed to paste in.
这是您的操作方式.
<composite:interface>
<composite:attribute name="title" required="true" type="java.lang.String"/>
<composite:attribute name="action" targets="view" required="true" />
</composite:interface>
<!--implementation-->
<composite:implementation>
<li><h:commandLink id="view" value="#{cc.attrs.title}" /></li>
</composite:implementation>
这篇关于如何将动作字符串传递到JSF 2复合组件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!