0
我們對自己的JSF 2.2項目中使用這樣的(代碼已被簡化爲清楚起見)的複合成分:F:在複合材料部件阿賈克斯聽者停止WildFly工作10
<!-- the page with the composite component inside -->
<my:component methodListener="#{myBean.myMethod}" />
<!-- the composite component -->
<cc:interface>
<cc:attribute name="methodListener" required="true" method-signature="void listener(javax.faces.event.AjaxBehaviorEvent)" />
...
<cc:implementation>
<h:commandLink>
<f:ajax listener="#{cc.attrs.methodListener}" />
<f:attribute name="myAttribute" value="myValue" />
</h:commandLink>
// the called method
public void myMethod(AjaxBehaviorEvent event)
{
System.out.println("> " + event);
}
在Wildfly 9.0.2,當點擊複合組件內部的commandLink
時,myMethod
被調用並且事件被定義(允許我們找回myAttribute
的值)。
在Wildfly 10.1.0中,使用完全相同的代碼調用myMethod
,但事件參數始終爲null
。
我們在這裏做錯了什麼?
測試過的解決方法可能是用bean實例替換methodListener CC屬性,如下面的代碼。不過,這需要在我們的項目中進行大量替換,因此我們希望避免此解決方案。
<!-- the workaround composite component -->
<cc:interface>
<cc:attribute name="methodBean" required="true" type="com.example.myBean" />
...
<cc:implementation>
<h:commandLink>
<f:ajax listener="#{cc.attrs.methodBean.myMethod}" />
<f:attribute name="myAttribute" value="myValue" />
</h:commandLink>