Thanks for helping. In fact I was trying to validate the ListView's model. I thought that each time we press the Submit button the new choice selected in each DropDownChoice in the ListView's rows would be submited and filled inside the Model of the ListView, meaning the model would now have the new values selected by the user. So I was trying to validate it's Model, because I want to find a way to tell the user if he selected the same choice twice or more. Each row of the ListView has a DropDownChoice but the form must not accept repeated choices. Now I'm not sure if the model would be updated or not... I had succes writing such repeater with a validator like this using RefreshingView instead of ListView. As I experienced, the model of the RefreshingView was updated when the for was submited, but only with TextField or CheckBox. When I changed the TextField by a DropwDownChoice, it just not worked, so I started working around with a ListView, but I'm having problems too. Any ideas, please for validating repeated choices inside a repeater?
2009/8/11 bferr <[email protected]> > > The model of your listView has to be LoadableDetachable so that the > listView > retrieves the new list values each time. Also the setReuseItems() might > have to be false. I don't think you're doing form validation within the > ListView correct? > > > > > > Marcel Bonnet wrote: > > > > Hi everybody, I'm new in the mail-list. I've been studying the framework, > > I > > even read the book Wicket in Action, but I'm having trouble using some > > kind > > of repeater inside a Form, updating and validating the model. > > What I'm trying to do is a ListView inside a Form: when the user change > > the > > value of the dropdownchoice, it needs to fire a validator to verify if > the > > new choice is already in the list. If it is, the validator must call the > > "error(validatable)" method from AbstractValidator because I don't want > > repeated choices in the list. > > First question, anybody knows a simple way to do this? > > Second, if I'm on the right way with the code above, how can I get the > > listview's model (with the updated values changed by the user, instead of > > the default items rendered on the view on the first time) so I can pass > > this > > updated model to my Validator (it needs to know the values in the list to > > know wich is repeated). > > > > I just supressed the part of the code that fires my feedback message ( a > > kind of Label because I don't want a message per component, just a global > > message) > > Thanks for any help. Marcel. > > > > private class InputForm extends Form > > { > > // holds NameWrapper elements > > private List<NameWrapper> data; > > > > public InputForm(String name, IFeedback feedback) > > { > > super(name); > > > > final SubmitLink update = new SubmitLink("update"); > > add(update); > > > > // add some dummy data > > data = new ArrayList<NameWrapper>(); > > data.add(new NameWrapper("one", 1, "default = 1", true)); > > data.add(new NameWrapper("two", 2, "default = 2", false)); > > data.add(new NameWrapper("three", 3, "default = 3", false)); > > data.add(new NameWrapper("four", 4, "default = 4", true)); > > final Model dataModel = new Model(); > > dataModel.setObject(data); > > ListView listView = new ListView("list", dataModel) > > { > > > > protected void populateItem(ListItem item) > > { > > > > NameWrapper wrapper = > > (NameWrapper)item.getModelObject(); > > > > item.add(new Label("name", wrapper.getName())); > > item.add(new CheckBox("check", new > > PropertyModel(wrapper, "selected"))); > > > > DropDownChoice combo = new DropDownChoice("combo" > > , new Model(wrapper) > > , new ArrayList(Arrays.asList(new > > NameWrapper(1000,"mil"), new NameWrapper(2000,"dois mil"), new > > NameWrapper(3000,"trĂªs mil"))) > > , new ChoiceRenderer("comboText","comboId")); > > > > combo.add(new > > NameWrapperValidator((List<NameWrapper>)dataModel.getObject())); > > item.add(combo); > > } > > }; > > *listView.setReuseItems(true); *//i read this > line > > is very important > > add(listView); > > > > > > -- > View this message in context: > http://www.nabble.com/ListView-inside-Form%3A-retrieving-the-listview%27s-model-tp24893789p24922802.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
