java ee - Change parent layout by child button on that layout -


i have problem change of tab panel layout click event on buton located on panel. main idea have custom menu (new, open, del) on smal panel on every tab panel. when click button, tab panel layout change form (for example). don't want use modal window or new window, change tab panel layout (content) else button click.

it, wrong specified question - should ask how notify parent component. bellow have 2 examples show how achive goals. first implementation jens janssons suggest on vaadin forum, pass clicklistener second panel constructor parameter. note able remove component outer panel, need both reference outer panel , inner panel. in example kim lappanen stored references in class variables. note ther used horizontallayout called "panel", can change it.

public class testcaseapplication extends application implements clicklistener {     private static final long serialversionuid = 75232258896642392l;      private final horizontallayout mainlayout = new horizontallayout();     private final yourpanel panel = new yourpanel(this);      @override     public void init() {         settheme("example");         window mainwindow = new window("playground application");         setmainwindow(mainwindow);          mainwindow.setcontent(mainlayout);          mainlayout.addcomponent(panel);     }      public void buttonclick(clickevent event) {         mainlayout.removecomponent(panel);     }      public class yourpanel extends panel {          public yourpanel(clicklistener listener) {             super();             addcomponent(new button("remove", listener));         }     } } 

antoher example implement clicklistener directly in inner panel. in buttonclick method, call getparent() (returns out layout) , removes layout.

public class testcaseapplication extends application {     private static final long serialversionuid = 75232258896642392l;      @override     public void init() {         settheme("example");         window mainwindow = new window("playground application");         setmainwindow(mainwindow);          horizontallayout mainlayout = new horizontallayout();         mainwindow.setcontent(mainlayout);          mainlayout.addcomponent(new yourpanel());     }      public class yourpanel extends panel implements clicklistener {          public yourpanel() {             super();             addcomponent(new button("remove", this));          }          public void buttonclick(clickevent event) {             ((componentcontainer) getparent()).removecomponent(this);         }     }  } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -