0

我正在开发一个应用程序,我在其中放置了从 mysql 数据库呈现的菜单,我已将菜单名称和 mappingIds 插入到 db 表中。现在我遇到问题了如何将列表(菜单列表)呈现到 xhtml(jsf html 标签)中,目前我正在使用这个我已经保存了所有菜单subMenuBeanList并将这个列表存储到Session 然后迭代(ui:repeatsubMenuBeanList到我想要的 xhtml 文件中像这样获取菜单名称(向用户显示菜单名称):h:commandLink value="#{subMenuBeanList.subMenuNameBean}"mappingIdaction="#{subMenuBeanList.subMenuLinkBean}"请参见下面的清晰代码:

 <ui:repeat value="#{session.getAttribute('subMenuBeanList')}" var="subMenuBeanList">

<h:commandLink value="#{subMenuBeanList.subMenuNameBean}"   action="#{subMenuBeanList.subMenuLinkBean}" />  
// i want this <h:commandLink value="menu One Name" action="pretty:menuonemappingid" />
//<h:commandLink value="menu Two Name" action="pretty:menutwomappingid" />
// so on depending upon records in table
// closing tags

在这里,当我单击时,h:commandLink我得到了这个异常

javax.el.MethodNotFoundException: /template/templateslider.xhtml @56,123 action="#{subMenuBeanList.subMenuLinkBean}": Method not found: com.hesco.repository.common.generalinformation.managed.bean.SubMenuBean@1a0974ce.subMenuLinkBean()

我知道这subMenuLinkBean不是一个方法,它是 action(.java) 类中的一个变量,但在这里我把它放进去,action="#{subMenuBeanList.subMenuLinkBean}"这就是为什么我得到这个异常..

我的问题是我该怎么做?我想从 Db 中获取 mappingId,而不是硬编码在任何文件中

这是托管 bean 类

@ManagedBean(name="subMenuBean")
@ViewScoped
public class SubMenuBean implements Serializable {



    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private Integer subMenuIdBean;
    private Integer menuIdBean;
    private String subMenuNameBean;
    private String subMenuLinkBean;
    private String isActive;
    //jsf will not create nasted object, so that i create it like this.
    private MenuBean menuBean = new MenuBean();

    //private Set<Assigneduserrole> assigneduserroles = new HashSet<Assigneduserrole>(0);
    private ArrayList<SubMenuBean> subMenuBeanList = null;

///setter and getter

这是我设置bean值的另一个类,它 query是fatched db记录..

for (Iterator it = query.iterator(); it.hasNext();) {
                                    Object[] obj = (Object[]) it.next();

                                    log.info("assigning role by iterator");
                                    // adding Section Beans into ArrayList

                                    SubMenuBean subMenuBean = new SubMenuBean();
                                    subMenuBean.setSubMenuIdBean(((Submenu) obj[2]).getSubMenuId());
                                    subMenuBean.setSubMenuNameBean(((Submenu) obj[2]).getSubMenuName());
                                    subMenuBean.setSubMenuLinkBean(((Submenu) obj[2]).getSubMenuLink());
                                    subMenuBean.setMenuIdBean(((Submenu) obj[2]).getMenu().getMenuId());
                                    subMenuBean.setIsActive(((Submenu) obj[2]).getIsActive());
                                    this.subMenuBeanList.add(subMenuBean);

                                    log.info("Sub Menu List: " + this.subMenuBeanList.size());

                                } // ending of Object iterator
4

0 回答 0