This content has been marked as final.
Show 2 replies
-
1. Re: Creating a non-deprecated rich:dropDownMenu dynamically
bp2s Jan 28, 2010 6:05 PM (in response to bp2s)This seems to have done it:
public HtmlDropDownMenu getNodeMenu()
{ HtmlDropDownMenu menu = new HtmlDropDownMenu(); menu.setValue( "Node Select" ); HtmlMenuItem menuItem = new HtmlMenuItem(); // TODO programmatically pass from getNodes into a String[] rather than an ArrayList of SelectItems String subOption = "myitem"; menuItem.setValue( subOption ); Application app = FacesContext.getCurrentInstance().getApplication(); MethodExpression methodExpression = app.getExpressionFactory().createMethodExpression( FacesContext.getCurrentInstance().getELContext(), "#{BackingBean.onItemClick}", null, new Class[] { ActionEvent.class }); menuItem.setActionExpression(methodExpression); menu.getChildren().add( menuItem ); return( menu ); } public void onItemClick( ActionEvent event ) { Object obj = event.getSource(); if( obj instanceof HtmlMenuItem ) { HtmlMenuItem item = (HtmlMenuItem)obj; if( item != null ) { lastItem = item.getValue().toString(); logger.info("lastItem selected is " + lastItem); } } }
-
2. Re: Creating a non-deprecated rich:dropDownMenu dynamically
bp2s Jan 28, 2010 6:06 PM (in response to bp2s)oh, and in your jsp:
<h:form> <rich:dropDownMenu binding="#{PrismBacking.nodeMenu}"> </rich:dropDownMenu> </h:form>