Problems with <p:datatable> and jboss 7.1 el method call

UI Components for JSF
hanskr
Posts: 3
Joined: 09 Mar 2012, 12:15

09 Mar 2012, 12:36

Hi.

I have a problem when passing a method call as the "value" for a datatable.

I am on JBoss 7.1 Final, and I've tried Primefaces 3.1, 3.1.1 and 3.2RC1 with the same result. I am using servlet 3.0 and the standard JBoss EL engine which is supposed to be EL 2.2 spec compliant.

This is an example of code that will fail:

test.xhtml

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
        <p:dataTable value="#{testBean.getStuff()}" var="item">
			<p:column>
                <h:outputText value="#{item}"/>
            </p:column>
		</p:dataTable>
</ui:composition>
My bean, TestBean.java

Code: Select all

package protector.claims.web.backing;

import java.io.Serializable;
import java.util.*;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named
@RequestScoped
public class TestBean implements Serializable {
	private static final long serialVersionUID = 1L;

	public List<String> getStuff() {
		List<String> l = new ArrayList<String>();
		l.add("Test");
		return l;
	}
}
The error message I get when accessing the page:
11:26:20,242 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-5) Error Rendering View[/test.xhtml]: javax.el.PropertyNotFoundException: /test.xhtml @9,64 value="#{testBean.getStuff()}": The class 'protector.claims.web.backing.TestBean$Proxy$_$$_WeldClientProxy' does not have the property 'getStuff'.
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at org.primefaces.component.datatable.DataTable.isLazy(DataTable.java:968) [primefaces-3.2.RC1.jar:]
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:191) [primefaces-3.2.RC1.jar:]
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:108) [primefaces-3.2.RC1.jar:]
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.0.Final.jar:2.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79) [primefaces-3.2.RC1.jar:]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.0.Final.jar:7.1.0.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.10.Final.jar:]
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.10.Final.jar:]
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.10.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]
Now, if I change the <p:datatable> to a <h:datatable> it works fine. Also calling methods (with or without parameters) work fine everywhere else I use them. That's why I suspect this to be a Primefaces bug and not a JBoss bug.

I know I can work around this issue by accessing a property instead of a method, but this is a simplified example and in my real app that is not really an option.

So, please. Could someone take a look at this and see why Primefaces insists on looking for a property when I am trying to call a method?

Hamsterbau
Posts: 409
Joined: 28 Dec 2011, 17:44

09 Mar 2012, 12:45

I've red some time ago of a "bug" of JBoss AS 7 with methods without parameters. But if this EL works for you in h:dataTable maybe it was fixed :?:
Primefaces 8.0.7 (PF Extensions 8.0)
JSF: Mojarra 2.3.2 (Spec 2.3) - running on WildFly 22

hanskr
Posts: 3
Joined: 09 Mar 2012, 12:15

09 Mar 2012, 12:54

I have no problem calling methods without parameters in other places than p:datatable.
Furthermore I get the exact same error if I call a method with parameters in the p:datatable

Hamsterbau
Posts: 409
Joined: 28 Dec 2011, 17:44

09 Mar 2012, 13:00

Ok, than it sounds like a PF problem :(
Primefaces 8.0.7 (PF Extensions 8.0)
JSF: Mojarra 2.3.2 (Spec 2.3) - running on WildFly 22

mindlink
Posts: 14
Joined: 08 Oct 2009, 14:25

12 Mar 2012, 14:04

I have the same problem when using datalist.

The error is at (PF 3.2)
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at org.primefaces.component.api.UIData.isLazy(UIData.java:155)
at org.primefaces.component.datalist.DataListRenderer.encodeMarkup(DataListRenderer.java:63)

when the value property is a function e.g. value="#{editProject.getUsers(2)}"

It looks like the isLazy method is not able to evaluate this correctly. Maybe as a short term solution it should just return
"false" when there is a problem.

hanskr
Posts: 3
Joined: 09 Mar 2012, 12:15

13 Mar 2012, 10:57

FYI I have now made a workaround that hooks in a custom EL-resolver like this:

Code: Select all

package protector.claims.util.el;

import stuff...;

public class ElResolverImpl extends ELResolver {

	@Override
	public Class<?> getType(ELContext elContext, Object base, Object property) {
		if (base == null || property == null) {
			return null;
		}

		try {
			elContext.getELResolver().getValue(elContext, base, property);
		} catch (javax.el.PropertyNotFoundException e) {
			for(Method m:base.getClass().getMethods()) {
				if (m.getName().equals(property)) {
					elContext.setPropertyResolved(true);
				    return Object.class;
				}
			}
		}

		return null;
	}
The other methods you have to override can pretty much just return null as they will pass down the chain.

And in the faces-config.xml:

Code: Select all

    <application>
    	<el-resolver>protector.claims.util.el.ElResolverImpl</el-resolver>
    </application>
Basically, I just check to see if a method exists with the property name. I can't see any way to find the arguments to the method, so there's a potential for Fail there. But it solves my problem for the time being.

MP3HiFi
Posts: 8
Joined: 23 Feb 2012, 21:55

23 Apr 2012, 17:15

Hello,

any news on this error or problem.

Kind Regards
Martin

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

23 Apr 2012, 20:27

MP3HiFi wrote:any news on this error or problem.
Did you try the workaround that the other person shared above?
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

demetrio812
Posts: 29
Joined: 10 Feb 2010, 03:44

24 Jun 2012, 02:45

Hello, I have the same problem here (PF 3.3). The workaround works well (thanks!!) but I think this is very important and need to be fixed...without the workaround, p:dataTable would give me the PropertyNotFound exception while if I swap to h:dataTable is works as expected...

Please fix it..

Thanks,
Dem

demetrio812
Posts: 29
Joined: 10 Feb 2010, 03:44

24 Jun 2012, 03:05

I have to say that now the workaround breaks all my ajax form submit...will have to look into it and undertand why...

This is a basic use case and I don't understand why we have to use workarounds to be able to call a method (with parameters) instead of a property only...

Thanks,
Dem

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 46 guests