myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <>
Subject [jira] [Commented] (MYFACES-3613) NPE in composite component when ActionListener is missing in the source
Date Fri, 05 Oct 2012 18:24:02 GMT


Leonardo Uribe commented on MYFACES-3613:

I have seen this problem many times. The recommended solution until this time is use "targets"

<cc:attribute name="action" targets="mybutton"/>
        <cc:attribute name="value"/>
        <cc:actionSource targets="mybutton"/>
<h:commandButton id="mybutton" value="#{cc.attrs.value}" immediate="true">

This syntax is the one initially designed in JSF 2.0 spec.

But thinking more about it, it sounds reasonable to avoid the NullPointerException on ValueExpressionMethodExpression,
which do the "bridge" between source #{cc.attr....} declaration and the ValueExpression chain,
that finally ends in the final MethodExpression. In that way, h:commandButton will have a
"dummy" invocation, but if you provide a method expression in the composite component attribute
map, it will be redirected without any user intervention. 

I can't imagine any side effects doing this change, and it will be friendly for users. Also,
there are some cases where this behavior is wanted and "targets" syntax needs to be avoided
(non NamingContainer  composite component and inner components with generated ids). According
to user reports, it will help with migration from facelets templates to composite components.

If no objections I'll commit the proposed solution soon.
> NPE in composite component when ActionListener is missing in the source
> -----------------------------------------------------------------------
>                 Key: MYFACES-3613
>                 URL:
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.1.8
>         Environment: Java 1.7_05 Win32, Servlet3.0, Jetty8.1.5.v20120716
>            Reporter: marco fago
>         Attachments: MYFACES-3613-1.patch
> Consider the following component (simpleCommandButton.xhtml)
> <ui:component xmlns="" 
> 	xmlns:ui=""
>   	xmlns:h="" 
>   	xmlns:p=""  	
> 	xmlns:cc=""
>   	>
> 	<cc:interface>
> 		<cc:attribute name="action"/>
> 		<cc:attribute name="actionListener"/>
>         <cc:attribute name="value"/>        
> 	</cc:interface>
> 	<cc:implementation>		
> 		<h:commandButton value="#{cc.attrs.value}" action="#{cc.attrs.action}" actionListener="#{cc.attrs.actionListener}"
> 			<cc:insertChildren/>
> 		</h:commandButton>
> 	</cc:implementation>
> </ui:component>
> And in your page:
> <myLib::simpleCommandButton value="Test" action="exit"/>
> When clicking on the button a NPE occurs:
> java.lang.NullPointerException
> 	at org.apache.myfaces.view.facelets.el.ValueExpressionMethodExpression.invoke(
> 	at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(
> 	at javax.faces.event.MethodExpressionActionListener.processAction(
> 	at javax.faces.event.ActionEvent.processListener(
> 	at javax.faces.component.UIComponentBase.broadcast(
> 	at javax.faces.component.UICommand.broadcast(
> 	at javax.faces.component.UIViewRoot._broadcastAll(
> 	at javax.faces.component.UIViewRoot.broadcastEvents(
> 	at javax.faces.component.UIViewRoot._process(
> 	at javax.faces.component.UIViewRoot.processDecodes(
> 	at org.springframework.faces.webflow.FlowLifecycle.invokePhase(
> 	at org.springframework.faces.webflow.FlowLifecycle.execute(
> 	at org.springframework.faces.webflow.JsfView.processUserEvent(
> 	at org.springframework.webflow.engine.ViewState.handleEvent(
> 	at org.springframework.webflow.engine.ViewState.resume(
> 	at org.springframework.webflow.engine.Flow.resume(
> 	at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(
> 	at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(
> 	at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(
> 	at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(
> 	at org.springframework.web.servlet.DispatcherServlet.doDispatch(
> 	at org.springframework.web.servlet.DispatcherServlet.doService(
> 	at org.springframework.web.servlet.FrameworkServlet.processRequest(
> 	at org.springframework.web.servlet.FrameworkServlet.doPost(
> 	at javax.servlet.http.HttpServlet.service(
> 	at javax.servlet.http.HttpServlet.service(
> 	at org.eclipse.jetty.servlet.ServletHolder.handle(
> 	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(
> 	at org.primefaces.webapp.filter.FileUploadFilter.doFilter(
> 	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(
> 	at net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(
> 	at net.sf.ehcache.constructs.web.filter.Filter.doFilter(
> 	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(
> 	at$VirtualFilterChain.doFilter(
> probably because of the missing (null) attribute "actionListener" in the source declaration.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message