java - how to reload or refresh a tab's content base on actions in vaadin -


the content of tab formed , displayed when application loaded. later content of tab may changed other actions. want show newer content after each action. , each time when click tab sheet, content should refresh/updated. failed.

    //the content of tab "reprintstab" class     //in "reprintstab" query data database , print out     //later update data in database somewhere else, , want tab shows new content     //i want click tab sheet reload "reprinttab" class , print out new content      //here did:      public tabsheet sheet;      //add tab , add content "reprinttab" tab     sheet.addtab(new reprintstab());      //add listener      sheet.addlistener(new tabsheet.selectedtabchangelistener() {          @override         public void selectedtabchange(selectedtabchangeevent event) {          //i know not work, because reload class. not put content under tab want         new reprintstab();          }     }); 

what should do? please me, thanks.

you can use tabsheet.replacecomponent method this:

//field store current component private reprintstab currentcomponent;   //during initialization currentcomponent = new reprintstab(); sheet.addtab(currentcomponent);  sheet.addlistener(new tabsheet.selectedtabchangelistener() {     @override     public void selectedtabchange(selectedtabchangeevent event) {         reprintstab newcomponent = new reprintstab();         sheet.replacecomponent(currentcomponent, newcomponent);         currentcomponent = newcomponent;     } }); 

also, might want reload tab when it's shown:

sheet.addlistener(new tabsheet.selectedtabchangelistener() {         @override         public void selectedtabchange(selectedtabchangeevent event) {             if (event.gettabsheet().getselectedtab() == currentcomponent) {                 //here goes code             }         } }); 

this should work you, suggest cleaner approach: implement reprintstab container components, create method reload or buildinterface method refresh its' state, can call:

currentcomponent.reload(); 

when need update interface.

also, hope reprintstab example name, java class names starting lowercase letter ugly.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -