-
FEATURED COMPONENTS
First time here? Check out the FAQ!
i want to select a row from a listbox (which is in AOlist.zul)
and when i click the button edit the selected row will be showning in EditAO.zul
index.zul
<window id="win" border="none" height="100%" > <tabbox id="tb" height="100%" > <tabs> <tab label="Appel" id="ao" /> <tab label="Portail" id="portail" visible="false"/> </tabs> <tabpanels id="pp" > <tabpanel id="aop" style="overflow:scroll;position:relative;text-align:center"> <include src="AoList.zul" id="include" /> </tabpanel> <tabpanel id="portailp" style="overflow:scroll;position:relative;text-align:center"> <include src="portail.zul" id="include5" /> </tabpanel> </tabpanels> </tabbox> </window>
AoList.zul
<window id="aolist" apply="com.loool.controleur.AOControleur" title="new page title" border="normal"> <button id="edit" image="/images/clipboard-24.png" tooltip="modifier" > <attribute name="onClick"> <![CDATA[ ((Include)edit.getDesktop().getPage("admin").getFellow("win").getFellow("tb").getFellow("include")).setSrc("EditAO.zul"); ]]> </attribute> </button> <listbox id="box" multiple="true" rows="5" model="@{aolist$composer.allAppelOffres}" selectedItem="@{aolist$composer.current}"> <listhead> <listheader label="numero" width="30%" /> <listheader label="intitulé" /> <listheader label="objet" width="20%"/> </listhead> <listitem self="@{each='event'}" value="@{event}"> <listcell label="@{event.num}" /> <listcell label="@{event.intitule}" /> <listcell label="@{event.objet}" /> </listitem> </listbox> </window>
AOControleur.java
Spublic class AOControleur extends GenericForwardComposer { private static final long serialVersionUID = -9145887024839938515L; ApplicationContext appContext = new ClassPathXmlApplicationContext("application-context.xml"); IEntiteDao service = (IEntiteDao) appContext.getBean("hibernateNonIntrusiveHibernateDao"); AppelOffre a = new AppelOffre(); AppelOffre current = new AppelOffre(); Grid aogrid; Grid aogridce; Listbox box; public AppelOffre getCurrent() { return current; } public void setCurrent(AppelOffre current) { this.current = current; } public List getAllAppelOffres() { return service.getAllEntites(a); }
EditAO.zul
<window id="editao" title="Modifier Appel d'offre" apply="com.loool.controleur.AOControleur" style="text-align:left" width="80%" border="normal"> <grid> <columns> <column label="" width="20%"/> <column label=""/> <column label="" width="20%"/> </columns> <rows> <row > <label value="Numero :" width="150px" /> <hlayout> <textbox value="@{editao$composer.current.num}" id="num" width="150px" tabbable="true" /> </hlayout> <hlayout> <label sclass="hightlight">commentaire</label> </hlayout> </row> <row> <label value="Intitulé :" width="150px" /> <hlayout> <textbox id="itl" value="@{editao$composer.current.intitule}" width="100%" rows ="2" tabbable="true" /> </hlayout> <hlayout> <label sclass="hightlight">commentaire</label> </hlayout> </row> <row> <label value="Objet :" width="150px" /> <hlayout> <textbox id="obj" value="@{editao$composer.current.objet}" width="100%" tabbable="true" /> </hlayout> <hlayout> <label sclass="hightlight">commentaire</label> </hlayout> </row> <row> <cell colspan="3" style="text-align:center"> <button id="sauvegarder" label="Sauvegarder" width="100px" > </button> <button id="annuler" label="Annuler" width="100px" > </button> </cell> </row> </rows> </grid> </window>
so what is wrong with this code??
i have change AOList.zul and AOcontrolleur to :
AOList.zul
<?page title="new page title" contentType="text/html;charset=UTF-8"?> <zk> <window id="aolist" apply="com.loool.controleur.AOControleur" title="new page title" border="normal"> <button id="edit" image="/images/clipboard-24.png" tooltip="modifier" /> <listbox id="box" multiple="true" rows="5" model="@{aolist$composer.allAppelOffres}" selectedItem="@{aolist$composer.current}"> <listhead> <listheader label="numero" width="30%" /> <listheader label="intitulé" /> <listheader label="objet" width="20%"/> </listhead> <listitem self="@{each='event'}" value="@{event}"> <listcell label="@{event.num}" value="@{eaolist$composer.current.num}" /> <listcell label="@{event.intitule}" value="@{aolist$composer.current.intitule}" /> <listcell label="@{event.objet}" value="@{aolist$composer.current.objet}"/> </listitem> </listbox> </window> </zk>
AOControlleur
public class AOControleur extends GenericForwardComposer { private static final long serialVersionUID = -9145887024839938515L; ApplicationContext appContext = new ClassPathXmlApplicationContext("application-context.xml"); IEntiteDao service = (IEntiteDao) appContext.getBean("hibernateNonIntrusiveHibernateDao"); AppelOffre a = new AppelOffre(); AppelOffre current = new AppelOffre(); Grid aogrid; Grid aogridce; Listbox box; Button edit; public AppelOffre getCurrent() { return current; } public void setCurrent(AppelOffre current) { this.current = current; } public List getAllAppelOffres() { return service.getAllEntites(a); } public void onClick$edit() { System.out.println("==========="+current.getNum()); ((Include)edit.getDesktop().getPage("admin").getFellow("win").getFellow("tb").getFellow("include")).setSrc("EditAO.zul"); } }
but always the same probleme i can't get current attribute in EditAO.zul :(
any idea?
hey, i've done it like this:
container.zul
<window use="myWindow"> <listbox id="box" multiple="true" rows="5" model="@{aolist$composer.allAppelOffres}" selectedItem="@{myWindow.current}"> <listhead> <listheader label="numero" width="30%" /> <listheader label="intitulé" /> <listheader label="objet" width="20%"/> </listhead> <listitem self="@{each='event'}" value="@{event}"> <listcell label="@{event.num}" value="@{eaolist$composer.current.num}" /> <listcell label="@{event.intitule}" value="@{aolist$composer.current.intitule}" /> <listcell label="@{event.objet}" value="@{aolist$composer.current.objet}"/> </listitem> </listbox> </window>
myWindow extends Window .. private Window editView; //if you use databinding you have to save the created edit.zul to get the correct binder! private loadEditView(){ editView = (Window)Executions.createComponent(edit.zul, idToLoadTheZul, null); } private void setCurrent(){ .. }
private void onClick$edit(){ //get the myWindow Windo and call loadEditView }
in editao you can get the current (selected item) as follows:
@{myWindow.current}
at the beginning i'm also tried to work with include but it's a horror-trip :)
best
tanks ftmichael for your replay :)
but i have 2 questions :
1-what do you mean by the second attribute (idToLoadTheZul) of Executions.createComponent() ??
2-how should i implement onClick$edit() in my contoler ??
best
1) e.g.
<window use="myWindow" id="container"> <borderlayout> <center id="center"> </center </borderlayout> </window>
center will be the id to load your editZul into.
2) you just have it:
public void onClick$edit() { System.out.println("==========="+current.getNum()); //((Include)edit.getDesktop().getPage("admin").getFellow("win").getFellow("tb").getFellow("include")).setSrc("EditAO.zul"); get the myWindow Window an call loadEditView(); }
hi ftmichael, sorry to bother you again
but i didn't really get your proposition
should i drop include in my index.zul ? if yes what i must do instead?
my object current must be in myWindow class and not in AOControleur? if yes i have to change this on container.zul
<listcell label="@{event.num}" value="@{eaolist$composer.current.num}" />
to <listcell label="@{event.num}" value="@{myWindow.current.num}" />
i appretiate your effort
instead of your include use the Executions.createComponent methode i proposed.
yeah, current has to be in myWindow (setter/getter)
u have to change this: selectedItem="@{aolist$composer.current}"> to selectedItem="@{myWindow.current}">
then databinder automaticly calls the set methode when you are clicking on a row.
the value in your listcell you get from your model, which gets the data from your composer.
i work on it but i stell didn't get my editao.zul ful of data
AOControleur.java
public class AOControleur extends GenericForwardComposer { private static final long serialVersionUID = -9145887024839938515L; ApplicationContext appContext = new ClassPathXmlApplicationContext("application-context.xml"); IEntiteDao service = (IEntiteDao) appContext.getBean("hibernateNonIntrusiveHibernateDao"); AppelOffre a = new AppelOffre(); Listbox box; Button edit; public List getAllAppelOffres() { return service.getAllEntites(a); } public void onClick$edit() { myWindow win = (myWindow)edit.getDesktop().getPage("admin").getFellow("win").getFellow("aolist"); win.loadEditView(); }
public class myWindow extends Window{ AppelOffre current = new AppelOffre(); private Window editView; public void setCurrent(AppelOffre current) { this.current = current; } public AppelOffre getCurrent() { return current; } public void loadEditView(){ System.out.println("==========="+current.getNum());//that show null editView = (Window)Executions.createComponents("EditAO.zul",null, null); } }
editao.zul
<window use="com.loool.controleur.myWindow" title="Modifier Appel d'offre" style="text-align:left" width="80%" border="normal"> <grid> <columns> <column label="" width="20%"/> </columns> <rows> <row > <textbox value="@{myWindow.current.num}" id="num" width="150px" tabbable="true" /> </row> </rows> </grid> </window>
and here is AoList.zul
<window use="com.loool.controleur.myWindow" id="aolist" apply="com.loool.controleur.AOControleur" title="new page title" border="normal"> <button id="edit" image="/images/clipboard-24.png" tooltip="modifier" /> <listbox id="box" multiple="true" rows="5" model="@{aolist$composer.allAppelOffres}" selectedItem="@{myWindow.current}"> <listhead> <listheader label="numero" width="30%" /> <listheader label="intitulé" /> <listheader label="objet" width="20%"/> </listhead> <listitem self="@{each='event'}" value="@{event}"> <listcell label="@{event.num}" value="@{myWindow.current.num}" /> <listcell label="@{event.intitule}" value="@{myWindow.current.intitule}" /> <listcell label="@{event.objet}" value="@{myWindow.current.objet}"/> </listitem> </listbox> </window>
what's wrong with this codes
best
Window listView = (Window)Executions.createComponents("EditAO.zul",center, null);
<window use="myWindow" id="container"> <borderlayout> <center id="center"> </center </borderlayout> </window>
if it's about loading zul file in center this is not the mean probleme
i want to fill editAo.zul by the right data at the right component
if you have a simple and complete example using "use=myWindow" i will be very tankful
i keep tring ;)
Asked: 2011-06-10 08:41:42 +0800
Seen: 534 times
Last updated: Jun 11 '11