Hello!

I got confused on what is the intended behavior of the dropdownchoice
with integers.

I wanted to create a dropdownchoice, which would list a range of
integers for user to select.

It seems to me, that if I call the setType(Integer.class), then it
changes the way it is processed when I submit. The dropdownchoice will
get the index value in the model instead of the value that the user
selected in the dropdownchoice. If I remove the call to the
setType-method, then the value which gets passed to the under
lying  model is what I select in the dropdownchoice.

Here is what I did:


public class TestPage extends WebPage {
        
        public TestPage() {
                Form<Void> form = new Form<Void>("form");
                
                List<Integer> choices = new ArrayList<Integer>();
                for(int i =5; i < 10; i++) {
                        choices.add(new Integer(i));
                }
                Model<Integer> integerModel  = new Model<Integer>(5){
                        @Override
                        public void setObject(Integer object) {
                                super.setObject(object);
                                System.err.println("Setting the model
object: "+ object);                               
                        }
                };
                DropDownChoice<Integer> myDropDownChoice = 
                        new DropDownChoice<Integer>("myDropDownChoice",
integerModel,
choices);
                
                // If you comment out the setType()-call,
                // then it works as I would expect.
                myDropDownChoice.setType(Integer.class); 

                form.add(myDropDownChoice);
                this.add(form);
        }; 
}

Is it a bad idea to call the setType() method or am I doing something
else wrong?

My wicket version was 1.4.10

Br,
Jarkko




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

Reply via email to