Davide,
you have to attach a model to the drop downlist that will hold the state
of each list.
you could to this:
create a MyDate class with integer fields for day, month, hour and
minute and the respective getters and setters.
then change your method so it takes a PropertyModel:
private FormComponent getIntegerDropDownChoice(String name, PropertyModel
model, int start,
int stop) {
DropDownChoice select = new DropDownChoice(name, model, getIntegerList(start,
stop));
return addRequiredValidator(select);
}
and add the dropdownchoices like so:
MyDate myDate = new MyDate(); (well, of course you have to remember the MyDate
instance across page calls and not build a new one each time...)
section1.add(getIntegerDropDownChoice("dateContainer.day", new PropertyModel(myDate,
"day"), 1, 31));
section1.add(getIntegerDropDownChoice("dateContainer.month", new PropertyModel(myDate,
"month"), 1, 12));
section1.add(getIntegerDropDownChoice("dateContainer.hour", new PropertyModel(myDate,
"hour"), 0, 23));
section1.add(getIntegerDropDownChoice("dateContainer.minute", new PropertyModel(myDate,
"minute"), 0, 59));
That should do the trick!
- Johannes
Davide Savazzi wrote:
I have created a Form with several DropDownChoice... some of them
update the model but after the submit they lose their state (the first
value is selected), others update the model only on the first submit,
and only one of them seems to work! :)
public Step1Form(String name, MyModel model) {
super(name, new CompoundPropertyModel(model));
Border section1 = new MyBorder("section1Border", "Title");
section1.add(getIntegerDropDownChoice("dateContainer.day", 1, 31));
section1.add(getIntegerDropDownChoice("dateContainer.month", 1, 12));
section1.add(getIntegerDropDownChoice("dateContainer.hour", 0, 23));
section1.add(getIntegerDropDownChoice("dateContainer.minute", 0, 59));
section1.add(addRequiredValidator(new CityDropDownChoice("city")));
...
private FormComponent getIntegerDropDownChoice(String name, int start,
int stop) {
DropDownChoice select = new DropDownChoice(name, getIntegerList(start, stop));
return addRequiredValidator(select);
}
Textfields works, and a Panel in the same page is updated with the same model.
I can't figure out what I'm doing wrong with these DropDownChoice elements... :(
Cheers,
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user