hi,

i am new in myfaces and beans and try to find out how i can pass arguments
with cerateMethodeBinding.
my bean adds some commandLink commponents to the view and each action of the
commandLink commponent points back to the bean. So far it works, but i would
like to detect with commandLink commponent was clicked. I tried with arrays
like...

DummyModel.getDummyItems()[1].doSomeThing(); --> #{DummyBean.???}

Does that works or are i total wrong?

Is there another workaround to solve this problem?

Thanks!
regards,
Hanspeter

Ex.:

public class DummyModel {
        
        private List _listItems; 
        
        public DummyModel() {
                _listItems = new ArrayList();
                _listItems.add(new MenuNode("Node 1", 0));
                _listItems.add(new MenuNode("Node 2", 1));
                _listItems.add(new MenuNode("Node 3", 2));
                _listItems.add(new MenuNode("Node 4", 3));
                
        }
        
        public MenuNode[] getDummyItems()
        {
                if (_listItems == null) return new MenuNode[0];
                return (MenuNode[]) _listItems.toArray(new
MenuNode[_listItems.size()]);
        }
        
        public void doAction() {
                System.out.println("ok");
        }
}

public class DummyNode {
        
        private HtmlCommandLink linkItem;
        
        public HtmlCommandLink getHtmlCommandLink() {
                return linkItem;
        }
        
        public void doSomeThing() {
                System.out.println("doSomeThing in DummyNode ");
        }
        
        public DummyNode(String text, int index) {
                linkItem = new HtmlCommandLink();
                HtmlOutputText textItem = new HtmlOutputText();
                textItem.setValue(text);
                linkItem.getChildren().add(textItem);
                FacesContext context = FacesContext.getCurrentInstance();

                MethodBinding mb =
context.getApplication().createMethodBinding("#{DummyBean.doAction}", null);
                linkItem.setAction(mb);
        }
}


Reply via email to