-
FEATURED COMPONENTS
First time here? Check out the FAQ!
<?page id="memberpage" title="Member Registation" contentType="text/html;charset=UTF-8"?> <zk> <window id="winmember" border="normal" width="100%" height="100%" apply=""> <tabbox height="100%"> <tabs id="tabs"> <tab id="tabinfo" label="Information" /> <tab id="tabregister" label="Registration" /> </tabs> <tabpanels id="tabpanelsearch"> <tabpanel> <include src="/erp/first.zul"/> </tabpanel> <tabpanel id="tabpanelregister" > <include src="/erp/second.zul"/> </tabpanel> </tabpanels> </tabbox> </window> </zk>
<?page id="firstpage" title="" contentType="text/html;charset=UTF-8"?> <zk> <window id="winfirst" border="normal" apply="org.vts.erp.First"> <grid> <rows> <row> <label value="No" /> <textbox id="passno"/> </row> <row> <button id="next" label="next" /> <button label="cancel" /> </row> </rows> </grid> </window> </zk>
<?page id="secondpage" title="" contentType="text/html;charset=UTF-8"?> <zk> <window id="winsecond" border="normal" apply="org.vts.erp.Second"> <grid id="passgrid"> <rows> <row> <label value="No" /> <textbox id="passid"/> </row> <row> <label value="Name" /> <textbox id="nameid"/> </row> <row> <button id="nextsecond" label="next" /> <button label="cancel" /> </row> </rows> </grid> </window> </zk>
public class First extends GenericForwardComposer { public Second ss = new Second(); public Textbox passno; public Button next; public void onClick$next(Event event) throws Exception { final String no = passno.getText(); System.out.println("textbox val...."+passno.getText()); ss.setPassId(no); } }
public class Second extends GenericForwardComposer { public Textbox passid; public Button nextsecond; public void setPassId(final String no) throws Exception { //doAfterCompose(passid); //afterCompose(); System.out.println("Method is Call....."+no); passid.setText(no); } }
Your problem stems from the fact that First->ss is NOT the same Second that is referenced in second.zul's apply="org.vts.erp.Second". The apply in second.zul created a new instance of org.vts.erp.Second. So did public Second ss = new Second(); in First. So, they're two distinct instances. When First executes "ss.setPassId(no);", the passid that you're referencing in the last statement of setPassId(final String no) has not been initialized because the instance was created by you and not the ZK framework and thus your NPE.
Also, winfirst and winsecond are window's, so they're different id spaces. You'll probably have to forward an event from winfirst into winsecond.
Thanks caclark
Yes you are correct. There are tow distinct instances also winfirst and winsecond are window's, so they're different id spaces.
I have solve this problem.
Zul file as it is. Java file is change.
First.java
public class First extends GenericForwardComposer { public Second ss = new Second(); public Textbox passno; public Button next; public void doAfterCompose(Component win) throws Exception { super.doAfterCompose(win); } public void doRefresh() throws Exception { doAfterCompose(Path.getComponent("//firstpage/winfirst")); } public void onClick$next(Event event) throws Exception { final String no = passno.getText(); System.out.println("textbox val...."+passno.getText()); ss.setPassId(no); } }
Second.java
public class Second extends GenericForwardComposer { public Textbox passid; public Button nextsecond; public void doAfterCompose(Component win) throws Exception { super.doAfterCompose(win); } public void doRefresh() throws Exception { doAfterCompose(Path.getComponent("//secondpage/winsecond")); } public void setPassId(final String no) throws Exception { doRefresh(); passid.setText(no); } }
Try this. and if there is any problem in my code please post message.
@Kailas..
HI. .
Kailas I don't know actually how was your problem get resolved, but actually when I run your given code It still gives me that NULL POINTER EXCEPTION. DON'T know what's their the problem.
Can you plz help me to solve that..
@Kailas
thanx for your help but my problem not solved and it throws me another error.
Failed to assign [id=retailers_win] to <Window z_fnr_r7> Not unique in ID space [Page tra]: retailers_win
my filter_bar.zul page is
<window border="normal" id="filter_bar" class="main_bg" apply="${baseController}"> <div class="textalign1" style="height:30px;"> <div style="float:left;" class="style_a5 select_service"></div> <div class="textalign2 combo"> Brand :<listbox id="lbox_service" width="120px" mold="select" multiple="false" rows="1"> <listitem self="@{each=each1}" label="@{each1.serviceName}" value="@{each1.serviceId}"/> </listbox> </div> <div class="style_a5 select_service2" style="margin-left:35px;" ></div> <div style="float:left; margin-left:5px;"> <div id="div_seasons" class="combo"> Season :<listbox id="lbox_season" width="120px" mold="select" multiple="false" rows="1" > <listitem self="@{each=each1}" label="@{each1.season}" value="@{each1.seasonId}" /> </listbox> </div> </div> <div class="style_a5 select_service2" style="margin-left:35px;" ></div> <div style="float:left; margin-left:5px;"> <div id="div_refresh"> Period :<textbox id="period1"></textbox> <button id="ref" label="Ref"></button> </div> </div> <div class="style_a5 select_service2" style="margin-left:35px;" ></div> <div style="float:left; margin-left:5px;"> <div class="combo"> Month From :<listbox id="monthFrom" width="120px" mold="select" multiple="false" rows="1"> </listbox> Year From :<listbox id="yearFrom" width="120px" mold="select" multiple="false" rows="1" > </listbox> Month To :<listbox id="monthTo" width="120px" mold="select" multiple="false" rows="1" > </listbox> Year To :<listbox id="yearTo" width="120px" mold="select" multiple="false" rows="1" > </listbox> </div> </div> </div> </window>
and the controller for the filter_bar.zul is baseController.java that has on onClick$ref that will get the value from my filter bar and that has a code
public void onClick$ref(Event event){ //this.setPeriod(); final Map<String, Object> map = new HashMap<String, Object>(0); map.put("service_id",this.getService_id() ); map.put("season_id", this.getSeason_id() ); final Window win = (Window)Executions.createComponents("tradition.zul", null, map); }
and then my tradition.zul page load that has having controller Traditional_retailers
<zk> <?page id="tra" title="Traditional" contentType="text/html;charset=UTF-8"?> <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="retailers_win"?> <?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?> <include src="filter_bar.zul" /> <window border="normal" id="retailers_win" class="main_bg" apply="${traditionalRetailer1}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"> <div id="product_table" align="left" width="100%" height="100%"> <listbox id="retailer" fixedLayout="true" model="@{controller.TDRetailers}" > <attribute name="onSelect"> <![CDATA[ Messagebox.show(self.getSelectedItem().getChildren().get(0).getLabel()); //Messagebox.show("Selected Value : " + self.getSelectedItem().getLabel()+", "+ self.getSelectedItem().getChildren().get(2).getLabel()); ]]> </attribute> <listhead> <listheader label="Store Name" width="18%" align="left" /> <listheader label="Country" width="14%" align="left"/> <listheader label="City" width="14%" align="left"/> <listheader label="Auth. OK" width="10%" align="center"/> <listheader label="Info. OK" width="10%" align="center"/> <listheader label="Auth. KO" width="10%" align="center"/> <listheader label="Info. KO" width="10%" align="center"/> <listheader label="Auth. Fakes" width="10%" align="center"/> <listheader label="Unq. Invalid" width="10%" align="center"/> </listhead> <listitem self="@{each=each1}" > <listcell visible="false" label="@{each1.verification_store_id}"></listcell> <listcell label="@{each1.store_name}" /> <listcell label="@{each1.country}" /> <listcell label="@{each1.city_name}" /> <listcell label="@{each1.auth_ok}" /> <listcell label="@{each1.info_ok}" /> <listcell label="@{each1.auth_ko}" /> <listcell label="@{each1.info_ko}" /> <listcell label="@{each1.auth_fakes}" /> <listcell label="@{each1.unique_invalid}" /> </listitem> </listbox> <label value="${args.service_id}"></label> <label value="${args.season_id}"></label> </div> </window> </zk>
my traditional_retailer.java file having doAfterCompose code is below
@Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); EventQueues.lookup("myEventQueue", EventQueues.DESKTOP, true) .subscribe(new EventListener() { public void onEvent(Event event) throws Exception { /*String service = (String) event.getData(); logger.info("Servive $$$$$$$$$ " + service); //String season = (String) event.getData(); //logger.info("Season $$$$$$$$$ " + season);*/ /*if("service_id".equals(event.getName())) { System.out.println("service_id_select :" +event.getData()); setService_id((String) event.getData()); baseController.setFilterChanged("true"); System.out.println("Service Id :" +event.getData()); }*/ if("season_id".equals(event.getName())) { setSeason_id((String) event.getData()); baseController.setFilterChanged("true"); System.out.println("Season Id :" +event.getData()); } logger.info("filter change : " +baseController.getFilterChanged()); if(baseController.getFilterChanged().equals("true")) { String order = "2"; List TDRetailers = verificationStoreHibernateDao.getTraditionalRetailers(getService_id(), getSeason_id(),dateFrom, dateTo, order); //VerificationStoreHibernateDao storeHibernateDao = new VerificationStoreHibernateDao(); //List TDRetailers = this.verificationStoreHibernateDao.getTraditionalRetailers(service_id); //ListModel listModel = this.retailers.getModel(); ListModelList listModelList = (ListModelList) retailer.getModel(); listModelList.clear(); listModelList.addAll(TDRetailers); } } });
but when i Click the refresh button of the baseController it show's me the error
Failed to assign [id=retailers_win] to <Window z_fnr_r7> Not unique in ID space [Page tra]: retailers_win
and also I don't know how to get my passed value in my traditional controller class
Asked: 2010-04-27 03:33:10 +0800
Seen: 3,485 times
Last updated: Mar 02 '11