我正在寻找另一种JSF
导航方式,而不是提到导航案例faces-config.xml
.
目前我正在使用faces-config.xml
导航.我想清理它.
请建议所有其他方式,以便我可以使用任何适合我的需要.
我需要2.xhtml
在当前 JSF 页面(例如1.xhtml
)的新选项卡中打开一个新的JSF 页面(例如)。我应该使用哪个 JSF 组件?<h:commandLink>
或者<h:outputLink>
?
1.xhtml
单击链接以2.xhtml
在新选项卡中打开后,我不想失去当前页面的范围。
的豆1.xhtml
是@ViewScoped
。我应该把它改成@RequestScoped
吗?
我正在使用JSF 2.0
这是我的faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file is not required if you don't need any extra configuration. -->
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<navigation-rule>
<from-view-id>/pages/test/test.html</from-view-id>
<navigation-case>
<from-outcome>write</from-outcome>
<to-view-id>/pages/test/test-write.html</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Run Code Online (Sandbox Code Playgroud)
TestController.java
@ManagedBean(name="testController")
@SessionScoped
public class TestController implements Serializable {
private static final long serialVersionUID = -3244711761400747261L;
public String test() {
return "write?faces-redirect=true";
}
Run Code Online (Sandbox Code Playgroud)
在我的test.xhtml文件中
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="/WEB-INF/templates/default.xhtml">
<ui:define name="content">
<h:form>
<h:commandButton action="#{testController.test()}" value="test" />
</h:form>
</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
这是我的web.xml
<web-app …
Run Code Online (Sandbox Code Playgroud) 我遇到以下情况:
场景:
在搜索时,支持bean会抛出异常,因为有很多null
值.原因是,当他们按下"搜索"时,页面处于RESTORE_VIEW
同步状态.
我尝试在页面上禁用缓存,强制用户刷新后退按钮上的页面,但是很多用户抱怨"为什么我不能使用后退按钮,我之前可以做到!" 由于他们认为应用程序在"确认表单重新提交"页面chrome/IE/Firefox show中崩溃,导致帮助台门票,因此管理人员希望我寻找替代方案.
我的问题:
可以检测RESTORE_VIEW的当前Phase_ID,而不是在此阶段进行任何处理以避免异常,但仅此一点,只需重新调整即可为用户提供部分页面视图.是否可以RENDER_RESPONSE
在此方案中放入页面然后进行处理?这应该刷新页面.
由于推荐(或普通/良好)实用是禁用动态页面上的缓存,我已经这样做了,并且必须重新教育顽固的用户.
但是我有以下问题.
当按下具有禁用缓存的页面上的"返回"按钮时,浏览器会显示"确认表单重新提交"(chrome),用户可以按Refresh / F5
或Enter
键.
如果Refresh/ F5
是动作,一切都可以,我检测到RESTORE_VIEW
相位并避免在该阶段中进行任何处理并让处理在RENDER_RESPONSE
阶段完成.但是,如果Enter
按下,则PhaseID处于,RENDER_RESPONSE(6)
但是几个下拉控件的值为null,这会导致页面失败.所以我进行检查以检测这些情况并显示FaceMessage以告诉用户刷新页面.
问题是,我可以强制页面刷新而不是强制用户这样做吗?此页面的导航案例格式为:
<navigation-rule>
<navigation-case>
<from-outcome>/app/ord/r1</from-outcome>
<to-view-id>/jsp/ordersHistory.jsp</to-view-id>
</navigation-case>
</navigation-rule>
Run Code Online (Sandbox Code Playgroud)
我已经看到在线代码片段faces-redirect=true
用于强制重新加载页面,但我无法让它工作!有什么建议?
jsf ×4
jsf-2 ×2
navigation ×2
faces-config ×1
java ×1
java-ee-6 ×1
jsf-1.2 ×1
new-window ×1
view-scope ×1