0

Listbox - model, data binding and callbacks

asked 2012-05-23 21:05:05 +0800

juergenmw gravatar image juergenmw
79 1

updated 2012-05-23 21:07:12 +0800

Hi

In Callbacks it is often necessary to get the (selected) Bean/Object/PoJo, not only the selected list item.
There seem to be several ways to add data (model) to a Listbox, not all of them support this need:

1.) SetModel
Just create a Selectbox in ZUML, Wire it and use setModel(..) in your Controller

+ Easy
+ Only Supports ListModelList, ... as Model(Data)
- No connection to a Bean/Pojo, ListItem has only a String which is being displayed and a Index(which is not an ItemID)

2.) Template
See Reference/MVC/View/Template/Listbox_Template

+ Also easy to use
- Does not support use of PoJos/Beans (NOT SURE ABOUT THIS???)

3.) Custom ItemRenderer
There are several examples from terrytornado and others in the forum

+ Highest flexibility
+ item.setAttribute allows to add the object to each row
+ this enables to extract the object later using getAttribute (eg in onClick)
- Separate implementation for every Object type - not generic

4.) AnnotateDataBinder (MVC)
Example(third to last entry)

+ As easy as #2 (template)
+ Listitem.getValue can be cast to PoJo/Object

5.) MVVM DataBinder
Completly different approach with other pros/cons


So, here are a few questions:

a) Ad 2 - is it possible to use PoJos/Beans here, I didn't succeed.
b) Ad 4 - is AnnotateDataBinder still "state of the art" in MVC? There aren't many current docs around
c) Ad 5 - is there a way to combine MVC with the new DataBinder from MVVM?

Any comment welcome - maybe I forgot somethin?

Thanks
juergenmw

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-05-24 10:05:51 +0800

vincentjian gravatar image vincentjian
2245 6

updated 2012-05-24 10:07:16 +0800

Hi juergenmw,

For your question:
a) Yes, template supports pojos/beans, check the sample
b) I think it depends on your needs, here is a the related document
c) It is not suggested, please refer to the forum link

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-05-23 21:05:05 +0800

Seen: 150 times

Last updated: May 24 '12

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