JSF 2.0導航規則

You can use default mappings of outcomes to results pages. In the absence of explicit navigation rules, the return values of the action controller method correspond to the file names that should be used. Suppose that your form (file form.xhtml, URL form.jsf) says <h:commandButton ... action="#{someBean.someMethod}"/>. When the button is pressed, the bean named someBean is instantiated (assuming request scope), setter methods corresponding to the h:inputBlah elements are run, validation occurs, and then someMethod is executed. This is the same as in JSF 1.x, except that the managed bean name (someBean) can be derived from the bean class name (SomeBean). But now, if someMethod returns "foo" and "bar", and there are no explicit navigation rules in faces-config.xml for those outcomes, then JSF will assume that they correspond to foo.xhtml and bar.xhtml (from the same folder as form.xhtml), respectively. For example, in the this sample bean, the outcomes correspond toaccepted.xhtml and rejected.xhtml.

 

組件的action的綁定函數返回值(outcome)決定頁面導航,例如返回"foo"和"bar",先查找faces-config.xml裏是否有對應的navigation-rule,有則使用之,否則導航到返回值對應的頁面,即foo.xhtml/bar.xhtml.

 

 

Normally the return value of an action controller method determines the page navigation. But there is no navigation with

f:ajax: the original page is still displayed. So, the return value is irrelevant.

 

一般情況下action控制函數的返回字符串決定頁面導航,但是使用f:ajax時只會回顯原頁面,返回什麼值 沒多大關係。

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章