问题
I have successfully able to pass in argument to method inside composite component using this technique from BalusC (Pass Argument to a composite-component action attribute), however this seems to work on Mojarra, but not on MyFaces 2.0.4-2.0.5 (packaged inside Websphere 8.5 + OpenWebBeans). I post my code below
This is my cc
<cc:interface>
<cc:attribute name="value" />
<cc:attribute name="bean" />
<cc:attribute name="myAction" />
<cc:attribute name="property" />
</cc:interface>
<cc:implementation>
<rich:dataTable value="#{cc.attrs.value}" var="galleryFile">
...
<a4j:commandLink execute="@this" action="#{cc.attrs.bean[cc.attrs.myAction]}">
<f:setPropertyActionListener
target="#{cc.attrs.bean[cc.attrs.property]}"
value="#{galleryFile}" />
</a4j:commandLink>
</rich:dataTable>
</cc:implementation>
From the outside I do this
<mycomp:reportGallery value="#{listPopup.files}" id="listReportGallery"
bean="#{listPopup}" myAction="fileSelected" property="selectedFile"/>
Inside ListPopup ViewScoped bean, I have
@ManagedBean(name = "listPopup")
@ViewScoped
public class ListPopup implements Serializable {
private EpiFSObject selectedFile;
public void setSelectedFile(final EpiFSObject selectedFile) {
this.selectedFile = selectedFile;
}
public EpiFSObject getSelectedFile() {
return selectedFile;
}
public void fileSelected() {
...
}
}
When I click on the link, I got this exception
javax.el.PropertyNotFoundException: /resources/infor/reportGallery.xhtml at line 79 and column 89 action="#{cc.attrs.bean[cc.attrs.myAction]}": Property 'fileSelected' not found on type com.infor.om.ui.bean.ListPopup
at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:89)
at org.apache.myfaces.view.facelets.el.LocationValueExpression.getValue(LocationValueExpression.java:90)
So it fileSelected
is a property instead of a method. Does anyone know how to resolve this issue please? My suspicion is that this problem come from OpenWebBeans
EDIT I take suggestion from BalusC to do a hack to provide getFileSelected()
since it ask for fileSelected
as a property instead of method
public String getFileSelected(){
fileSelected();
return "";
}
but I still got below exception
java.lang.NullPointerException
at org.apache.myfaces.view.facelets.el.ValueExpressionMethodExpression.getExpressionString(ValueExpressionMethodExpression.java:70)
at org.apache.myfaces.view.facelets.el.TagMethodExpression.getExpressionString(TagMethodExpression.java:101)
at javax.faces.component._MethodExpressionToMethodBinding.getExpressionString(_MethodExpressionToMethodBinding.java:60)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:97)
at javax.faces.component.UICommand.broadcast(UICommand.java:120)
at org.richfaces.component.RowKeyContextEventWrapper.broadcast(RowKeyContextEventWrapper.java:104)
at org.richfaces.component.UIDataAdaptor.broadcast(UIDataAdaptor.java:448)
at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:973)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:275)
at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1285)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:711)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1225)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:775)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:457)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
at com.infor.om.ui.servlets.filter.LoginFilter.doFilter(LoginFilter.java:151)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.infor.om.ui.servlets.filter.ResponseFilter.doFilter(ResponseFilter.java:110)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.infor.om.ui.servlets.filter.LoginFilter.doFilter(LoginFilter.java:151)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.infor.om.ui.filter.RequestHeaderLogger.doFilter(RequestHeaderLogger.java:77)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.infor.om.ui.filter.RequestHeaderLogger.doFilter(RequestHeaderLogger.java:77)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:908)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1815)
Please help. Thank you
回答1:
Well, I have fixed this by create a common abstract bean that have these methods, so now I just have to pass in the bean and call cc.attrs.bean.commonMethod()
instead of cc.attrs.bean[cc.attrs.myAction]
. This will solve the problem. Not sure why myfaces
or OWB
does not understandthis syntax cc.attrs.bean[cc.attrs.myAction]
回答2:
We had the same Problem. We were able to fix it by updating AppServer from 8.5.0.0 to 8.5.0.2.
来源:https://stackoverflow.com/questions/17357593/passed-argument-to-method-inside-composite-component-does-not-work-on-myfaces