2

可以写这样的东西吗?

<f:metadata>
    <f:viewParam name="#{constantsBean.viewParameterNameForIds}" value="#{displayBean.technicalId}" />
</f:metadata>

我总是收到 myfaces 错误,我认为它来自视图参数名称中的 el 表达式。

编辑:完整的堆栈跟踪是:

java.lang.NullpointerException
at org.apache.myfaces.util.AbstractAttributeMap.get(AbstractAttributeMap.java:94)
at javax.faces.component.UIViewParameter.decode(UIViewParameter.java:78)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
at javax.faces.component.UIInput.processDecodes(UIInput.java:178)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1170)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1170)
at javax.faces.component.UIViewRoot._processDecodesDefault(UIViewRoot.java:1316)
at javax.faces.component.UIViewRoot.access$400(UIViewRoot.java:75)
at javax.faces.component.UIViewRoot$ApplyRequestValuesPhaseProcessor.process(UIViewRoot.java:1379)
at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1282)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:718)
at org.apache.myfaces.lifecycle.ApplyRequestValuesExecutor.execute(ApplyRequestValuesExecutor.java:34)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:95)
at org.apache.myfaces.extensions.validator.core.startup.ExtValLifecycleWrapper.execute(ExtValLifecycleWrapper.java:61)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1147)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:722)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:449)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92)
at gid.common.technical.filter.InboundProcessingFilter.doFilter(InboundProcessingFilter.java:46)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:919)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1016)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:883)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1659)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
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:1648)

顺便提一句。我正在使用随 WebSphere 8、Myfaces Codi 和 ExtVal 一起提供的 MyFaces。

4

1 回答 1

3

<f:viewParam>文档name对属性进行了以下说明:

Name | Required | Request-Time | Type
-----+----------+--------------+-------------------------------------------------
name | true     | false        | javax.el.ValueExpression 
     |          |              | (must evaluate to java.lang.String)    

它说javax.el.ValueExpression,不是java.lang.String(就像你在id属性上看到的那样,它确实不接受值表达式)。所以,它确实支持EL。

我不使用 MyFaces,但我只是在 Mojarra 上进行了测试,它对我有用。我不确定您到底得到了什么错误,因为您似乎出于某种原因将其视为无关信息,因此在您的问题中没有提及。错误信息即通常包含问题的答案。如果您发布完整的错误消息,那么我们可能能够用外行的方式解释该消息,以便您能够理解错误,因此解决方案将变得显而易见。例如,它可能有完全不同的原因,甚至可能是 MyFaces 中的错误。

于 2012-05-04T16:31:22.650 回答