I use facelets components (not composite components, old fashioned way with tag lib) and I have situation that p:ajax can't evaluate EL expression with facelets parameters as listener attribute (Primefaces 3.0.M3).
Example:
Page A:
Code: Select all
...
<wf:dataTable tableId="tblSearchResult" dataModel="#{formBacking.dataBean.tableModel}" rows="5"
selectItem="#{formBacking.dataBean.selectedRow}" selectable="#{allowSelect}" selectListenerFormBacking="#{formBacking}" rowSelectListener="handleRowSelect"
lazy="true" partialTriggers="tblSearchResult tblSearchResultHelper">
...
Code: Select all
...
<c:if test="${not empty rowSelectListener}">
<c:set var="selectListenerFormBacking" value="${empty selectListenerFormBacking ? formBacking : selectListenerFormBacking}" />
<c:set var="rowSelectListenerMethod" value="${rowSelectListener}" />
</c:if>
<c:if test="${empty rowSelectListener}">
<c:set var="selectListenerFormBacking" value="${dummyBacking}" />
<c:set var="rowSelectListenerMethod" value="emptySelectListener" />
</c:if>
<c:set var="selectionMode" value="#{empty selectionMode ? 'single' : (selectionMode eq 'none' ? null : selectionMode)}" />
<p:dataTable id="#{tableId}" value="#{dataModel}"
rendered="#{empty rendered ? true : rendered}" var="row"
style="#{empty style ? 'width:100%;' : style}"
emptyMessage="#{empty emptyText? resMsg['inf.no_data_found'] : emptyText}"
paginator="#{empty paginator ? true : paginator}"
paginatorPosition="#{empty paginatorPosition? 'bottom' : paginatorPosition}"
rows="5"
selection="#{selectItem}" update="#{partialTriggers}"
selectionMode="#{selectionMode}"
scrollable="#{empty scrollable? false : scrollable}"
lazy="#{lazy}" styleClass="#{styleClass}" rowIndexVar="rowIndex"
rowStyleClass="#{rowStyleClass}"
rowKey="#{empty rowKey ? row.hashCode() : rowKey}">
<p:ajax event="rowSelect" listener="#{selectListenerFormBacking[rowSelectListenerMethod]}"
update="#{partialTriggers}" oncomplete="#{onselectComplete}"/>
...
I debuged and found source of the problem in class AjaxBehavior and method broadcast:
Code: Select all
FacesContext context = FacesContext.getCurrentInstance();
ELContext eLContext = context.getELContext();
if(listener != null) {
try {
listener.invoke(eLContext, null); // A //no-arg listener
} catch(MethodNotFoundException e1) {
MethodExpression argListener = context.getApplication().getExpressionFactory().
createMethodExpression(eLContext, listener.getExpressionString(), null, new Class[]{event.getClass()});
argListener.invoke(eLContext, new Object[]{event}); // B
}
}
So code A throws MethodNotFoundException and code B throws javax.el.PropertyNotFoundException.
But if i use event method without parameter public void handleRowSelect2() {} and change page A with rowSelectListener="handleRowSelect", code A executes successfully and event is fired and dataTable behaves as expected.
So i think there is problem with MethodExpression creation context, because listener property is setted earlier and works ok (except it expects method without parameter).
I tested with Mojarra 2.1.3 and Myfaces 2.1.3 and got same results. Earlier Primefaces version 3.0.M1 worked fine because events was implemented as attributes.
Is it bug in my usage, in JSF implementation or in Primefaces?
P.S. I thought it is related to myfaces bug fix MYFACES-3169, but same results with Mojarra. And most interesting why code A can successfully get selectListenerFormBacking.