Panelmenuitem actions in binding bean not responding
aqueous Apr 11, 2008 4:17 AMHello all,
I am attempting to code a bean to render a panel menu and dynamically build groups and panelmenuitems. I have used one of the example jsp's I found and have been editing this to build my bean. The following represents that part of the example jsp with tags that I'm trying to code in my bean. I have tried many variations of the action but it doesn't seam to respond at all... the leftMenu.updateCurrent doesn't happen
eg.
<rich:panelMenuItem label="Item 1.2" action="#{leftMenu.updateCurrent}"
onclick="document.location.href='http://AqueousIt01:2345/aqueousIt.faces?chapter=chapter2'">
<h:outputLink value="http://AqueousIt01:2345/aqueousIt.faces?chapter=chapter2">
<h:outputText value="Chapter 2"></h:outputText>
</h:outputLink>
<f:param name="current" value="Item 1.2"/>
<f:param name="chapter" value="chapter2"/>
</rich:panelMenuItem>1) My last attempts failed because the action was not working.
2) I was having difficulty coding the output link,
3) And the parameters I'm just haven't registered as to how to code these...
My attempted code looks like this...
HtmlPanelMenuItem[] pMenuItms = (HtmlPanelMenuItem[]) Array.newInstance(HtmlPanelMenuItem.class,12);
MethodExpression[] pMenuEL = (MethodExpression[]) Array.newInstance(MethodExpression.class,12);
ValueExpression[] pMenuVE1 = (ValueExpression[]) Array.newInstance(ValueExpression.class,12);
for (int i = 0; i < 12; i++) {
System.out.println("Loop count: " + i);
pMenuItms = (HtmlPanelMenuItem) app.createComponent(HtmlPanelMenuItem.COMPONENT_TYPE);
pMenuItms.setName("B1Chapter" + (i+1));
pMenuItms.setId("B1Chapter" + (i+1));
pMenuItms.setLabel("Chapter " + (i+1));
pMenuItms.setOnclick("document.location.href='http://AqueousIt01:2345/aqueousIt.faces?chapter=chapter"+ (i+1) +"'");
pMenuEL = app.getExpressionFactory().createMethodExpression(FacesContext.getCurrentInstance().getELContext(),
"#{lpanMenu.updateCurrent}", null, new Class<?>[0]);
pMenuItms.setActionExpression(pMenuEL);
pMenuItms.setValueExpression("chapter",app.getExpressionFactory().createValueExpression("chapter"+ (i+1) ,String.class));
pMenuItms.setValueExpression("current",app.getExpressionFactory().createValueExpression("Item "+ (i+1) ,String.class));
pMenuVE1 = app.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "Item1.1", java.lang.String.class);
pMenuItms.setValueExpression("current",pMenuVE1);
pMenuVE1 = app.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(),"chapter", java.lang.String.class);
pMenuItms.addActionListener(new ActionListener(){ public void processAction(final ActionEvent event) {
System.out.println("process action: updateCurrent(event);");
LeftMenu lmb = (LeftMenu)event.getComponent().getAttributes().get("lpanMenu");
lmb.updateCurrent(event);
}
} );
pmg.getChildren().add(pMenuItms);
}
....
public String updateCurrent() {
FacesContext context=FacesContext.getCurrentInstance();
setCurrent((String)context.getExternalContext().getRequestParameterMap().get("current"));
setChapter((String)context.getExternalContext().getRequestParameterMap().get("chapter"));
return null;
}
public void updateCurrent(ActionEvent event) {
setCurrent(((UIPanelMenuItem)event.getComponent()).getLabel().toString());
setChapter(((UIPanelMenuItem)event.getComponent()).getLabel().toString());
}
If anyone could offer some advise it would be greatly appreciated.
I think I've got something really wrong...