webtier@glassfish.java.net

Re: JSF 2.0 composite components with method-valued attributes

From: <webtier_at_javadesktop.org>
Date: Wed, 18 Feb 2009 10:35:29 PST

I tried the Nightly build, but I still get an exception, well, read along :) :

I noticed that there is a nav sample and changed it to
<composite:interface>
    <composite:attribute name="act" targets="navbutton" required="true" method-signature="String f1(void)" />
</composite:interface>

<composite:implementation>
   <h:commandButton id="navbutton" action="#{compositeComponent.attrs.act}" value="NavButton" type="submit" />
    <!-- <h:commandButton id="navbutton" action="nav2" value="NavButton" type="submit" /> -->
</composite:implementation>
(renamed action to act as action has special treatment)

here is the stacktrace:

java.lang.ClassCastException: com.sun.faces.facelets.el.TagValueExpression cannot be cast to javax.el.MethodExpression
        at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:262)
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        at javax.faces.component.UICommand.broadcast(UICommand.java:387)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:764)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1185)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:102)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
        at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)


I also see

Unable to determine expected return type for String f1()
java.lang.ClassNotFoundException: String
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1576)
        at com.sun.faces.util.Util.loadClass(Util.java:203)
        at com.sun.faces.util.Util.getTypeFromString(Util.java:302)
        at com.sun.faces.application.view.MultiViewHandler.retargetMethodExpressions(MultiViewHandler.java:402)
        at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(CompositeComponentTagHandler.java:162)
        at com.sun.faces.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:192)
        at com.sun.faces.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:84)
        at com.sun.faces.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:361)
        at com.sun.faces.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:192)
        at com.sun.faces.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:84)
        at com.sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:101)
        at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:182)
        at com.sun.faces.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:376)
        at com.sun.faces.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:347)
        at com.sun.faces.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:106)
        at com.sun.faces.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:84)
        at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86)
        at com.sun.faces.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:84)
        at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:80)
        at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:285)
        at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:331)
        at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:310)
        at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:181)
        at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:159)
        at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:86)
        at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:80)
        at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:132)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:462)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.createView(FaceletViewHandlingStrategy.java:288)
        at com.sun.faces.application.view.MultiViewHandler.createView(MultiViewHandler.java:477)
        at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:201)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:102)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:106)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)

Actually I ran into this last week so I changed String to java.lang.String,
now I get
javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: Method not found: ezcomp.NavigationHandler_at_508e9.goNav2(void)
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:92)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        at javax.faces.component.UICommand.broadcast(UICommand.java:387)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:764)

I changed (void) to () and it started working!
So now I have
    <composite:attribute name="act" targets="navbutton" required="true" method-signature="java.lang.String f1()" />

Great job!
[Message sent by forum member 'nzinoviev' (nzinoviev)]

http://forums.java.net/jive/thread.jspa?messageID=332717