0

Databind grid from Java code

asked 2007-10-19 10:48:22 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4577714

By: matteo_barbieri

Hi,
I'm writing a component from Java code.
This component has a Grid and I do:

binder.addBinding(grid, "model", "collection");

and then

binder.bindBean("collection", collection); binder.loadAll();

and the grid creates the right number of rows, but I have problems rendering rows correctly.
In zul I do:

<row self="@{each=obj}">
<label value="@{obj.name}"/>
<label value="@{obj.property}"/>
</row>

In Java I tried:

binder.addBinding(row, "self", "each=obj"); for(String p : properties) {
Label l = new Label();
binder.addBinding(l, "value", "obj."+p);
l.setParent(row);
}

and many other ways, but the result it's the same: every row has one label with the toString method of "each" object printed, like:

com.MyClass@957e72
com.MyClass@ae9862
com.MyClass@696079

Any idea?

Many thanks,
bye

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2007-10-22 01:11:22 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4581118

By: jebberwocky

Dear Matteo

I try the first sample u mentioned with code:
<window id="mainwin">
<zscript>
import org.zkoss.demo.Person;


int count = 30;
List persons = new ArrayList();
for(int j= 0; j < count; ++j) {
Person personx = new Person(j);
persons.add(personx);
}

</zscript>
<grid id="grid">
<rows>
<row self="@{each=obj}">
<label value="@{obj.name}"/>
<label value="@{obj.email}"/>
</row>
</rows>
</grid>
<zscript>
AnnotateDataBinder binder = new AnnotateDataBinder(mainwin);
binder.addBinding(grid, "model", "persons");
binder.bindBean("person", persons);
binder.loadAll();
</zscript>
</window>
It works fine in my case tho.
But I can duplicate your problem
by remove the row tag .

could u provide more information? thanks.

link publish delete flag offensive edit

answered 2007-10-22 07:46:34 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4581390

By: matteo_barbieri

Simply try to create the grid completely from java code, not using zul tags.

Grid grid = new Grid();
grid.setParent(mainwin);
Rows rows = new Rows();
rows.setParent(grid);

....

etc.

link publish delete flag offensive edit

answered 2011-06-28 05:06:45 +0800

pacuz gravatar image pacuz
3

Hi all,

I have the same problem.... no solutions?????

link publish delete flag offensive edit

answered 2011-07-10 22:43:03 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

@pacuz plz post your problem in new thread

better with details and duplicatable cases
:)

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: 2007-10-19 10:48:22 +0800

Seen: 429 times

Last updated: Jul 10 '11

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