0

How to decode in key listitem while loading data?

asked 2010-12-21 03:53:33 +0800

lramellavotta gravatar image lramellavotta flag of Italy
200 1 8

Hello everyone, I have yet another question (embarrassing in its simplicity) that I can not write a decent solution.
I have a simple list box with date and event code. I would like to decode the code on-the-fly, but I can not find a general method.
What do you suggest to fix this?
Luca


.zul

<?xml version="1.0" encoding="UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<window id="win" title="Gestione Utenti" width="750px" border="normal"
        apply="rvl.unitocli.composer.AdminUtentiComposer">
        
	   <caption>
 		  <button id="btnnew"  image="/images/buttonadd-32x32.png"  width="40px"  disabled="true" />
		  <button id="btnupd"  image="/images/file-save-32x32.png"  width="40px"  disabled="true" />
	      <button id="btndel"  image="/images/button-del-32x32.png" width="40px" />
	      <label value="__"></label>
	      <button id="btnexit" image="/images/exit-32x32.png"         width="40px" onClick="Executions.sendRedirect("login.zul")"/>
	   </caption>
	   
		<tabbox id="tbox" width="720px" onSelect="tbox_onSelect()">
			<tabs>
				<tab id="eventi"    label="Eventi"/>
			</tabs>
		    
		<tabpanels width="720px">
			<tabpanel>
				<hbox>
					Utente:
					<label value="utente" />
				</hbox>
				<separator></separator>				
								
	          	<listbox id="lsbEventi" multiple="false" mold="paging" rows="10"  width="700px" 
	          			 model="@{win$composer.EventiUtente, load-after='btnnew.onClick, btndel.onClick, btnupd.onClick'}"
	          			 selectedItem="@{win$composer.current}" >
 					<listhead>
 						<listheader label="Data"   width="23%" />
 						<listheader label="Evento" />
 						<listheader label="Descrizione" />
					</listhead> 
 					<listitem self="@{each='current'}" value="@{current}">
 						<listcell label="@{current.Data_evento}"  />
				    	<listcell label="@{current.Evento}"  />
				    	<listcell label="descrizione"  />
					</listitem>
				</listbox>			
			</tabpanel>
		</tabpanels>
	</tabbox>
	
	<zscript>
		
	<![CDATA[
    		    
	void tbox_onSelect()
	{
		
	}
		
	]]>
	</zscript>
</window> 

.java

public class AdminUtentiComposer extends GenericForwardComposer
{

	private static final long serialVersionUID = 8329600099118015757L;
	EventiUtente current = new EventiUtente();
	protected transient AnnotateDataBinder binder;
	
	public List<EventiUtente> getEventiUtente()
	{	
		EventiUtenteDAO pdao = (EventiUtenteDAO)SpringUtil.getBean("EventiUtenteDAO");
		List<EventiUtente> lstEventiUtente = pdao.findAll("admin");				
		return lstEventiUtente;
	}

	public List<Eventi> getEventi()
	{
		EventiDAO pdao = (EventiDAO)SpringUtil.getBean("EventiDAO");
		List<Eventi> lstEventi = pdao.findAll();
		return lstEventi;
	}
	    /*
		page - the page for composing this component.
		parent - the parent component, or null if it is the root component.
		compInfo - the component info used to instantiate the component.
	    */
	
		@Override
	    public ComponentInfo doBeforeCompose(Page page, Component parent, ComponentInfo compInfo) 
	    {
	    	// Inizializzo i dati della pagina
	    	//List<EventiUtente> list = super.getAllEvents();
	    	// Attribuisco il model dati nella pagina
	    	//page.setAttribute("mod_elenco", list);
	    	System.out.println("doBeforeCompose: " + parent);
	    	binder = new AnnotateDataBinder(page);
	    	return super.doBeforeCompose(page, parent, compInfo);
	    }

		@Override
		public void doAfterCompose(Component comp) throws Exception 
		{
			super.doAfterCompose(comp);
			loadAll();
			System.out.println("doAfterCompose: " + comp);

			// Posso aggiungere altri dati o gestrli
			// ...
			
			// Alla fine devo perĂ² attribuirli in qualche modo
			//desktop.setAttribute("data2", data2);
		}

		@Override	    
	    public void doBeforeComposeChildren(Component comp) throws Exception 
	    {
	    	super.doBeforeComposeChildren(comp);
	    	System.out.println("doBeforeComposeChildren: " + comp);

	    	//super.doBeforeComposeChildren(cmp);
	        //DataResource dr = new DataResource();
	        //Object obj = FusionInvoker.newInstance(new Object[] { cmp, dr });
			//set the new object to original component's name then we can use it by EL
	        //cmp.setVariable(cmp.getId(), obj, true);
	    }
	    // 
	    // Dopo doBeforeCompose vengono creati i children
	    //
        
		@Override
	    public boolean doCatch(Throwable ex) throws Exception 
	    {
            return false;
	    }

		@Override
	    public void doFinally() throws Exception 
	    {
	    	System.out.println("doFinally");
	    }

		
        protected void loadComponent(Component comp) 
        {
            binder.loadComponent(comp);
        }
		
        protected void loadAll() 
		{
            binder.loadAll();
		}


	
	
	
    public void addEvent() {}  
    public void updateEvent() {}
    public void deleteEvent() {}
	 
	/*
	 *  Metodi per accedere agli eventi di onClick sui button
	 */
	
    public void onClick$btnnew(EventiUtente current) 
    {     
  
    }  
    public void onClick$btnupd(EventiUtente current) 
    {      

    }
    public void onClick$btndel(EventiUtente current) 
    {      
 
    }
	
	
	
	/*
	 * Metodi di accesso dalla videata ai dati
	 */
    public EventiUtente getCurrent() 
    {
        return current;
    }
    public void setCurrent(EventiUtente current) 
    {
        this.current = current;
    }
    
}

delete flag offensive retag edit
Be the first one to reply this discussion!
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: 2010-12-21 03:53:33 +0800

Seen: 244 times

Last updated: Dec 21 '10

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