richpanel menu selected query
jsfgeeks Mar 17, 2010 8:35 AMhello,
i have developed rich:panlemenu dynamically from java bean.
my bean is in session scope.
<rich:panelMenu width="255px" iconGroupPosition="right" selectedChild="#{contentlist.current}" expandSingle="true" binding="#{contentlist.phymenu}" id="phymenu" expandMode="ajax" iconExpandedTopGroup="chevronUp" iconCollapsedTopGroup="chevronDown">
</rich:panelMenu>
//java
if (con != null && rs_tpview != null) {
while (rs_tpview.next()) {
if (rs_tpview.isFirst()) {
current_std = rs_tpview.getInt("id");
}
if (null == phymenu) {
phymenu = (HtmlPanelMenu) app.createComponent(HtmlPanelMenu.COMPONENT_TYPE);
}
HtmlPanelMenuGroup pnlgrpstd = (HtmlPanelMenuGroup) app.createComponent(HtmlPanelMenuGroup.COMPONENT_TYPE);
pnlgrpstd.setId("pnlmenugrp" + rs_tpview.getString("id"));
pnlgrpstd.setLabel(rs_tpview.getString("name"));
sel_chap = "SELECT * FROM table3 where lang_id='" + langcode + "' and subject_field_Id=" + current_subject + " and prev_table_id=" + rs_tpview.getInt("id") + " and final=1 order by content_index";
rs2_tpview = stmt1_tpview.executeQuery(sel_chap);
if (con != null && rs2_tpview != null) {
while (rs2_tpview.next()) {
if (rs_tpview.isFirst() && rs2_tpview.isFirst()) {
current = rs2_tpview.getObject("id");
}
if (rs2_tpview.isFirst()) {
UIParameter pnlstdpara = (UIParameter) app.createComponent(UIParameter.COMPONENT_TYPE);
pnlstdpara.setId("pnlmenuitmfprmchap" + rs2_tpview.getString("id"));
pnlstdpara.setName("std_curr_1stchap");
pnlstdpara.setValue(rs2_tpview.getString("id"));
// //System.out.println(rs_tpview.getString("id") + ": valueeee: " + rs2_tpview.getString("id"));
pnlgrpstd.getChildren().add(pnlstdpara);
}
HtmlPanelMenuItem phymenuitmchap = (HtmlPanelMenuItem) app.createComponent(HtmlPanelMenuItem.COMPONENT_TYPE);
phymenuitmchap.setLabel(rs2_tpview.getString("name"));
phymenuitmchap.setId("pnlmenuitm" + rs2_tpview.getString("id"));
phymenuitmchap.setName(rs2_tpview.getString("id"));
UIParameter pnlchappara = (UIParameter) app.createComponent(UIParameter.COMPONENT_TYPE);
pnlchappara.setId("pnlmenuitmfprm" + rs2_tpview.getString("id"));
pnlchappara.setName("current");
pnlchappara.setValue(rs2_tpview.getString("id"));
phymenuitmchap.getChildren().add(pnlchappara);
phymenuitmchap.setReRender("outpnl");
phymenuitmchap.setMode("ajax");
Class[] params = {};
MethodExpression actionExpression = app.getExpressionFactory().createMethodExpression(ctx.getELContext(), "#{contentlist.chapterlist_action}", String.class, params);
phymenuitmchap.setActionExpression(actionExpression);
pnlgrpstd.setReRender("pnl_stchlst,outpnl");
phymenuitmchap.setReRender("outpnl");
pnlgrpstd.getChildren().add(phymenuitmchap);
}
}
Class[] params1 = {};
MethodExpression actionExpression1 = app.getExpressionFactory().createMethodExpression(ctx.getELContext(), "#{contentlist.std_action}", String.class, params1);
pnlgrpstd.setActionExpression(actionExpression1);
pnlgrpstd.setReRender("pnl_stchlst");
pnlgrpstd.setExpandMode("ajax");
pnlgrpstd.setExpanded(true);
phymenu.getChildren().add(pnlgrpstd);
}
}
public void chapterlist_action() {
FacesContext context = FacesContext.getCurrentInstance();
//System.out.println("new Value: " + context.getExternalContext().getRequestParameterMap().get("current"));
int value = Integer.parseInt(context.getExternalContext().getRequestParameterMap().get("current"));
//populate topics
session.setAttribute("current", current);
populate_topic(value);
if (session.getAttribute("Usertype") != null && session.getAttribute("Usertype").toString().length() > 0) {
populate_external_topic(Integer.toString(value));
}
}
public void std_action() {
FacesContext context1 = FacesContext.getCurrentInstance();
//System.out.println("std value : " + context1.getExternalContext().getRequestParameterMap().get("std_curr_1stchap"));
current = context1.getExternalContext().getRequestParameterMap().get("std_curr_1stchap");
// MenuState ms = new MenuState();
// current = current_std;
// ms.setSelectedMenuItem(current_std.toString());
// ms.
session.setAttribute("current", current);
populate_topic(Integer.parseInt(current.toString()));
if (session.getAttribute("Usertype") != null && session.getAttribute("Usertype").toString().length() > 0) {
populate_external_topic(current.toString());
}
}
now, my problem is that when u click on patricular menu item it's get selected and it's color gets changed,nut when i click on menu group i want to set selected first menu item of that menu group any idea?