0

Comobox DataBinding in ZK MVC

asked 2012-01-23 06:45:42 +0800

swapndipj gravatar image swapndipj
30

Hi Everyone,

I wanted to bind the data from the database table to the combobox item. I used MVC methodology in my applications and i wanted to implement it purely. So i don't want to implement the java code for databinding in the view (ZUML) file. Please give me some information and suggest some tutorial/ Example link for the solutions.

Thanks in Advance..

Regards
Swapnil

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2012-01-23 13:03:41 +0800

Matze2 gravatar image Matze2
773 7

Here is a brief example as a start using ZK5 data-binding approach (I hope I understood your intentions correctly):
Suppose you have have a list of domain object from your database query and the objects have a bean property "label" which can be used to display the entry in the combobox item.
Then you implement the following methods in your composer (T is the type of your domain object):

public List<T> getEntries();
public T getSelectedItem();
public void setSelectedItem(T selectedItem);

Then you use the following combobox definition in your ZUL file:
<combobox model="@{win$composer.entries}" selectedItem="@{win$composer.selectedItem}">
	<comboitem self="@{each=entry}" value="@{entry}" label="@{entry.label}" />
</combobox>

When a combobox item is selected, setSelectedItem() is called.

The Small Talk articles provide similar examples, for sure.

link publish delete flag offensive edit

answered 2012-02-09 13:39:34 +0800

javafan gravatar image javafan
12

Hi Matze2
I am struggling with your codes as I am new, could you please share your codes of each file so that I can understand well?

regards

link publish delete flag offensive edit

answered 2012-02-09 14:36:43 +0800

Matze2 gravatar image Matze2
773 7

Short answer: I will not do that.

Long answer: If you are a beginner and you have no idea what I am talking about, then it is much more effective for you (and also for me by the way) to go through the tutorials and small talk articles which are available on this site.
Example 1: "Tutorial" (the first link on the Documentation page). There is a data-binding example at the end. This should be good start.
Example 2: The article "Create a database-driven application" has an example for listbox, which is very similar to the combobox use case above.

Believe me, you won't get a happy with a load of classes and ZUL files where you do not have the context understanding.

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: 2012-01-23 06:45:42 +0800

Seen: 294 times

Last updated: Feb 09 '12

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