Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The following page has been changed by AfrimSallahi: http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects The comment on the change is: changed from List parameter to Collection for better flexibility... good work! ------------------------------------------------------------------------------ This has proven to be a dificult task, especially since we are all new to T5. Here is an example of a !SelectionModel that simplifies using Select component with objects. It requires 5 parameters - * List<T> - the list of objects that can be selected + * Collection<T> - the list of objects that can be selected (a Collection type of list) * Class<T> - Superclass of all objects in the list (this is because of Generics deletion at runtime) so an adapter can be produced (even byte code generated one might be implemented in Tapestry-ioc later on) * name of the identifier property - a property that identifies the object (usually id if object is from database), it will be used as value attribute for the <option> * name of the name property - if name is composed of few properties, add a transient property to your Object @@ -31, +31 @@ Here's code for the !SelectModel implementation: !GenericSelectModel {{{ import java.util.ArrayList; + import java.util.Collection; import java.util.List; import org.apache.tapestry.OptionGroupModel; @@ -51, +52 @@ private PropertyAdapter labelFieldAdapter; private PropertyAdapter idFieldAdapter; - private List<T> list; + private Collection<T> list; - public GenericSelectModel(List<T> list, Class<T> clazz, String labelField, String idField, PropertyAccess access) { + public GenericSelectModel(Collection<T> list, Class<T> clazz, String labelField, String idField, PropertyAccess access) { this.list = list; if (idField != null) this.idFieldAdapter = access.getAdapter(clazz).getPropertyAdapter(idField); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
