JSF+PrimeFaces跳转后不显示页面内容

夜色sdf 2012-12-06 10:12:27
通过redirect跳转是正常的,通过forward跳转出的错误。
用forward跳转后index.xml页面缺少了:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ,页面没有任何显示得刷新下才可以显示。

faces-config.xml配置

<navigation-rule>
<description>
task navigation rules
</description>
<from-view-id>/pages/main/login.xhtml</from-view-id>
<navigation-case>
<from-outcome>main</from-outcome>
<to-view-id>/pages/main/index.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>

java类

public String loginIndex(){

return "main";
}


index.xhtml


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/WEB-INF/template/common.xhtml">

<ui:define name="title">index</ui:define>
<ui:define name="head">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
*{
font-size:0.96em;
}
</style>
</ui:define>
<ui:define name="body">
<p:layout fullPage="true" >
<!-- 框架顶层 -->
<p:layoutUnit id="frmTop" position="north" size="92" style="padding:0px;">

</p:layoutUnit>

<p:layoutUnit id="frmBottom" position="south" size="25" style="width:100%;float:center;padding: 0px;">

</p:layoutUnit>

<!-- 左侧菜单 -->
<p:layoutUnit id="frmLeft" position="west" resizable="true" size="200" collapsible="true" header="应用系统菜单" minSize="100">

</p:layoutUnit>

<!-- 右侧布局栏 -->
<p:layoutUnit id="frmRight" position="east" header="Gallery" size="200" resizable="true" closable="true" collapsible="true" style="text-align:center;">

</p:layoutUnit>

<p:layoutUnit id="frmCenter" position="center" style="overflow:hidden;">

</p:layoutUnit>

</p:layout>

<p:dialog header="Basic Dialog" widgetVar="dlg1" modal="true">
<h:outputText value="Resistance to PrimeFaces is futile!" />
</p:dialog>
</ui:define>
</ui:composition>
</html>



login.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/WEB-INF/template/common.xhtml">
<ui:define name="title">用户登录</ui:define>
<ui:define name="body">
<h:form id="loginForm" >
<p:panel id="panel_a" style="width:#{parameters.screenWidth}px;height:#{parameters.screenHeight}px;">
<p:messages id="messages" closable="true"></p:messages>
<p:panel id="panel_b" header="test"
style="width:450px;height:250px;margin-top:#{parameters.marignTop}px;margin-left:#{parameters.marignLeft}px;">

<h:panelGrid>
<p:column>
<p:commandButton value="登录" update="panel_a" id="login"
icon="ui-icon-regedit" action="#{loginBean.loginIndex}"
styleClass="ui-priority-primary" />
<p:spacer style="width:10px;" />
<p:commandButton id="reset" type="reset" value="清空"
icon="ui-icon-cancel" styleClass="ui-priority-primary" />
</p:column>
</h:panelGrid>
</p:panel>
</p:panel>
</h:form>

</ui:define>
</ui:composition>
</html>
...全文
279 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
夜色sdf 2012-12-07
  • 打赏
  • 举报
回复
再顶下
夜色sdf 2012-12-07
  • 打赏
  • 举报
回复
自己顶下
夜色sdf 2012-12-06
  • 打赏
  • 举报
回复
高手快出来吧!配置文件错了,去掉 <redirect/>。如下: <navigation-rule> <description> task navigation rules </description> <from-view-id>/pages/main/login.xhtml</from-view-id> <navigation-case> <from-outcome>main</from-outcome> <to-view-id>/pages/main/index.xhtml</to-view-id> </navigation-case> </navigation-rule>

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧