-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
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
Asked: 2012-05-23 21:05:05 +0800
Seen: 150 times
Last updated: May 24 '12