导航案例扩展

时间:2013-08-23 19:23:39

标签: jsf jsf-2 websphere-7 icefaces-3

我正在尝试导航到静态Web项目中的xhtml页面。我的原始上下文是一个带有icefaces 3.3的动态Web项目。即使我在.faces中将.xhtml指定为结果,它也会使用to-view-id重定向到以下路径。有没有办法让它重定向到.xhtml呢?

http://localhost:9080/staticWebRoot/logout.faces

面-navigation.xml

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
    <from-outcome>logout</from-outcome>
    <to-view-id>/../../staticWebRoot/logout.xhtml</to-view-id>
    <redirect/>     
    </navigation-case>
</navigation-rule>

1 个答案:

答案 0 :(得分:2)

您可以而且不应该对非JSF资源使用导航规则。 JSF假设所有to-view-id都是当前webapp中的真实JSF视图(否则,它们首先不会被称为“视图ID”)。

只需使用ExternalContext#redirect()

public void redirect() throws IOException {
    // ... 
    FacesContext.getCurrentInstance().getExternalContext().redirect("/staticWebRoot/logout.xhtml");
}