使用Omniface的Components #includeCompositeComponent
动态创建组合组件时,是否可以传递属性值(例如属性myValue
),以便它可用于复合材料上的预渲染事件?Omnifaces组件#includeCompositeComponent设置属性值
<composite:interface>
<composite:attribute name="myValue" required="true" />
</composite:interface>
<composite:implementation>
<!-- this works! -->
<h:outputText value="#{cc.attrs.myValue}" />
<!-- this doesn't execute -->
<f:event id="eventId"
type="javax.faces.event.PreRenderComponentEvent"
listener="#{bean.someAction(cc.attrs.myValue)}" />
<!-- stuff -->
</composite:implementation>
不过,我能够访问myValue
在XHTML(可通过#{cc.attrs.myValue}
),但它不适用于预渲染(我以前UIComponent#getAttributes
指定myValue
的价值)。
编辑:如果该属性也可用于@PostConstruct
(通过托管属性),它也可以。
'setValueExpression'是否将复合属性与bean中的值绑定('bean.myValue')?不过,要尝试一下。谢谢 – nuno 2014-10-10 14:51:26
它和''具有完全相同的效果,而'getAttribute()'方法与''只要它是一个'String'。 –
BalusC
2014-10-10 14:55:03
经过仔细阅读后,我猜'setValueExpression'只是从另一个bean获取值。我对吗? – nuno 2014-10-10 14:55:05