ネストされた複合コンポーネントにメソッド パラメータを渡す際に問題があります。
最初のコンポーネント wose composite:interface は次のようになります。
<composite:interface>
<composite:attribute name="onRowEditListener" required="false" method-signature="void listener(org.primefaces.event.RowEditEvent)"/>
</composite:interface>
同様のインターフェースを持つ別の複合コンポーネント コンポーネントを使用します。
第 1 レベルのコンポーネントは次のように使用されます。
<mynamespace:compo1 onRowEditListener=#{bean.method}"/>
ネストされたものは次のように使用されます。
<mynamespace:compo2 onRowEditListener=#{cc.attrs.onRowEditListener}"/>
両方のコントロールに挿入すると、次のようになりました。
- 最初のレベルのコントロールでは、org.apache.el.MethodExpressionImpl@358f0647 のような出力が表示されます。
- 2 番目の (ネストされた) レベル コントロールでは、 org.apache.myfaces.view.facelets.el.LocationValueExpression@ff381f45 のような出力。
発生した例外は次のようになります。
19/07/2012 19:39:02 fr.senat.faces.exceptions.DetailedExceptionHandler INFO [DetailedExceptionHandler.java:40] [http-8080-7] - Stack trace: javax.faces.FacesException: Exception while calling broadcast on component : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /editSenateur.xhtml][Class: javax.faces.component.html.HtmlBody,Id: j_id_5][Class: org.primefaces.component.layout.Layout,Id: j_id_6][Class: org.primefaces.component.layout.LayoutUnit,Id: j_id_v][Class: org.primefaces.component.outputpanel.OutputPanel,Id: detailCommissions][Class: javax.faces.component.html.HtmlForm,Id: j_id_x][Class: org.primefaces.component.tabview.TabView,Id: tabFonctionsInternes][Class: org.primefaces.component.tabview.Tab,Id: fonctionsCommissions][Class: javax.faces.component.UINamingContainer,Id: j_id_10][Class: javax.faces.component.UIPanel,Id: j_idj_id_10__f_cc_facet][Class: org.primefaces.component.outputpanel.OutputPanel,Id: panelTabViewCommissions][Class: org.primefaces.component.tabview.TabView,Id: tabViewCommissions][Class: org.primefaces.component.tabview.Tab,Id: commissionTab][Class: org.primefaces.component.panelgrid.PanelGrid,Id: j_id_15][Class: org.primefaces.component.row.Row,Id: j_id_1b][Class: org.primefaces.component.column.Column,Id: j_id_1c][Class: javax.faces.component.UINamingContainer,Id: j_id_1d][Class: javax.faces.component.UIPanel,Id: j_idj_id_1d__f_cc_facet][Class: org.primefaces.component.datatable.DataTable,Id: sheetFonctions]} created from: /resources/sen/fonctionsCommission.xhtml at line 27 and column 162
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:430)
at javax.faces.component.UIData.broadcast(UIData.java:1610)
at javax.faces.component.UIData.broadcast(UIData.java:1596)
at javax.faces.component.UIData.broadcast(UIData.java:1596)
at javax.faces.component.UIData.broadcast(UIData.java:1596)
at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1023)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:286)
at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1360)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:38)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:95)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at fr.senat.faces.filters.HibernateSessionConversationFilter.doFilter(HibernateSessionConversationFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.myfaces.view.facelets.el.ContextAwareELException: javax.el.ELException: java.lang.IllegalArgumentException: wrong number of arguments
at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:108)
at org.primefaces.component.behavior.ajax.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxBehaviorListenerImpl.java:42)
at org.primefaces.event.RowEditEvent.processListener(RowEditEvent.java:41)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:74)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:406)
... 31 more
Caused by: javax.el.ELException: java.lang.IllegalArgumentException: wrong number of arguments
at org.apache.el.parser.AstValue.invoke(AstValue.java:195)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at org.apache.myfaces.view.facelets.el.ValueExpressionMethodExpression.invoke(ValueExpressionMethodExpression.java:68)
at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:96)
... 35 more
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.el.parser.AstValue.invoke(AstValue.java:191)
... 38 more
メソッドは最初のコントロールに適切に渡されているように見えますが、2番目に渡されるとEL式が黒丸になります...
私は使っている :
- マイフェイス 2.1.7
- トムキャット 6.0.33
よろしくお願いします。
アップデート
私が評価できる唯一の「進歩」は、お粗末です...
クラッジクラス:
/**
*
* @author lpenet
*
* This class is a workaround kluge. Methods passed as a parameter to a
* composite component then to a PrimeFaces p:ajax seems to get a bullet
* somewhere in the process, at least with Tomcat 6 + MyFaces
* 2.1 + CODI 1.0.5 + OpenWebbeans 1.0.3 See :
* http://forum.primefaces.org/viewtopic.php?f=3&t=23558&p=72885#p72885
*
* Using this class as "componentType", one can forward the methode call.
*
* Not so nice, but... works.
*
*/
@FacesComponent(value = "fr.senat.beans.PrimefacesListenerKludge")
public class PrimefacesListenerKludge extends UINamingContainer {
@Override
public String getFamily() {
return "javax.faces.NamingContainer"; // Important! Required for
// composite components.
}
public void forwardRowEditListener(RowEditEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
Object listener = getAttributes().get("onRowEditListener");
if (listener == null) {
return;
}
MethodExpression ajaxEventListener = (MethodExpression) listener;
ajaxEventListener
.invoke(context.getELContext(), new Object[] { event });
}
}
サンプル使用:
<composite:interface componentType="fr.senat.beans.PrimefacesListenerKludge">
...
<composite:attribute name="onRowEditListener" required="false"
method-signature="void listener(org.primefaces.event.RowEditEvent)"
default="#{cc.parent.attrs.onRowEditListener}" />
</composite:interface>
<composite:implementation>
...
</composite:implementation>
正直なところ、現在のスタック (PrimeFaces 4/MyFaces 2.1.13/OWB 1.2.1/Tomcat 7.0.32) でまだ必要かどうかはわかりませんが、テストする時間がありません。