i am developing an application in which i have put menus which are rendered from mysql database i have inserted menus names and mappingIds into db table.
now i am getting problem how do i rendered list (list of menus) into xhtml(jsf html tags) currently i am using this
i have saved all menus in subMenuBeanList
and stored this list into Session
and then iterate(ui:repeat
) subMenuBeanList
into xhtml file where i want to get menus names(show menus names to the user) like this: h:commandLink value="#{subMenuBeanList.subMenuNameBean}"
and mappingId action="#{subMenuBeanList.subMenuLinkBean}"
see clear code below :
<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
here when i click on h:commandLink
i get this Exception
javax.el.MethodNotFoundException: /template/templateslider.xhtml @56,123 action="#{subMenuBeanList.subMenuLinkBean}": Method not found: com.hesco.repository.common.generalinformation.managed.bean.SubMenuBean@1a0974ce.subMenuLinkBean()
i know this subMenuLinkBean
is not a method its a variable in action(.java) class but here i put it into action="#{subMenuBeanList.subMenuLinkBean}"
thats why i am getting this exception..
my question is that how do i do this ? i want to get mappingId from Db not hard coded in any file
this is managed bean class
@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
this is an other class from where i am setting beans value
query
is fatched db records..
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