I have my own ListSelectModel for this purpose. Then, for any entity I want
to use in a select menu, all I need to write is a LabelProvider. 

public interface LabelProvider<T> {
   String getLabel(T value);
}

public class ListSelectModel<T> extends AbstractSelectModel {
   private List<OptionModel> options;
   public ListSelectModel(List<T> list, LabelProvider<T> labelProvider) {
      options = new ArrayList<OptionModel>(list.size());
      for (T value : list) {
         String label = labelProvider.getLabel(value);
         options.add(label, value);
      }
   }

   @Override
   public List<OptionGroupModel> getOptionGroups() {
      return null;
   }

   @Override
   public List<OptionModel> getOptions() {
      return options;
   }
}






--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Dynamic-OptionModel-Implementation-How-To-tp5719875p5719883.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to