0

Listbox setSelected( ) depending of the value of the ListItem

asked 2009-02-09 22:30:33 +0800

bob007 gravatar image bob007
384 3 4

Hi all,

I'm new with zk. So i don't know what is the best way for set the selected value of a Listbox depending of the data value. For exemple, here i want to display on a person, so i want the Listbox to display (select) the right listitem.


<zscript>
   Person person = new Person("ERT-2009-0001", "Actif", "RST", 1, Calendar.getInstance()) ;   
   groups = new String[] {"ERT", "RST", "CCT", "testg"};
</zscript>
....
         <row>
            <label value="Group" /> 
            <hbox>            
               <listbox rows="1" mold="select" selectedItem="@{person.group}">
                  <listitem label="${each}" value="${each}" forEach="${groups}"

<zscript>
if (each==person.group){
setSelected(true);
}
</zscript>
 
                  />               
               </listbox>
               <image src="img/QuestionmarkButton-16x16.png" tooltip="h_group" popup="h_group" style="cursor:help;"/>
               <label value="@{person.group}"/>               
            </hbox>
         </row>
...

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2009-02-10 01:20:33 +0800

iantsai gravatar image iantsai
2755 1

updated 2009-02-10 01:25:06 +0800

"each" is an EL variable and can't be use like this way.

in your case, I'll suggest you use a ListModelList instead of EL foreach.

you can find how to use it by ether searching "zk ListModelList" or typing "ListModel" in ZK Demo's filter.

ZK Demo

link publish delete flag offensive edit

answered 2009-02-10 16:12:43 +0800

bob007 gravatar image bob007
384 3 4

Sorry,

Forget my question, finally the selected item synchronize automaticly with the binded attribute : selectedItem="@{person.group}">

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-02-09 22:30:33 +0800

Seen: 403 times

Last updated: Feb 10 '09

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