autocompleteMethod giving PropertyNotFoundException when used in composite
jonathan.man Mar 30, 2012 4:02 AMHi everyone,
I'm trying to develop a custom component based on Richfaces autocomplete, but I'm having trouble passing the "autocompleteMethod" attribute through my composite.
The composite seems to expect a property with a "getter" instead of a method, and thus is generating an exception when trying to use the autocomplete.
Here is the composite :
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="autocompleteMethod" method-signature="java.util.List filter(java.lang.String)" />
<composite:attribute name="value" type="java.lang.Object" />
</composite:interface>
<composite:implementation>
<rich:autocomplete id="autocomplete"
autocompleteMethod="#{cc.attrs.autocompleteMethod}"
value="#{cc.attrs.value}"
minChars="0"
showButton="true">
</rich:autocomplete>
</composite:implementation>
</html>
Here is my test page, with a standard autocomplete which works properly :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:mutex="http://java.sun.com/jsf/composite/components/mutex">
<ui:debug />
<h:head>
<title><h:outputText value="Small test application" /></title>
</h:head>
<h:body>
<h:form id="form">
<rich:panel header="Standard Autocomplete Test (with filter)">
<h:panelGrid columns="2">
<h:outputText value="Chose value : " />
<rich:autocomplete value="#{filteredAuto.stringValue}"
autocompleteMethod="#{filteredAuto.filterStringValues}"
showButton="true"
minChars="1">
</rich:autocomplete>
</h:panelGrid>
</rich:panel>
<rich:panel header="Custom Autocomplete Test (with filter)">
<h:panelGrid columns="2">
<h:outputText value="Chose value : " />
<mutex:customAuto value="#{filteredAuto.stringValue}"
autocompleteMethod="#{filteredAuto.filterStringValues}"
showButton="true">
</mutex:customAuto>
</h:panelGrid>
</rich:panel>
<rich:messages id="messages"/>
</h:form>
</h:body>
</html>
My web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <display-name>Test components</display-name> <context-param> <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name> <param-value>true</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <context-param> <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param> </web-app>
And my pom :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.mutex</groupId>
<artifactId>testforum</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Testforum Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<!-- <slf4j.version>1.6.4</slf4j.version> -->
<spring.version>3.0.6.RELEASE</spring.version>
<mojarra.version>2.1.7</mojarra.version>
<richfaces.version>4.2.0.Final</richfaces.version>
<hibernate.version>4.0.1.Final</hibernate.version>
<junit.version>3.8.1</junit.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-bom</artifactId>
<version>${richfaces.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${mojarra.version}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${mojarra.version}</version>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>testforum</finalName>
</build>
</project>
Here is the stacktrace :
30 mars 2012 09:52:05 org.richfaces.renderkit.AutocompleteRendererBase getItems
GRAVE: /filter-test.xhtml @31,25 autocompleteMethod="#{filteredAuto.filterStringValues}": Property 'filterStringValues' not found on type fr.testcomp.custom.autocomplete.FilteredAutocompleteBean
javax.el.PropertyNotFoundException: /filter-test.xhtml @31,25 autocompleteMethod="#{filteredAuto.filterStringValues}": Property 'filterStringValues' not found on type fr.testcomp.custom.autocomplete.FilteredAutocompleteBean
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
at com.sun.faces.facelets.el.ContextualCompositeMethodExpression.invoke(ContextualCompositeMethodExpression.java:190)
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:450)
at org.richfaces.renderkit.AutocompleteRendererBase.getItems(AutocompleteRendererBase.java:102)
at org.richfaces.renderkit.AutocompleteRendererBase.encodeItems(AutocompleteRendererBase.java:163)
at org.richfaces.renderkit.AutocompleteRendererBase.encodeMetaComponent(AutocompleteRendererBase.java:275)
at org.richfaces.component.AbstractAutocomplete.encodeMetaComponent(AbstractAutocomplete.java:234)
at org.richfaces.context.ExtendedPartialViewContextImpl$RenderVisitCallback.visit(ExtendedPartialViewContextImpl.java:493)
at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:321)
at org.richfaces.context.ExtendedVisitContext.invokeMetaComponentVisitCallback(ExtendedVisitContext.java:68)
at org.richfaces.component.AbstractAutocomplete.visitTree(AbstractAutocomplete.java:220)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:163)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIForm.visitTree(UIForm.java:371)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
at org.richfaces.context.ExtendedPartialViewContextImpl.processPartialRenderPhase(ExtendedPartialViewContextImpl.java:272)
at org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:194)
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:981)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:391)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1805)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
My setup is :
Eclipse indigo 3.7.0
jdk 1.6_30
Tomcat 7.0.25
Richfaces 4.2.0.Final
Mojarra 2.1.7
I've tried many things, such as :
- replacing tomcat el-api by el-api-2.2 found on maven
- tried with this el-api, both el-impl-2.2 of glassfish, and jboss-el 2.0.0.GA
- decalring the attribute as an javax.el.MethodExpression
All of this to no avail.
el-impl of glassfish gives another error : "wrong number of arguments, something like that.
I also tried tomcat 7.0.26, and i have same behavior.
Is this something to do with me? A JSF bug? A richfaces one? Or an el one?
Thanks in advance