Re: How to set the initially selected value of a DropDownChoice?

2008-03-20 Thread Kaspar Fischer
Thanks for the helpful link, Martijn. For the sake of completeness,  
here's

what I have ended up with:

  List PagerSizesList = Arrays.asList("25", "50", "100");

  ValueMap parameters = // ...
  parameters.put("search-page-size", PagerSizesList.get(0));

  form.setModel(new CompoundPropertyModel(parameters));
  form.add(new DropDownChoice("search-page-size", PagerSizesList));

On 19.03.2008, at 23:29, Martijn Dashorst wrote:


Start by reading this: http://wicket.apache.org/exampledropdownchoice.html

On 3/19/08, Kaspar Fischer <[EMAIL PROTECTED]> wrote:

How can I set the default value of a required DropDownChoice that
should not have null values?

  private static final List PagerSizesList =
Arrays.asList("25", "50", "100");

  // in constructor...
  DropDownChoice pagerSizer = new DropDownChoice("search-page-size",
PagerSizesList);
  add(pagerSizer);

I've tried overriding my DropDownChoice's getDefaultChoice(),

  @Override
  protected CharSequence getDefaultChoice(final Object selected)
  {
return "" + PagerSizesList.get(0) + "";
  }

but this replaces the label of the null string, but does not remove
the null string itself.

Thanks and best wishes,
Kaspar


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to set the initially selected value of a DropDownChoice?

2008-03-19 Thread Martijn Dashorst
Start by reading this: http://wicket.apache.org/exampledropdownchoice.html

On 3/19/08, Kaspar Fischer <[EMAIL PROTECTED]> wrote:
> How can I set the default value of a required DropDownChoice that
>  should not have null values?
>
>private static final List PagerSizesList =
>  Arrays.asList("25", "50", "100");
>
>// in constructor...
>DropDownChoice pagerSizer = new DropDownChoice("search-page-size",
>  PagerSizesList);
>add(pagerSizer);
>
>  I've tried overriding my DropDownChoice's getDefaultChoice(),
>
>@Override
>protected CharSequence getDefaultChoice(final Object selected)
>{
>  return "" + PagerSizesList.get(0) + "  option>";
>}
>
>  but this replaces the label of the null string, but does not remove
>  the null string itself.
>
>  Thanks and best wishes,
>  Kaspar
>
>  -
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.2 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.2

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How to set the initially selected value of a DropDownChoice?

2008-03-19 Thread Kaspar Fischer

How can I set the default value of a required DropDownChoice that
should not have null values?

  private static final List PagerSizesList =  
Arrays.asList("25", "50", "100");


  // in constructor...
  DropDownChoice pagerSizer = new DropDownChoice("search-page-size",  
PagerSizesList);

  add(pagerSizer);

I've tried overriding my DropDownChoice's getDefaultChoice(),

  @Override
  protected CharSequence getDefaultChoice(final Object selected)
  {
return "" + PagerSizesList.get(0) + "option>";

  }

but this replaces the label of the null string, but does not remove
the null string itself.

Thanks and best wishes,
Kaspar

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]