我在通过按钮导航页面时遇到问题。
我当前的 xhtml 片段是这样的:
<p:layoutUnit position="west" size="200" header="Menü" resizable="true" closable="true" collapsible="true">
<p:column>
<p:commandButton type="button" value="New Project" icon="ui-icon-document" action="#{createProject.create()}"/>
<p:commandButton type="button" value="All Projects" icon="ui-icon-folder-open"/>
<p:commandButton type="button" value="Edit" icon="ui-icon-pencil"/>
<p:commandButton type="button" value="Delete" icon="ui-icon-closethick"/>
<p:separator />
<p:commandButton type="button" title="Yazdır" icon="ui-icon-print"></p:commandButton>
</p:column>
</p:layoutUnit>
在这里,当我单击新项目时,它不会导航到相关页面。
我的豆文件:
@ManagedBean
@RequestScoped
public class CreateProject {
/**
* Creates a new instance of CreateProject
*/
public String create() {
return "newproject.xhtml";
}
}
单击按钮时如何导航用户?
编辑:这是我的面孔配置
<faces-config
version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<managed-bean>
<managed-bean-name>loginBean</managed-bean-name>
<managed-bean-class>com.ibb.source.LoginBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>myProjects</managed-bean-name>
<managed-bean-class>com.ibb.source.MyProjects</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>myCalendar</managed-bean-name>
<managed-bean-class>com.ibb.source.MyCalendar</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/panel.xhtml</from-view-id>
<navigation-case>
<from-outcome>create</from-outcome>
<to-view-id>newproject.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>createProject</managed-bean-name>
<managed-bean-class>com.ibb.source.CreateProject</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>inPlaceEditor</managed-bean-name>
<managed-bean-class>com.ibb.source.InPlaceEditor</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>projectsList</managed-bean-name>
<managed-bean-class>com.ibb.source.ProjectsList</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>panel.xhtml</from-view-id>
<navigation-case>
<from-outcome>newproject</from-outcome>
<to-view-id>/newproject.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>allProjects</managed-bean-name>
<managed-bean-class>com.ibb.source.AllProjects</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>allProjectsList</managed-bean-name>
<managed-bean-class>com.ibb.source.AllProjectsList</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>