quickstart attached to a jira ticket will help -igor
On Fri, Dec 9, 2011 at 12:15 PM, Jablow, Eric R <eric.jab...@mantech.com> wrote: > In my project, for business reasons, we have classes with SortedSet members. > The classes and their elements are all Serializable. I'm having trouble > working with a SortedSet<MantechControl> object; when I try creating a > ListMultipleChoice<MantechControl> object for it (and putting it into a > FormComponentPanel<SortedSet<MantechControl>>), I get all sorts of > compilation problems. The MantechControlPanel has constructor: > > public MantechControlPanel(String id, > IModel<SortedSet<MantechControl>> model) { > super(id, model); > control = new ListMultipleChoice<MantechControl>( > "choices", new SetModel<NonICDisseminationControl>(choices), > choiceList, new ChoiceRenderer<MantechControl>( > "banner")); > add(control); > onModelChanged(); > } > > The onModelChanged() method has (after I extracted some local objects in a > futile attempt to fix things): > > @Override > protected void onModelChanged() { > super.onModelChanged(); > if (getModelObject()!= null) { > control.setModel(getModel()); > } > > The problem is that the control.setModel() expects a Model of a Collection, > while getModel() returns a Model of a SortedSet: > > The method setModel(IModel<Collection< MantechControl >>) in the type > FormComponent<Collection< MantechControl >> is not applicable for the > arguments (IModel<SortedSet< MantechControl >>). I have good business reasons > to use a sorted set, and what I think are good reasons to use a > FormComponentPanel and a ListMultipleChoice. But should I do something > different? > > Meanwhile, I've created a wicket/metagen quickstart project and am running > into a similar problem there. I can upload the project somewhere if you > want more info. Here I wrote a class ColorfulPerson that has a String name > and a SortedSet<Color> colors. In trying to write a FormComponentPanel for > this, I have an obvious error at the indicated line: > > public class ColorfulPersonPanel extends FormComponentPanel<ColorfulPerson> { > private static final long serialVersionUID = -457616015428125432L; > private final FormComponent<String> name; > private final FormComponent<Collection<Color>> colors; > private List<Color> colorChoices = Arrays.asList(Color.values()); > public ColorfulPersonPanel(String id, IModel<ColorfulPerson> model) { > super(id, model); > name = new TextField<String>("name", new Model<String>()); > add(name); > colors = new ListMultipleChoice<Color>("colors", new > SetModel<Color>(), colorChoices); > add(colors); > onModelChanged(); > } > @Override > protected void onModelChanged() { > super.onModelChanged(); > ColorfulPerson colorfulPerson = getModelObject(); > if (colorfulPerson != null) { > > name.setModel(MetaModel.of(colorfulPerson).get(ColorfulPersonMeta.name)); > > colors.setModel(MetaModel.of(colorfulPerson).get(ColorfulPersonMeta.colors)); > // Error as the model is one of > SortedSet<Color> while the ListMultipleChioice expects a model of > Collection<Color>. > > } else { > name.setModelObject(null); > colors.setModelObject(null); > } > } > > Could there be a MetaModel.as(Class<?> castingClass) method? > > Respectfully, > Eric Jablow > > This communication, along with any attachments, is covered by federal and > state law governing electronic communications and may contain company > proprietary and legally privileged information. If the reader of this > message is not the intended recipient, you are hereby notified that any > dissemination, distribution, use or copying of this message is strictly > prohibited. If you have received this in error, please reply immediately to > the sender and delete this message. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org