-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi Everyone,
In my application i have a menu bar consisting of certain number of menu items, what i am doing is on click of menu item a tab and its panel must be added to the tabbox dynamically and the tab panel must be include with the zul file provided.
I tried with the code,
Window winTest=new Window();
Tab tab1 = new Tab();
Tabpanel tabp1 = new Tabpanel();
tab1.setLabel("Dynamic Tab");
tab1.setClosable(true);
tabadd.appendChild(tab1);
Include inc = new Include();
inc.setSrc("/Discount.zul");
winTest.setHeight("100%");
winTest.appendChild(inc);
tabp1.appendChild(wintest);
tabpanel.appendChild(tabp1);
tab1.setSelected(true);
by this source code i am able to add the tab and tab panel but am not able to include the zul file.
can any one specify what's wrong in the code or any other method by which i can get the solution.
Thanks.
Don't begin with include. Take the Executions.createComponents() to have the full acess to it.
Here are a method that opens a zul-file in a tab and checks if the tab is already opened. If so than select this tab.
Hope it can be useful.
best
Stephan
/** * Creates a page from a zul-file in a tab in the center area of the * borderlayout. Checks if the tab is opened before. If yes than it selects * this tab. * * @param zulFilePathName * The ZulFile Name with path. * @param tabName * The tab name. * @throws InterruptedException */ private void showPage(String zulFilePathName, String tabName) throws InterruptedException { try { // TODO get the parameter for working with tabs from the application // params int workWithTabs = 1; if (workWithTabs == 1) { /* get an instance of the borderlayout defined in the zul-file */ Borderlayout bl = (Borderlayout) Path .getComponent("/outerIndexWindow/borderlayoutMain"); /* get an instance of the searched CENTER layout area */ Center center = bl.getCenter(); // get the tabs component Tabs tabs = (Tabs) center.getFellow("divCenter").getFellow( "tabBoxIndexCenter").getFellow("tabsIndexCenter"); /** * Check if the tab is already opened than select them and<br> * go out of here. If not than create them.<br> */ Tab checkTab = null; try { // checkTab = (Tab) tabs.getFellow(tabName); checkTab = (Tab) tabs.getFellow("tab_" + tabName.trim()); checkTab.setSelected(true); } catch (ComponentNotFoundException ex) { // Ignore if can not get tab. } if (checkTab == null) { Tab tab = new Tab(); tab.setId("tab_" + tabName.trim()); tab.setLabel(tabName.trim()); tab.setClosable(true); tab.setParent(tabs); Tabpanels tabpanels = (Tabpanels) center.getFellow( "divCenter").getFellow("tabBoxIndexCenter") .getFellow("tabsIndexCenter").getFellow( "tabpanelsBoxIndexCenter"); Tabpanel tabpanel = new Tabpanel(); tabpanel.setHeight("100%"); tabpanel.setStyle("padding: 0px;"); tabpanel.setParent(tabpanels); /* * create the page and put it in the tabs area */ Executions .createComponents(zulFilePathName, tabpanel, null); tab.setSelected(true); } } else { /* get an instance of the borderlayout defined in the zul-file */ Borderlayout bl = (Borderlayout) Path .getComponent("/outerIndexWindow/borderlayoutMain"); /* get an instance of the searched CENTER layout area */ Center center = bl.getCenter(); /* clear the center child comps */ center.getChildren().clear(); /* * create the page and put it in the center layout area */ Executions.createComponents(zulFilePathName, center, null); } if (logger.isDebugEnabled()) { logger.debug("--> calling zul-file: " + zulFilePathName); } } catch (Exception e) { Messagebox.show(e.toString()); } }
@ terrytornado
Thanks for your reply, it worked for me,
By Clicking on menu item i am able to add a tab with the zul file included in it,
For first time it works fine, but when i close the tab and again oprn the same tab i get the following error,
"org.zkoss.zk.ui.UiException: Page is already covered by another Data Binder.
Cannot be covered by this Data Binder again. Page:z_ij_0"
The zul file which i am including consists of list box.
what must have gone wrong.
thanks for your time.
Dear Terrytornado,
I have tree navigation node at left which will come DB dyamically. On click of navigation node I have to create a new tab at right side with respective zul page. Here I am using Spring Web flow system to traverse the navigations with View-state id. To load the zul page in a tab I am using Include tag but this tag will take source a static zul page. How will I load the page from Spring Web flow controller dynamically.
Your help is really appreciated.
Regards,
Kishore
Asked: 2010-01-20 05:39:33 +0800
Seen: 2,992 times
Last updated: Jul 12 '10