Revision history [back]

click to hide/show revision 1
initial version

answered 2013-01-30 21:23:25 +0800

lramellavotta gravatar image lramellavotta flag of Italy

This code works

@Init
public void init() 
{
    UtentiDAO pdao = (UtentiDAO)SpringUtil.getBean("UtentiDAO");
    lstUtenti=pdao.findAll();
    System.out.println("init");
}

public List<Utenti> getlstUtenti()
{   
    return lstUtenti;
}
... 
@Command
@NotifyChange({"lstUtenti","selected"})
public void delUtente() throws Exception
{   
    Messagebox.show("Confermi la cancellazione di "+selected.getUtente()+" ?","Confirm",Messagebox.YES | Messagebox.NO,Messagebox.QUESTION,
            new EventListener<Event>()
            {
                @Override
                public void onEvent(Event event) throws Exception 
                {
                    if (event.getName().equals("onYes"))
                    {
                        System.out.println("Cancellato");
                        UtentiDAO pdao = (UtentiDAO)SpringUtil.getBean("UtentiDAO");
                        pdao.delete(selected.getUtente());
                        lstUtenti.remove(lstUtenti.indexOf(selected));   
                        BindUtils.postNotifyChange(null,null,aaa.this,"lstUtenti");
                        selected=null;
                    }
                }
            });

}

I hope it can help someone Luca

This code works

private List<Utenti> lstUtenti;
private Utenti selected;

@Init
public void init() 
{
    UtentiDAO pdao = (UtentiDAO)SpringUtil.getBean("UtentiDAO");
    lstUtenti=pdao.findAll();
    System.out.println("init");
}

public List<Utenti> getlstUtenti()
{   
    return lstUtenti;
}
... 
@Command
@NotifyChange({"lstUtenti","selected"})
public void delUtente() throws Exception
{   
    Messagebox.show("Confermi la cancellazione di "+selected.getUtente()+" ?","Confirm",Messagebox.YES | Messagebox.NO,Messagebox.QUESTION,
            new EventListener<Event>()
            {
                @Override
                public void onEvent(Event event) throws Exception 
                {
                    if (event.getName().equals("onYes"))
                    {
                        System.out.println("Cancellato");
                        UtentiDAO pdao = (UtentiDAO)SpringUtil.getBean("UtentiDAO");
                        pdao.delete(selected.getUtente());
                        lstUtenti.remove(lstUtenti.indexOf(selected));   
                        BindUtils.postNotifyChange(null,null,aaa.this,"lstUtenti");
                        selected=null;
                    }
                }
            });

}

I hope it can help someone Luca

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