當我點擊搜索按鈕,我試圖讓我的index.xhtml帶我到另一個頁面w /結果。我正在使用primefaces JSF。JSF導航案例不導航
我的問題是,我不能讓它去下一頁。它調用我的searchController beans findItem方法,但結果頁面不會改變。它只停留在index.xhtml頁面上。
任何人有想法嗎?
@ManagedBean(name="sController")
@RequestScoped
public class SController implements Serializable {
private static final long serialVersionUID = 1L;
public SController() { }
public String findItem() {
System.out.println("findItem called!");
return "success";
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
這是我的faces-config.xml。
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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"
version="2.0">
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-action>#{sController.findItem}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/items.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
而這裏是我的index.xhtml。
<f:view>
<h:form>
<p:panel id="search" header="Search Item">
<p:panelGrid columns="2" cellpadding="5">
<h:outputLabel value="Name" for="name"/>
<p:inputText id="name" value="#{sController.name}"/>
</p:panelGrid>
</p:panel>
<p:commandButton value="Search"
actionListener="#{sController.findItem}"/>
</h:form>
</f:view>
我只是發現了隱式導航和現在的工作。所以我刪除了我的faces-config.xml文件。 – Ender