p:ajax can't resolve facelets params in listener

UI Components for JSF
Post Reply
Shtirlicas
Posts: 7
Joined: 19 Apr 2011, 16:22

25 Oct 2011, 17:05

Hi,

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">
...
wf:data:

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}"/>
...
Problem is that expression "#{selectListenerFormBacking[rowSelectListenerMethod]}" throws Exception: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'selectListenerFormBacking' resolved to null

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
            }
        }
I have event method with parameter in my backing: public void handleRowSelect(final SelectEvent pEvent) {}
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.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

25 Oct 2011, 17:16

Hi,

This is a known bug. We have faced the same issue with p:ajax. Please report an issue in the issue tracker.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

Shtirlicas
Posts: 7
Joined: 19 Apr 2011, 16:22

25 Oct 2011, 18:15

thanks for quick reply. Registered issue http://code.google.com/p/primefaces/iss ... il?id=2690

Shtirlicas
Posts: 7
Joined: 19 Apr 2011, 16:22

13 Dec 2011, 15:42

Issue 2690 status was changed to CantReplicate, but I updated issue with test case. I wonder if I should create new issue or it will be reviewed someday?

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

14 Dec 2011, 07:54

Shtirlicas wrote:Issue 2690 status was changed to CantReplicate, but I updated issue with test case. I wonder if I should create new issue or it will be reviewed someday?
Just bookmark the issue, check on it for a few days, if you don't hear anything, then please do New Issue and add your test case.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 50 guests