【问题标题】:t:dataList causes redirect problems in JSF (java.lang.IllegalStateException)t:dataList 导致 JSF 中的重定向问题 (java.lang.IllegalStateException)
【发布时间】:2011-04-04 14:42:27
【问题描述】:

我正在尝试编写简单的基于 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

的链接

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

它工作正常。如果我不在导航规则中使用标签,它也可以正常工作。谁能解释这种不兼容的 t:dataList 和重定向?

【问题讨论】:

    标签: jsf redirect


    【解决方案1】:

    问题是我使用了错误版本的 tomahawk.jar。现在我正在使用 tomahawk20-1.1.10.jar,它工作得很好。

    【讨论】:

    • 您正在使用 JSF 2.0?在 Facelets 上?你也可以使用&lt;ui:repeat&gt;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-14
    • 2012-12-12
    • 1970-01-01
    • 1970-01-01
    • 2011-01-12
    • 2011-07-01
    相关资源
    最近更新 更多