0

我已经成功地使用 BalusC 中的这种技术将参数传递给复合组件内部的方法(将参数传递给复合组件操作属性),但这似乎适用于 Mojarra,但不适用于MyFaces 2.0.4-2.0.5(打包在 Websphere 8.5 + OpenWebBeans 中)。我在下面发布我的代码

这是我的抄送

 <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>

从外面我这样做

<mycomp:reportGallery value="#{listPopup.files}" id="listReportGallery" 
        bean="#{listPopup}" myAction="fileSelected" property="selectedFile"/>

在 ListPopup ViewScoped bean 里面,我有

@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() {
         ...
     }
}

当我点击链接时,我得到了这个异常

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)

所以它fileSelected是一个属性而不是一个方法。请问有谁知道如何解决这个问题?我怀疑这个问题来自 OpenWebBeans

编辑我接受 BalusC 的建议做一个 hack 来提供getFileSelected(),因为它要求fileSelected作为属性而不是方法

public String getFileSelected(){
    fileSelected();
    return "";
}

但我仍然低于异常

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)

请帮忙。谢谢

4

2 回答 2

1

好吧,我已经通过创建一个具有这些方法的通用抽象 bean 来解决这个问题,所以现在我只需要传入 bean 并调用cc.attrs.bean.commonMethod()而不是cc.attrs.bean[cc.attrs.myAction]. 这将解决问题。不知道为什么myfacesOWB不理解这种语法cc.attrs.bean[cc.attrs.myAction]

于 2013-07-01T07:18:41.463 回答
1

我们有同样的问题。我们能够通过将 AppServer 从 8.5.0.0 更新到 8.5.0.2 来修复它。

于 2013-08-27T21:38:05.137 回答