0

How to setting on runtime an radiogroup selectedItem

asked 2009-09-03 17:01:09 +0800

lramellavotta gravatar image lramellavotta flag of Italy
200 1 8

Hi, in a zk form I have a ListItem. On event onSelected I launch a function for setting various textbox.

My problem is "refreshing" this radiogroup when I set (on runtume) the value of txtEsame_attivo.

thanks




<hbox>
<textbox id="txtEsame_attivo" />
<radiogroup id="chkEsame_attivo" selectedItem="@{txtEsame_attivo}">
<radio id="riEsame_attivo_true" value = "1" label="Attivo" />
<radio id="riEsame_attivo_false" value = "0" label="Non attivo" />
</radiogroup>
</hbox>

....

void onSelect_lstEsami(Listitem lsi){
Iterator itc=lsi.getChildren().iterator();
while(itc.hasNext()){
Listcell lsc=(Listcell)itc.next();

if(lsc.getListheader().getLabel().equalsIgnoreCase("Esame")){
txtEsame.setValue(lsc.getLabel());
}
else
if(lsc.getListheader().getLabel().equalsIgnoreCase("Attivo")){
txtEsame_attivo.setValue(lsc.getLabel());
chkEsame_attivo.setParent(txtEsame_attivo);

....

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2009-09-04 07:52:10 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

You can call radiogroup.invalidate() to redraw the UI.

/Jumper

link publish delete flag offensive edit

answered 2009-09-04 08:03:29 +0800

lramellavotta gravatar image lramellavotta flag of Italy
200 1 8

Thank you for your reply jumperchen...

link publish delete flag offensive edit

answered 2009-09-04 16:07:01 +0800

lramellavotta gravatar image lramellavotta flag of Italy
200 1 8

updated 2009-09-04 16:09:17 +0800

I tried to call .invalidate but this solution don't work .... any idea?

Thanks for yours replay....
Luca

I send you an example



<?xml version="1.0" encoding="UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<window id="win" width="500px">
<listbox mold="paging" rows="13" id="lstEsami" width="700px" onSelect="onSelect_lstEsami(self.selectedItem)" >
 	<listhead>
		<listheader label="Esame" width="10%" />
		<listheader label="Descrizione" width="25%"/>
		<listheader label="Ok" width="5%"/>
	</listhead>
    	<listitem self="@{each=ex}">
 		<listcell label="@{ex.Esame}" />
		<listcell label="@{ex.Descrizione}"  />
		<listcell label="@{ex.Esame_attivo}" />
	</listitem>
	</listbox>
			
<grid>			
<rows>
    <row>
	Esame/Descrizione	
	<hbox>  
	<textbox id="txtEsame"        maxlength="15" />
	<textbox id="txtDesEsame"     maxlength="35" />
	</hbox>
	</row>
	<row>
	Attivo		
	<hbox>  
		<intbox id="txtEsame_attivo"  />
		<radiogroup id="chkEsame_attivo" selectedItem="@{txtEsame_attivo}">
		<radio id="riEsame_attivo_true"  value = "1"  label="Attivo" />
		<radio id="riEsame_attivo_false" value = "0"  label="Non attivo" />
		</radiogroup>
	</hbox>
	</row>	
</rows>	
</grid>  

link publish delete flag offensive edit

answered 2009-09-04 16:07:36 +0800

lramellavotta gravatar image lramellavotta flag of Italy
200 1 8

... and the code ....


<zscript> 
         
private class Order {
  private String esame;
  private String descrizione;
  private Boolean attivo;
  
  	public String getEsame() {
		return esame;
	}
	public void setEsame(String esame) {
		this.esame = esame;
	}
	public String getDescrizione() {
		return descrizione;
	}
	public void setDescrizione(String descrizione) {
		this.descrizione = descrizione;
	}
	public Boolean getAttivo() {
		return attivo;
	}
	public void setAttivo(Boolean attivo) {
		this.attivo = attivo;
	}
}   

<![CDATA[    
    int count = 10;
    List orders = new LinkedList();
    for(int j = 0; j < count; ++j) {
      Order o = new Order();
      o.setEsame("Esame - " + j );
      o.setDescrizione("Descrizione esame - " + j);
      o.setAttivo(false);
      orders.add(o);
    }
       
   	List lstLabEsami = orders;
	ListModel lsmLabEsami = new SimpleListModel(lstLabEsami);
	lstEsami.setModel(lsmLabEsami);   
 
	void onSelect_lstEsami(Listitem lsi){
    	Iterator itc=lsi.getChildren().iterator();
    	while(itc.hasNext()){
    		Listcell lsc=(Listcell)itc.next();
   		
    		if(lsc.getListheader().getLabel().equalsIgnoreCase("Esame")){
    			txtEsame.setValue(lsc.getLabel());
    		}
    	}
    	txtEsame_attivo.setValue(0);
    	chkEsame_attivo.invalidate();
	}
	]]>
  </zscript>
  </window>
</zk>

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: 2009-09-03 17:01:09 +0800

Seen: 607 times

Last updated: Sep 04 '09

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