please make a bug report with a testcase.

johan


On 4/6/06, Nino Wael <[EMAIL PROTECTED]> wrote:
Hmm strange, Im pretty much doing the same stuff. I do however also have a custom ichoicerenderer could that mean anything? Also I am disabling the control when adding it to the form and enabling it later on.

-regards Nino

        -----Oprindelig meddelelse-----
        Fra: [EMAIL PROTECTED] på vegne af Johan Compagner
        Sendt: on 05-04-2006 16:47
        Til: wicket-user@lists.sourceforge.net
        Cc:
        Emne: Re: [Wicket-user] wicket 1.2 beta 2 DropDownChoice default display value.. "Please Choose one"


        can't reproduce it if i do create this:

        ArrayList list = new ArrayList();
                list.add("test1");
                list.add("test2");
                 list.add("test3");

                DropDownChoice choice = new DropDownChoice("dropdownchoice", new Model(null), new Model(
                        list))

        So a normal default choice.
        The Choose one is displayed nicely.

        So if you override that getDefaultOption() but you do pretty much the same thing it should work fine.

        johan



        On 4/5/06, Nino Wael < [EMAIL PROTECTED]> wrote:

                The value of dropDownInitial is not used, instead it uses the first object from the model.



                So instead of displaying whats held in dropDownInitial it displays the object from the model.



                -regards Nino




  _____


                From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Johan Compagner
                Sent: 5. april 2006 13:02
                To: wicket-user@lists.sourceforge.net
                Subject: Re: [Wicket-user] wicket 1.2 beta 2 DropDownChoice default display value.. "Please Choose one"



                what doesn't work exactly?
                Because looking at the code it should work fine. The getDefaultChoice(selected) is called and appended to the output.

                johan

                P.S. Now i think about it getDefaultChoice is a perfect candidate for returning a CharSequence instead of a string. So that you don't have to call toString() on it.



                On 4/5/06, Nino Wael <[EMAIL PROTECTED]> wrote:

                Hi



                I looked at the dialog between Igor and Stefan, thought what a nice way to select the default value with the property model. However and then remembered why it did not do it that way, I wanted to replace the Choose One text with something else, well at least in some cases. Im replacing the text by overriding the getDefaultChoice method. However that doesn't seem to work any longer(im pretty sure I had it working with wicket 1.1.1), see sniplet below? Also I noticed these lines in the documentation :



                        // Note that when the selection is null, Wicket will lookup a localized string to


                        // represent this null with key: "id + '.null'". In this case, this is '
                site.null'

                        // which can be found in
                DropDownChoicePage.properties
                        form.add(new DropDownChoice("site", SITES));

                Does this mean that I could write in my own version of Please Choose one in the properties file or am I reading it wrong?



                /******Sniplet start******/



                                                                                 dropdown = new DropDownChoice("dropdown", DropdownList.toArray()

                                                                                                                             .getList(), new rowRenderer()) {

                                                                                                       protected String getDefaultChoice(Object selected) {

                                                                                                                             // The <option> tag buffer

                                                                                                                             final StringBuffer buffer = new StringBuffer();

                                                                                                                             if (isNullValid()) {

                                                                                                                                                   return super.getDefaultChoice(selected);

                                                                                                                             } else {

                                                                                                                                                   // Null is not valid. Is it selected anyway?

                                                                                                                                                   if (selected == null) {

                                                                                                                                                                         // Force the user to pick a non-null value

                                                                                                                                                                         final String option = dropDownInitial;

                                                                                                                                                                         buffer

                                                                                                                                                                                                                    .append(

                                                                                                                                                                                                                                                                "\n<option selected=\"selected\" value=\"\">")

                                                                                                                                                                                                                    .append(option).append("</option>");

                                                                                                                                                   }



                                                                                                                             }

                                                                                                                             return buffer.toString();

                                                                                                       }



                                                                                                       protected void onSelectionChanged(Object newSelection) {

                                                                                                                             fill.setEnabled(true);

                                                                                                                             invoke.setEnabled (true);

                                                                                                                             selectAll.setEnabled (true);

                                                                                                                             deselectAll.setEnabled (true);

                                                                                                                             btn_add.setEnabled(true);

                                                                                                                             btn_remove.setEnabled(true);



                                                                                                                             info("actionbutton was clicked");

                                                                                                                             DataItem selected = (DataItem) dropdown.getModelObject();

                                                                                                                             invoke.setChoices (DropdownList.getNewValues(

                                                                                                                                                                         selected.getID()).getList());

                                                                                                                             fill.setChoices(new ArrayList());



                                                                                                       }



                                                                                                       protected boolean wantOnSelectionChangedNotifications() {

                                                                                                                             return true;

                                                                                                       }



                                                                                 };

                /******Sniplet end******/



                Regards Nino








Reply via email to