検索ボタンをクリックすると、index.xhtmlで結果のある別のページに移動しようとしています。私はprimefacesJSFを使用しています。
私の問題は、次のページに移動できないことです。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>