-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, everyone.
I'm having an error with the path of my zul file. This is my code:
package com.siger.main.control.zk; import org.zkoss.zk.ui.ComponentNotFoundException; import org.zkoss.zk.ui.Components; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.ext.AfterCompose; import org.zkoss.zul.Center; import org.zkoss.zul.Messagebox; import org.zkoss.zul.Tab; import org.zkoss.zul.Tabpanel; import org.zkoss.zul.Tabpanels; import org.zkoss.zul.Tabs; import org.zkoss.zul.Window; public class PessoaTabController extends Window implements AfterCompose, TabController { public void afterCompose() { Components.wireVariables(this, this); Components.addForwards(this, this); } /** * */ private static final long serialVersionUID = 1L; private Center pessoa_center; public void onCreate$pessoa_window() throws InterruptedException { showPage("/view/atores/tabs/pessoa/cards/pessoaCard.zul", "pessoaCard"); } public void onClick$btn1(Event event) throws InterruptedException { showPage("/view/atores/tabs/pessoa/cards/pessoaCard.zul", "pessoaCard"); } public void showPage(String zulFilePathName, String tabName) throws InterruptedException { try { // get the tabs component Tabs tabs = (Tabs) pessoa_center.getFellow("pessoa_div").getFellow( "pessoa_tabbox").getFellow("pessoa_tabs"); /** * Check if the tab is already opened than select them and<br> * get out of here. If not than create them.<br> */ Tab checkTab = null; try { 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) pessoa_center.getFellow( "pessoa_div").getFellow("pessoa_tabbox").getFellow( "pessoa_tabs").getFellow("pessoa_tabpanels"); 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); tab.setVisible(false); } } catch (Exception e) { Messagebox.show(e.toString()); } } }
My problem is: although my zulFilePathName is correct, when it tries to run, returns a nullpointerException. I use similar code in other files and it work perfectly. Does anyone now how can i get the real path of my pessoa card, and pass it in my method showPAge() ?? thanks a lot.
Hi, wrt2k4, thanks.
i tried your solution, and he returns the following Exception:
org.zkoss.zk.ui.UiException: Page not found: /view/D:\Workspace\siger\view\atores\tabs\pessoa\cards\pessoaCard.zul
but the path D:\Workspace\siger\view\atores\tabs\pessoa\cards\pessoaCard.zul is the location im my HD.
Any suggestion?
thanks
You'll need to use absolute paths:
sc.getRealPath("/view/atores/tabs/pessoa/cards/pessoaCard.zul");
Cheers, Maik
Hi nilsonhp, would you please show me how to solve your problem?. Thanks
Hello ilovedongri,
The most possible solution that nilsonhp used was to refactor the folders of his project in order to be accessed correctly.
If you still have the same issue please post your project's directory structure and mention the source->target pages you want to connect.
Best Regards,
Darksu
Asked: 2011-05-04 22:29:46 +0800
Seen: 501 times
Last updated: Aug 30 '15