0

how to pass selecteditem to another page ?

asked 2011-06-10 08:41:42 +0800

fati gravatar image fati
108 1

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??

delete flag offensive retag edit

14 Replies

Sort by » oldest newest

answered 2011-06-10 09:44:52 +0800

fati gravatar image fati
108 1

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?

link publish delete flag offensive edit

answered 2011-06-10 12:50:00 +0800

ftmichael gravatar image ftmichael
129 1

updated 2011-06-10 12:52:55 +0800

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.java
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(){
..
}

AOControleur
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

link publish delete flag offensive edit

answered 2011-06-11 02:55:35 +0800

fati gravatar image fati
108 1

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

link publish delete flag offensive edit

answered 2011-06-11 03:28:59 +0800

ftmichael gravatar image ftmichael
129 1

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();
	    }

link publish delete flag offensive edit

answered 2011-06-11 04:10:37 +0800

fati gravatar image fati
108 1

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

link publish delete flag offensive edit

answered 2011-06-11 04:16:58 +0800

ftmichael gravatar image ftmichael
129 1

updated 2011-06-11 04:18:00 +0800

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.

link publish delete flag offensive edit

answered 2011-06-11 05:59:43 +0800

fati gravatar image fati
108 1

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();
	    }

myWindow.java
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>

link publish delete flag offensive edit

answered 2011-06-11 06:01:26 +0800

fati gravatar image fati
108 1

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

link publish delete flag offensive edit

answered 2011-06-11 06:07:32 +0800

ftmichael gravatar image ftmichael
129 1

updated 2011-06-11 06:10:24 +0800

no you need an container like container.zul where you have your layout. in the myWindow.java you have to add the doAfterCompose methode where you load your list when the page is composed:
Window listView = (Window)Executions.createComponents("EditAO.zul",center, null);
<window use="myWindow" id="container">
<borderlayout>
<center id="center">
</center
</borderlayout>
</window>
myWindow just use at container, not at any other page like editao. with (Window)Executions.createComponents("EditAO.zul",center, null); you will load your zul file in the center region!
link publish delete flag offensive edit

answered 2011-06-11 07:07:54 +0800

fati gravatar image fati
108 1

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 ;)

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-06-10 08:41:42 +0800

Seen: 534 times

Last updated: Jun 11 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More