What does "c.getMyOptionValue()" return?

This...
    public HomePage() {
        add(new DropDownChoice(
                "options",
                new Model(getMyOptionValue()),
                OPTIONS)
        {
            protected String getDefaultChoice(final Object selected) {
                return ""; // remove "Choose One" prompt
            }
        });
    }

    private String getMyOptionValue() { return "Opt2"; }
}
works as you'd expect. (The ChoiceRenderer() wasn't doing anything).

/Gwyn

On 21/09/06, Dumitru Postoronca <[EMAIL PROTECTED]> wrote:
> Hello everyone,
>
>    I want to create an edit form and I'm trying to set the selected item
> of a DropDownChoice to match what I have in the database.
>
> The form constructor looks like this:
> -----
> public ClientEditPage(Client c) {...}
> -----
>
> The code that sets the form looks like this:
>
> -----
> final static List OPTIONS = Arrays.asList(new String[] {"Opt1", "Opt2",
> "Opt3"});
>
> //...
>
> DropDownChoice ddc = new DropDownChoice(
>         "options",
>         new Model(c.getMyOptionValue()),
>         OPTIONS,
>         new ChoiceRenderer() {
>                 @Override
>                 public String getIdValue(Object arg0, int arg1) {
>                 // I also tried to return ((Integer)arg1).toString()
>                 // and it didn't work
>                 return ((Integer)OPTIONS.indexOf(arg0)).toString();
>                 }
>         }
> ){      protected String getDefaultChoice(final Object selected)
> {
>         return ""; // remove "Choose One" prompt
> }};
>
> add(ddc);
> -----
>
> No matter what client I select, it always shows me the first option.
> Also, the rendered HTML looks like this:
> <option value="0">Opt1</option>
> <option value="1">Opt2</option>
> <option value="2">Opt3</option>
>
> No selected="selected" attribute.
>
> Can somebody tell me what am I doing wrong?
>
> Thank you in advance,
> - posto
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>


-- 
Download Wicket 1.2.2 now! - http://wicketframework.org

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to