-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Dear all,
I want use "list" reply "dailybean" bindind on listbox below this code, What should I do?:
---------------------
<?xml version="1.0" encoding="GB2312"?>
<zk>
<hbox>
<window width="100px"/>
<window width="520px" >
<zscript>
import mysoft.smart.DBPool.*;
import java.until.*;
List<Map<String,Object>> list=new Arraylist<Map<String,Object>>;
list=new DBPool().excuteQuery("select userid,username from users");
//dailybean = new dailyManager().findAll(arg.get("ss"));
</zscript>
<listbox id="dailylist" width="320px" height="300px" fixedLayout="true">
<listhead >
<listheader label="userid" />
<listheader label="username" width="80px" />
</listhead>
<listitem forEach="${dailybean}" >
<listcell label="${each.userid}" style="border-left:1px solid gray;border-bottom: 1px solid gray"/>
<listcell label="${each.username}" style="border-left:1px solid gray;border-bottom: 1px solid gray"/>
</listitem>
</listbox>
</window>
</hbox>
</zk>
Do you got some errors?
What version of ZK are you using?
I'm not sure about zscript and the Generic-stuff --> List<Map<String,Object>>.
Maybe it works meanwhile.
Are you sure about:
List<Map<String,Object>> list=new Arraylist<Map<String,Object>>;
list=new DBPool().excuteQuery("select userid,username from users");
that DBPool returns a Map?
/Robert
Another fault:
You wrote forEach for $dailybean, but your list is not named dailybean.
Here is working example:
<?xml version="1.0" encoding="GB2312"?> <zk> <hbox> <window width="100px"/> <window width="520px" > <zscript> import java.util.*; ArrayList list= new ArrayList(); HashMap user1 = new HashMap(); user1.put("userid", 5); user1.put("username", "Robert"); list.add(user1); HashMap user2 = new HashMap(); user2.put("userid", 7); user2.put("username", "Pic"); list.add(user2); </zscript> <listbox id="dailylist" width="320px" height="300px" fixedLayout="true"> <listhead > <listheader label="userid" /> <listheader label="username" width="80px" /> </listhead> <listitem forEach="${list}" > <listcell label="${each.userid}" style="border-left:1px solid gray;border-bottom: 1px solid gray"/> <listcell label="${each.username}" style="border-left:1px solid gray;border-bottom: 1px solid gray"/> </listitem> </listbox> </window> </hbox> </zk>
It's Ok,Robert, Thank very much!
<?xml version="1.0" encoding="GB2312"?>
<zk>
<hbox>
<window width="100px"/>
<window width="520px" >
<zscript>
import mysoft.smart.DBPool.*;
import java.until.*;
Arraylist list=new Arraylist();
list=new DBPool().excuteQuery("select userid,username from users");
//DBPool().excuteQuery("select userid,username from users") return Arraylist<Map<String,Object>>
</zscript>
<listbox id="dailylist" width="320px" height="300px" fixedLayout="true">
<listhead >
<listheader label="userid" />
<listheader label="username" width="80px" />
</listhead>
<listitem forEach="${list}" >
<listcell label="${each.userid}" style="border-left:1px solid gray;border-bottom: 1px solid gray"/>
<listcell label="${each.username}" style="border-left:1px solid gray;border-bottom: 1px solid gray"/>
</listitem>
</listbox>
</window>
</hbox>
</zk>
Asked: 2011-03-22 04:05:02 +0800
Seen: 755 times
Last updated: Mar 23 '11