无法通过cc:attribute设置JSF 2.0 Composite Component Button操作

时间:2011-07-28 09:21:20

标签: jsf-2 spring-webflow

我想构建一个已经包含一些按钮的复合组件,用户可以添加其他按钮。

<composite:interface>
    <composite:attribute name="action" required="false" default="cancel" targets="idCancelButton" />
</composite:interface>

<composite:implementation>
    <h:panelGroup 
        layout="block"
        style="margin: 10px 0 10px 0; text-align: right;"
        styleClass="commandButtons">
        <composite:insertChildren />
        <p:spacer width="10" height="10" />
        <h:commandButton
            id="idCancelButton"
            value="Cancel"
        </h:commandButton>
    </h:panelGroup>
</composite:implementation>

对组件的调用看起来像这样

<buttons:cancelButtonGroup>
    <p:commandButton id="idSaveButton" action="save" value="save" />
</buttons:cancelButtonGroup>

我在Jetty 6上使用Primefaces(3.0M2)(p:commandButton)和Spring Webflow以及Mojarra 2.0.6。 正如已经描述的here使用action作为属性名称与目标工作正常。唯一的问题是,可能希望在组件内部使用多个预定义按钮。然后action属性不再起作用了。我一直在玩很多但我无法获得一个工作版本,我将属性更改为cancelAction并通过action =“#{cc.attrs.action}”从按钮引用它。请注意,当我使用Spring Webflow时,取消是我过渡的名称!我不想用返回类型String调用某个函数。我总是得到例外:

2011-07-28 11:15:30,071 [12832806@qtp-10183200-3] WARN  exceptionHandler:185 - Handler execution resulted in exception
org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'managePhysicalHost' of flow 'host/manageHost'
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:569)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
    at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
    at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at info.novatec.np.server.web.filter.ConfigurableDelegatingFilter.doFilter(ConfigurableDelegatingFilter.java:51)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.cancelAction}'
    at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:444)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    at org.springframework.faces.webflow.FlowActionListener.processAction(FlowActionListener.java:81)
    at org.springframework.faces.model.SelectionTrackingActionListener.processAction(SelectionTrackingActionListener.java:55)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
    at org.springframework.faces.webflow.FlowLifecycle.invokePhase(FlowLifecycle.java:127)
    at org.springframework.faces.webflow.FlowLifecycle.execute(FlowLifecycle.java:70)
    at org.springframework.faces.webflow.JsfView.processUserEvent(JsfView.java:114)
    at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:248)
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:218)
    at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
    ... 31 more
2011-07-28 11:15:30,074 [12832806@qtp-10183200-3] ERROR org.mortbay.log:87 - /ui/main
org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'managePhysicalHost' of flow 'host/manageHost'
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:569)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
    at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
    at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at info.novatec.np.server.web.filter.ConfigurableDelegatingFilter.doFilter(ConfigurableDelegatingFilter.java:51)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.cancelAction}'
    at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:444)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    at org.springframework.faces.webflow.FlowActionListener.processAction(FlowActionListener.java:81)
    at org.springframework.faces.model.SelectionTrackingActionListener.processAction(SelectionTrackingActionListener.java:55)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
    at org.springframework.faces.webflow.FlowLifecycle.invokePhase(FlowLifecycle.java:127)
    at org.springframework.faces.webflow.FlowLifecycle.execute(FlowLifecycle.java:70)
    at org.springframework.faces.webflow.JsfView.processUserEvent(JsfView.java:114)
    at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:248)
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:218)
    at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
    ... 31 more
vax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
    at org.springframework.faces.webflow.FlowLifecycle.invokePhase(FlowLifecycle.java:127)
    at org.springframework.faces.webflow.FlowLifecycle.execute(FlowLifecycle.java:70)
    at org.springframework.faces.webflow.JsfView.processUserEvent(JsfView.java:114)
    at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:248)
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:218)
    at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
    ... 31 more

我一直在阅读很多关于复合组件的帖子和文章,但似乎没有人将它们与Spring Webflow混合在一起。或者它并不值得注意,我的问题在其他地方被埋没了。 :)

1 个答案:

答案 0 :(得分:0)

这似乎是JSF spec error