- 
        1. Re: create tree programmaticallynbelaevski Apr 1, 2009 1:02 PM (in response to elf)Hello, 
 You can find all necessary information in this class: org.richfaces.taglib.TreeListenersTagHandler
- 
        2. Re: create tree programmaticallyelf Apr 3, 2009 1:02 PM (in response to elf)Could you please provide me simple example how to use this class. 
 I can not find sample of using :(
- 
        3. Re: create tree programmaticallynbelaevski Apr 3, 2009 1:08 PM (in response to elf)It's easy. applyMetadata() method does exactly what you have to do creating component programmatically: return new Metadata() { public void applyMetadata(FaceletContext context, Object object) { MethodBinding binding = context.getFacesContext().getApplication().createMethodBinding(attribute.getValue(), new Class[] {NodeSelectedEvent.class}); ((UIComponent) object).getAttributes().put(NODE_SELECT_LISTENER, binding); } };
- 
        4. Re: create tree programmaticallyelf Apr 3, 2009 4:47 PM (in response to elf)I am so sorry. How can I use your example with my code. Please help me. HtmlTree tree = new HtmlTree(); tree.setId("MenuTreeId"); tree.setSwitchType("client"); tree.setStyle("min-height:100%; min-width:100%; width:100%"); tree.setReRender("selectedNode"); tree.setValueExpression("value", eF.createValueExpression(eC, "#{treebean.treeNode}", TreeNode.class) );
- 
        5. Re: create tree programmaticallynbelaevski Apr 3, 2009 6:25 PM (in response to elf)No problem. Try this: tree.getAttributes().put("nodeSelectListener", context.getFacesContext().getApplication().createMethodBinding("#{bean.method}", new Class[] {NodeSelectedEvent.class}));
- 
        6. Re: create tree programmaticallyelf Apr 5, 2009 2:28 AM (in response to elf)Please help me. What is wrong in my code: tree.getAttributes().put("nodeSelectListener", eF.createMethodExpression(eC, "#{treebean.processSelection}", null, new Class[] {NodeSelectedEvent.class}));
 and
 public void processSelection(NodeSelectedEvent event){
 I have java.lang.reflect.InvocationTargetException: argument type mismatch.
 What is the correct way to use this?
 Thanks in advance.
- 
        7. Re: create tree programmaticallynbelaevski Apr 5, 2009 5:07 AM (in response to elf)"nodeSelectListener" is of type MethodBinding and you use MethodExpression. Either switch to MethodBinding or create adaptor to adapt MethodExpression to FacesListener (see examples in JSF code) and use it. 
- 
        8. Re: create tree programmaticallyelf Apr 6, 2009 1:26 AM (in response to elf)It looks like work with FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{"treebean.processSelection}", new Class[] {NodeSelectedEvent.class})
 but FacesContext.getCurrentInstance().getApplication().createMethodBinding( is deprecated for my environment. Is it correct to use this code?
- 
        9. Re: create tree programmaticallynbelaevski Apr 6, 2009 4:25 AM (in response to elf)"nbelaevski" wrote: MethodBidning is deprecated, but left for back compatibility. You can use JSF 1.2 approach described here, so that you won't need MethodBinding.
 "... or create adaptor to adapt MethodExpression to FacesListener (see examples in JSF code) and use it.
- 
        10. Re: create tree programmaticallyelf Apr 6, 2009 5:30 AM (in response to elf)Could you please post simple example here how I can do it. 
- 
        11. Re: create tree programmaticallynbelaevski Apr 6, 2009 5:50 AM (in response to elf)Take a look at sources of javax.faces.event.MethodExpressionActionListener. Just replace Action* stuff with NodeSelect* stuff. The add created listener using addNodeSelectListener() 
- 
        12. Re: create tree programmaticallyelf Apr 6, 2009 8:34 AM (in response to elf)It works. 
 Thank you
- 
        13. Re: create tree programmaticallyelf Apr 8, 2009 10:40 AM (in response to elf)Is there way to put selection on particular node when tree is loading (loadTree method in livedemo http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf?tab=model&cid=3587377) ? 
 May be I should bind my tree to request bean or something else ?
 
    