这是我的xhtml
page.sorting = count
这是我的豆子
<h:form>
<p:growl id="messages" showDetail="false"/>
<p:menubar>
<p:submenu label="Report" icon="ui-icon-arrowreturnthick-1-e">
<p:submenu label="User Management" icon="ui-icon-arrowreturnthick-1-e">
<p:menuitem value="Full Report" url="/secured/report/reportList.xhtml" icon="ui-icon-arrowreturnthick-1-e" />
<p:menuitem value="Generate Report" url="/secured/report/generateReport.xhtml" icon="ui-icon-arrowreturnthick-1-e" />
</p:submenu>
<p:submenu label="Service Management" icon="ui-icon-arrowreturnthick-1-e">
<p:menuitem value="Full Report" url="/secured/report/reportList.xhtml" icon="ui-icon-arrowreturnthick-1-e" />
<p:menuitem value="Generate Report" url="/secured/report/generateReport.xhtml" icon="ui-icon-arrowreturnthick-1-e" />
</p:submenu>
</p:submenu>
<p:menu model="#{menuModelBean.model}">
</p:menu>
</p:menubar>
</h:form>
}
这是错误。我正在使用primeface 5.1。
package com.bat.qpa.beans;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import org.primefaces.model.menu.DefaultMenuItem;
import org.primefaces.model.menu.DefaultMenuModel;
import org.primefaces.model.menu.DefaultSubMenu;
import org.primefaces.model.menu.MenuModel;
@ManagedBean(name = "menuModelBean")
public class MenuModelBean {
private MenuModel model = new DefaultMenuModel();
@PostConstruct
public void init() {
model = new DefaultMenuModel();
//First submenu
DefaultSubMenu firstSubmenu = new DefaultSubMenu("Dynamic Submenu");
DefaultMenuItem item = new DefaultMenuItem("External");
item.setUrl("http://www.primefaces.org");
item.setIcon("ui-icon-home");
firstSubmenu.addElement(item);
model.addElement(firstSubmenu);
//Second submenu
DefaultSubMenu secondSubmenu = new DefaultSubMenu("Dynamic Actions");
item = new DefaultMenuItem("Save");
item.setIcon("ui-icon-disk");
item.setCommand("#{menuView.save}");
item.setUpdate("messages");
secondSubmenu.addElement(item);
item = new DefaultMenuItem("Delete");
item.setIcon("ui-icon-close");
item.setCommand("#{menuView.delete}");
item.setAjax(false);
secondSubmenu.addElement(item);
item = new DefaultMenuItem("Redirect");
item.setIcon("ui-icon-search");
item.setCommand("#{menuView.redirect}");
secondSubmenu.addElement(item);
model.addElement(secondSubmenu);
}
public MenuModel getModel() {
return model;
}
public void setModel(MenuModel model) {
this.model = model;
}
public String openAction() {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Open action has activiated asynchrounsly !"));
return "";
}
我想使用托管bean创建一个Programmatic菜单。第一部分是我的xhtml页面,第二部分是Managed Bean,第三部分是error.I已搜索,但我找不到这样的任何错误。 我在Primefaces网站演示中遵循的方式。但得到错误。为什么呢?