0

List result binding Listbox?

asked 2011-03-22 04:05:02 +0800

leoyc gravatar image leoyc
163 3

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>

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-03-22 19:16:01 +0800

robertpic71 gravatar image robertpic71
1275 1

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

link publish delete flag offensive edit

answered 2011-03-22 19:35:42 +0800

robertpic71 gravatar image robertpic71
1275 1

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>

link publish delete flag offensive edit

answered 2011-03-23 02:23:08 +0800

leoyc gravatar image leoyc
163 3

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>

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: 2011-03-22 04:05:02 +0800

Seen: 755 times

Last updated: Mar 23 '11

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