Re: [Wicket-user] wicket 1.2 beta 2 DropDownChoice default display value.. "Please Choose one"
please make a bug report with a testcase.johanOn 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 CompagnerSendt: on 05-04-2006 16:47 Til: wicket-user@lists.sourceforge.netCc: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.johanOn 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 CompagnerSent: 5. april 2006 13:02To: 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. johanP.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:HiI 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 inDropDownChoicePage.propertiesform.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 tag buffer final StringBuffer buffer = new StringBuffer(); if (isNullValid()) { return super.getDefaultChoice(selected); } else { // Null is not valid. Is it selected anyway?
SV: [Wicket-user] wicket 1.2 beta 2 DropDownChoice default display value.. "Please Choose one"
Hmm, must have been a bug in my code after fidling around with(and rewriting my overide code) my overide it seems to work as wanted. Sorry for interupting, sometimes you just need someone elses opinion. -regards Nino -Oprindelig meddelelse- Fra: [EMAIL PROTECTED] på vegne af Nino Wael Sendt: to 06-04-2006 10:02 Til: wicket-user@lists.sourceforge.net Cc: Emne: SV: [Wicket-user] wicket 1.2 beta 2 DropDownChoice default display value.. "Please Choose one" 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**/
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 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")
RE: [Wicket-user] wicket 1.2 beta 2 DropDownChoice default display value.. "Please Choose one"
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 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") .append(option).append(""); } }
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.johanP.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 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") .append(option).append(""); } } return buffer.toString(); } protected void onSelectionChanged(Object newSelection) { fill.setEnabled(true); invoke.setEnabled (true);
[Wicket-user] wicket 1.2 beta 2 DropDownChoice default display value.. "Please Choose one"
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 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") .append(option).append(""); } } return buffer.toString(); } protected void onSelectionChanged(Object newSelection) { fill.setEnabled(true); invoke.setEnabled(true); selectAll.setEnabled(true); deselectAll.setEnabled(true); btn_add.setEnabled(true);