t:dataList导致JSF中的重定向问题(java.lang.IllegalStateException)

时间:2011-04-04 14:42:28

标签: jsf redirect

我正在尝试编写简单的基于jsf的应用程序,但是有一个问题我无法解决。我需要页面上的链接列表,所以我正在迭代使用来自Tomahawk库的t:dataList标签在页面上输出它们。

/list.jsp

<f:view>
<h:form>
<t:dataList value="#{someBean.listOfNews}" var="news" >
<h:commandLink  value="edit" action="#{someBean.edit}">
        <f:setPropertyActionListener target="#{someBean.id}" value="#news.id}" />  
</h:commandLink>
</t:dataList>
</f:view>
</h:form>

正如您所看到的,我在托管bean中有一个“新闻”列表。但这并不重要。通过单击我想重定向到页面/add.jsp

的链接

面-config.xml中

<navigation-rule>
    <from-view-id>/list.jsp</from-view-id>
    <navigation-case>
        <from-outcome>edit</from-outcome>
        <to-view-id>/add.jsp</to-view-id>
        <redirect></redirect>
    </navigation-case>
</navigation-rule>

但我得到了这个例外:

java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:435)
at com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:572)
at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:178)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:126)
at org.apache.struts.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:137)
at javax.faces.component.UICommand.broadcast(UICommand.java:311)
at javax.faces.component.UIData.broadcast(UIData.java:912)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Unknown Source)

但如果我尝试不使用此标记,例如

<f:view>
<h:form>
<h:commandLink  value="edit" action="#{someBean.edit}">
        <f:setPropertyActionListener target="#{someBean.id}" value="1" />  
</h:commandLink><br>
<h:commandLink  value="edit" action="#{someBean.edit}">
        <f:setPropertyActionListener target="#{someBean.id}" value="2" />  
</h:commandLink>
</h:form>
</f:view>

它工作正常。如果我不在导航规则中使用标签,它也可以正常工作。任何人都可以解释这种不兼容性:dataList和redirect?

1 个答案:

答案 0 :(得分:0)

问题是我使用了tomahawk.jar的坏版本。现在我正在使用tomahawk20-1.1.10.jar,它运行得很好。