命令按钮上的JSF导航
我想有条件地导航到某个页面。如果某个条件为真,我希望导航到其他页面,否则我希望保持在同一页面上。我有点像:-命令按钮上的JSF导航,jsf,Jsf,我想有条件地导航到某个页面。如果某个条件为真,我希望导航到其他页面,否则我希望保持在同一页面上。我有点像:- <h:commandButton action="#{bean.navigate}"/> public String navigate(){ if(value <= 0) return "helloWorld"; else return ""; } 在bean.navigate中,我有如下内容:- <h:co
<h:commandButton action="#{bean.navigate}"/>
public String navigate(){
if(value <= 0)
return "helloWorld";
else
return "";
}
在bean.navigate中,我有如下内容:-
<h:commandButton action="#{bean.navigate}"/>
public String navigate(){
if(value <= 0)
return "helloWorld";
else
return "";
}
公共字符串导航(){
如果(值您需要如下导航规则:
<navigation-rule>
<from-view-id>/firstpage.xhtml</from-view-id>
<navigation-case>
<from-outcome>helloWorld</from-outcome>
<to-view-id>/successPage.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<to-view-id>/failPage.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
/firstpage.xhtml
地狱世界
/successPage.xhtml
/failPage.xhtml
如果您想停留在同一页面,需要返回null
。这些导航规则是必要的吗?我没有使用任何导航xml文件,仍然可以导航到不同的页面。我使用的是JSF 2.0