You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Andrew Broderick <ab...@peak6u.com> on 2008/04/01 18:02:45 UTC

Simplest way to do name-value pairs in DropDownChoice

Hi,

I have looked around at several examples of using DropDownChoice. I see it is a very flexible component, with models, IChoiceRenderers and so on. But, I just want to pass it simple name/value pairs to use, with a minimum of fuss. Surely there must be an easy way to do this, since this is probably the main use case for this component. My pairs are just:

                              <option value="All Day">All Day</option>
                              <option value="7">7:00AM</option>
                              <option value="8">8:00AM</option>
                              <option value="9">9:00AM</option>
                              <option value="10">10:00AM</option>
                              <option value="11">11:00AM</option>
                              <option value="12">12:00PM</option>
                              <option value="13">1:00PM</option>
                              <option value="14">2:00PM</option>
                              <option value="15">3:00PM</option>
                              <option value="16">4:00PM</option>
                              <option value="17">5:00PM</option>
                              <option value="18">6:00PM</option>

In HTML. What is the simplest possible way to use these with DropDownChoice?

Thanks.


_______________________________________________________

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

Re: Simplest way to do name-value pairs in DropDownChoice

Posted by Alastair Maw <al...@gmail.com>.
Yikes. You're converting your domain data to some crazy type (NameValuePair)
just so you can display it differently. Not good.

Map<String, String> choices = new TreeMap<String, String>();
choices.put("foo", "Foo display value");

add(new DropDownChoice("foo", model, choices, new IChoiceRenderer() {
    Object getDisplayValue(Object object) {
        return choices.get(object);
    }
    String getIdValue(Object object, int index) {
        return object;
    }
});

Define that choice renderer in a separate class if you need to reuse it
across drop-downs. Call it a MapChoiceRenderer or something.

You really ought to try to use a more useful data type than a String in here
so you don't need to do lots of conversion later. It looks like you have
time intervals. Use a Joda Interval or TimeOfDay + Duration pair.

Unless you back your solution with a proper date/time library and
auto-generated values, your solution will fail when there is a day on a
daylight savings boundary, as you will either incorrectly display an hour
that doesn't exist, or you will not display the midnight hour twice (or
whatever the rules are for your particular timezone). I'd urge you to use
Joda or java.util.Calendar or similar to obviate the need to think about
this stuff too hard.

Regards,

Al

On Tue, Apr 1, 2008 at 7:26 PM, Andrew Broderick <ab...@peak6u.com>
wrote:

> Since it wasn't there, I extended DropDownChoice to encapsulate the whole
> name/value pair thing:
>
> package ****.****.****.helper.ui;
>
> import java.util.ArrayList;
> import java.util.List;
> import java.util.Map;
>
> import org.apache.wicket.markup.html.form.ChoiceRenderer;
> import org.apache.wicket.markup.html.form.DropDownChoice;
> import org.apache.wicket.model.AbstractPropertyModel;
>
> public class EasyDropDownChoice extends DropDownChoice
> {
>        public EasyDropDownChoice(String componentId, AbstractPropertyModel
> model, String[][] options)
>        {
>                this(componentId, model, toList(options));
>        }
>
>        public EasyDropDownChoice(String componentId, AbstractPropertyModel
> model, Map options)
>        {
>                this(componentId, model, toList(options));
>        }
>
>        public EasyDropDownChoice(String componentId, AbstractPropertyModel
> model, List<NameValuePair> options)
>        {
>                super(componentId, model, options, new
> ChoiceRenderer("value", "id"));
>        }
>
>        private static List<NameValuePair> toList(String[][] choices)
>        {
>                ArrayList<NameValuePair> options = new
> ArrayList<NameValuePair>();
>
>                for (int n = 0; n < choices.length; n++)
>                {
>                        options.add(new NameValuePair(choices[n][0],
> choices[n][1]));
>                }
>
>                return options;
>        }
>
>        private static List<NameValuePair> toList(Map<String, String>
> choices)
>        {
>                ArrayList<NameValuePair> options = new
> ArrayList<NameValuePair>();
>
>                for (String key: choices.keySet())
>                {
>                        options.add(new NameValuePair(key, choices.get
> (key)));
>                }
>
>                return options;
>        }
> }
>
> Which depends on:
>
> package ***.*****.****.helper.ui;
>
> import java.io.Serializable;
>
> public class NameValuePair implements Serializable
> {
>        private String id;
>        private String value;
>
>        public NameValuePair(String id, String value)
>        {
>                this.id = id;
>                this.value = value;
>        }
>
>        public String getId()
>        {
>                return id;
>        }
>
>        public void setId(String id)
>        {
>                this.id = id;
>        }
>
>        public String getValue()
>        {
>                return value;
>        }
>
>        public void setValue(String value)
>        {
>                this.value = value;
>        }
>
> }
>
> To initialize it with an array of choices, you now just have to do this:
>
> String[][] eventTimes = new String[][] { {"7:00:00", "7:00 AM"},
>
>                                       {"8:00:00", "8:00 AM"},
>
>                                       {"9:00:00", "9:00 AM"},
>
>                                       {"10:00:00", "10:00 AM"},
>
>                                       {"11:00:00", "11:00 AM"},
>
>                                       {"12:00:00", "12:00 PM"},
>
>                                       {"13:00:00", "1:00 PM"},
>
>                                       {"14:00:00", "2:00 PM"},
>
>                                       {"15:00:00", "3:00 PM"},
>
>                                       {"16:00:00", "4:00 PM"},
>
>                                       {"17:00:00", "5:00 PM"},
>
>                                       {"18:00:00", "6:00 PM"} };
>
> add(new EasyDropDownChoice("eventTime", new PropertyModel(this,
> "eventTime"), eventTimes));
>
> You can construct it with either a nested string array or a Map. Just have
> to make sure the property it's bound to is of type NameValuePair.
>
> -Andrew
>
> _______________________________________________________
>
> The  information in this email or in any file attached
> hereto is intended only for the personal and confiden-
> tial  use  of  the individual or entity to which it is
> addressed and may contain information that is  propri-
> etary  and  confidential.  If you are not the intended
> recipient of this message you are hereby notified that
> any  review, dissemination, distribution or copying of
> this message is strictly prohibited.  This  communica-
> tion  is  for information purposes only and should not
> be regarded as an offer to sell or as  a  solicitation
> of an offer to buy any financial product. Email trans-
> mission cannot be guaranteed to be  secure  or  error-
> free. P6070214
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: Simplest way to do name-value pairs in DropDownChoice

Posted by Andrew Broderick <ab...@peak6u.com>.
Since it wasn't there, I extended DropDownChoice to encapsulate the whole name/value pair thing:

package ****.****.****.helper.ui;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.model.AbstractPropertyModel;

public class EasyDropDownChoice extends DropDownChoice
{
        public EasyDropDownChoice(String componentId, AbstractPropertyModel model, String[][] options)
        {
                this(componentId, model, toList(options));
        }

        public EasyDropDownChoice(String componentId, AbstractPropertyModel model, Map options)
        {
                this(componentId, model, toList(options));
        }

        public EasyDropDownChoice(String componentId, AbstractPropertyModel model, List<NameValuePair> options)
        {
                super(componentId, model, options, new ChoiceRenderer("value", "id"));
        }

        private static List<NameValuePair> toList(String[][] choices)
        {
                ArrayList<NameValuePair> options = new ArrayList<NameValuePair>();

                for (int n = 0; n < choices.length; n++)
                {
                        options.add(new NameValuePair(choices[n][0], choices[n][1]));
                }

                return options;
        }

        private static List<NameValuePair> toList(Map<String, String> choices)
        {
                ArrayList<NameValuePair> options = new ArrayList<NameValuePair>();

                for (String key: choices.keySet())
                {
                        options.add(new NameValuePair(key, choices.get(key)));
                }

                return options;
        }
}

Which depends on:

package ***.*****.****.helper.ui;

import java.io.Serializable;

public class NameValuePair implements Serializable
{
        private String id;
        private String value;

        public NameValuePair(String id, String value)
        {
                this.id = id;
                this.value = value;
        }

        public String getId()
        {
                return id;
        }

        public void setId(String id)
        {
                this.id = id;
        }

        public String getValue()
        {
                return value;
        }

        public void setValue(String value)
        {
                this.value = value;
        }

}

To initialize it with an array of choices, you now just have to do this:

String[][] eventTimes = new String[][] { {"7:00:00", "7:00 AM"},
                                                                                                                 {"8:00:00", "8:00 AM"},
                                                                                                                 {"9:00:00", "9:00 AM"},
                                                                                                                 {"10:00:00", "10:00 AM"},
                                                                                                                 {"11:00:00", "11:00 AM"},
                                                                                                                 {"12:00:00", "12:00 PM"},
                                                                                                                 {"13:00:00", "1:00 PM"},
                                                                                                                 {"14:00:00", "2:00 PM"},
                                                                                                                 {"15:00:00", "3:00 PM"},
                                                                                                                 {"16:00:00", "4:00 PM"},
                                                                                                                 {"17:00:00", "5:00 PM"},
                                                                                                                 {"18:00:00", "6:00 PM"} };

add(new EasyDropDownChoice("eventTime", new PropertyModel(this, "eventTime"), eventTimes));

You can construct it with either a nested string array or a Map. Just have to make sure the property it's bound to is of type NameValuePair.

-Andrew

_______________________________________________________

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

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


Re: Simplest way to do name-value pairs in DropDownChoice

Posted by Ryan Gravener <ry...@ryangravener.com>.
set the choicerenderer

setChoiceRenderer(new IChoiceRenderer() {
		public Object getDisplayValue(Object object) {
			return ((MyEnum) object).getTime();
		}

		public String getIdValue(Object object, int index) {
			return String.valueOf(((MyEnum) object).ordinal());
		}
});

On Tue, Apr 1, 2008 at 1:53 PM, Andrew Broderick <ab...@peak6u.com> wrote:
> Wicket 1.3 does not have a class called SelectOption. I downloade Wicket Extension to obtain it, but found it to be incompatible with Wicket 1.3.
>
>  -Andrew
>
>
>  -----Original Message-----
>  From: jelevy@gmail.com [mailto:jelevy@gmail.com] On Behalf Of Jeremy Levy
>
>
> Sent: Tuesday, April 01, 2008 12:26 PM
>  To: users@wicket.apache.org
>  Subject: Re: Simplest way to do name-value pairs in DropDownChoice
>
>  Its just a class with a get/set Value and Id
>
>  j
>
>  On Tue, Apr 1, 2008 at 12:50 PM, Andrew Broderick <ab...@peak6u.com>
>  wrote:
>
>  > I am using Wicket 1.3. Has Wicket Extensions been updated to 1.3? I got
>  > the latest Extensions, but seem to be getting errors.
>  >
>  > Thanks
>  >
>  > -----Original Message-----
>  > From: jelevy@gmail.com [mailto:jelevy@gmail.com] On Behalf Of Jeremy Levy
>  > Sent: Tuesday, April 01, 2008 11:17 AM
>  > To: users@wicket.apache.org
>  > Subject: Re: Simplest way to do name-value pairs in DropDownChoice
>  >
>  > I think you are going to have to use a ChoiceRenderer. It's really not
>  > that
>  > complicated. Check out
>  >
>  >
>  > http://people.apache.org/~tobrien/wicket/apidocs/org/apache/wicket/extensions/markup/html/form/select/SelectOption.html<http://people.apache.org/%7Etobrien/wicket/apidocs/org/apache/wicket/extensions/markup/html/form/select/SelectOption.html>
>  >
>  > Jeremy
>  >
>  > On Tue, Apr 1, 2008 at 12:02 PM, Andrew Broderick <ab...@peak6u.com>
>  > wrote:
>  >
>  > > Hi,
>  > >
>  > > I have looked around at several examples of using DropDownChoice. I see
>  > it
>  > > is a very flexible component, with models, IChoiceRenderers and so on.
>  > But,
>  > > I just want to pass it simple name/value pairs to use, with a minimum of
>  > > fuss. Surely there must be an easy way to do this, since this is
>  > probably
>  > > the main use case for this component. My pairs are just:
>  > >
>  > >                              <option value="All Day">All Day</option>
>  > >                              <option value="7">7:00AM</option>
>  > >                              <option value="8">8:00AM</option>
>  > >                              <option value="9">9:00AM</option>
>  > >                              <option value="10">10:00AM</option>
>  > >                              <option value="11">11:00AM</option>
>  > >                              <option value="12">12:00PM</option>
>  > >                              <option value="13">1:00PM</option>
>  > >                              <option value="14">2:00PM</option>
>  > >                              <option value="15">3:00PM</option>
>  > >                              <option value="16">4:00PM</option>
>  > >                              <option value="17">5:00PM</option>
>  > >                              <option value="18">6:00PM</option>
>  > >
>  > > In HTML. What is the simplest possible way to use these with
>  > > DropDownChoice?
>  > >
>  > > Thanks.
>  > >
>  > >
>  > > _______________________________________________________
>  > >
>  > > The  information in this email or in any file attached
>  > > hereto is intended only for the personal and confiden-
>  > > tial  use  of  the individual or entity to which it is
>  > > addressed and may contain information that is  propri-
>  > > etary  and  confidential.  If you are not the intended
>  > > recipient of this message you are hereby notified that
>  > > any  review, dissemination, distribution or copying of
>  > > this message is strictly prohibited.  This  communica-
>  > > tion  is  for information purposes only and should not
>  > > be regarded as an offer to sell or as  a  solicitation
>  > > of an offer to buy any financial product. Email trans-
>  > > mission cannot be guaranteed to be  secure  or  error-
>  > > free. P6070214
>  > >
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  > For additional commands, e-mail: users-help@wicket.apache.org
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Ryan Gravener
http://ryangravener.com

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


RE: Simplest way to do name-value pairs in DropDownChoice

Posted by Andrew Broderick <ab...@peak6u.com>.
Wicket 1.3 does not have a class called SelectOption. I downloade Wicket Extension to obtain it, but found it to be incompatible with Wicket 1.3.

-Andrew

-----Original Message-----
From: jelevy@gmail.com [mailto:jelevy@gmail.com] On Behalf Of Jeremy Levy
Sent: Tuesday, April 01, 2008 12:26 PM
To: users@wicket.apache.org
Subject: Re: Simplest way to do name-value pairs in DropDownChoice

Its just a class with a get/set Value and Id

j

On Tue, Apr 1, 2008 at 12:50 PM, Andrew Broderick <ab...@peak6u.com>
wrote:

> I am using Wicket 1.3. Has Wicket Extensions been updated to 1.3? I got
> the latest Extensions, but seem to be getting errors.
>
> Thanks
>
> -----Original Message-----
> From: jelevy@gmail.com [mailto:jelevy@gmail.com] On Behalf Of Jeremy Levy
> Sent: Tuesday, April 01, 2008 11:17 AM
> To: users@wicket.apache.org
> Subject: Re: Simplest way to do name-value pairs in DropDownChoice
>
> I think you are going to have to use a ChoiceRenderer. It's really not
> that
> complicated. Check out
>
>
> http://people.apache.org/~tobrien/wicket/apidocs/org/apache/wicket/extensions/markup/html/form/select/SelectOption.html<http://people.apache.org/%7Etobrien/wicket/apidocs/org/apache/wicket/extensions/markup/html/form/select/SelectOption.html>
>
> Jeremy
>
> On Tue, Apr 1, 2008 at 12:02 PM, Andrew Broderick <ab...@peak6u.com>
> wrote:
>
> > Hi,
> >
> > I have looked around at several examples of using DropDownChoice. I see
> it
> > is a very flexible component, with models, IChoiceRenderers and so on.
> But,
> > I just want to pass it simple name/value pairs to use, with a minimum of
> > fuss. Surely there must be an easy way to do this, since this is
> probably
> > the main use case for this component. My pairs are just:
> >
> >                              <option value="All Day">All Day</option>
> >                              <option value="7">7:00AM</option>
> >                              <option value="8">8:00AM</option>
> >                              <option value="9">9:00AM</option>
> >                              <option value="10">10:00AM</option>
> >                              <option value="11">11:00AM</option>
> >                              <option value="12">12:00PM</option>
> >                              <option value="13">1:00PM</option>
> >                              <option value="14">2:00PM</option>
> >                              <option value="15">3:00PM</option>
> >                              <option value="16">4:00PM</option>
> >                              <option value="17">5:00PM</option>
> >                              <option value="18">6:00PM</option>
> >
> > In HTML. What is the simplest possible way to use these with
> > DropDownChoice?
> >
> > Thanks.
> >
> >
> > _______________________________________________________
> >
> > The  information in this email or in any file attached
> > hereto is intended only for the personal and confiden-
> > tial  use  of  the individual or entity to which it is
> > addressed and may contain information that is  propri-
> > etary  and  confidential.  If you are not the intended
> > recipient of this message you are hereby notified that
> > any  review, dissemination, distribution or copying of
> > this message is strictly prohibited.  This  communica-
> > tion  is  for information purposes only and should not
> > be regarded as an offer to sell or as  a  solicitation
> > of an offer to buy any financial product. Email trans-
> > mission cannot be guaranteed to be  secure  or  error-
> > free. P6070214
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Simplest way to do name-value pairs in DropDownChoice

Posted by Jeremy Levy <je...@meetmoi.com>.
Its just a class with a get/set Value and Id

j

On Tue, Apr 1, 2008 at 12:50 PM, Andrew Broderick <ab...@peak6u.com>
wrote:

> I am using Wicket 1.3. Has Wicket Extensions been updated to 1.3? I got
> the latest Extensions, but seem to be getting errors.
>
> Thanks
>
> -----Original Message-----
> From: jelevy@gmail.com [mailto:jelevy@gmail.com] On Behalf Of Jeremy Levy
> Sent: Tuesday, April 01, 2008 11:17 AM
> To: users@wicket.apache.org
> Subject: Re: Simplest way to do name-value pairs in DropDownChoice
>
> I think you are going to have to use a ChoiceRenderer. It's really not
> that
> complicated. Check out
>
>
> http://people.apache.org/~tobrien/wicket/apidocs/org/apache/wicket/extensions/markup/html/form/select/SelectOption.html<http://people.apache.org/%7Etobrien/wicket/apidocs/org/apache/wicket/extensions/markup/html/form/select/SelectOption.html>
>
> Jeremy
>
> On Tue, Apr 1, 2008 at 12:02 PM, Andrew Broderick <ab...@peak6u.com>
> wrote:
>
> > Hi,
> >
> > I have looked around at several examples of using DropDownChoice. I see
> it
> > is a very flexible component, with models, IChoiceRenderers and so on.
> But,
> > I just want to pass it simple name/value pairs to use, with a minimum of
> > fuss. Surely there must be an easy way to do this, since this is
> probably
> > the main use case for this component. My pairs are just:
> >
> >                              <option value="All Day">All Day</option>
> >                              <option value="7">7:00AM</option>
> >                              <option value="8">8:00AM</option>
> >                              <option value="9">9:00AM</option>
> >                              <option value="10">10:00AM</option>
> >                              <option value="11">11:00AM</option>
> >                              <option value="12">12:00PM</option>
> >                              <option value="13">1:00PM</option>
> >                              <option value="14">2:00PM</option>
> >                              <option value="15">3:00PM</option>
> >                              <option value="16">4:00PM</option>
> >                              <option value="17">5:00PM</option>
> >                              <option value="18">6:00PM</option>
> >
> > In HTML. What is the simplest possible way to use these with
> > DropDownChoice?
> >
> > Thanks.
> >
> >
> > _______________________________________________________
> >
> > The  information in this email or in any file attached
> > hereto is intended only for the personal and confiden-
> > tial  use  of  the individual or entity to which it is
> > addressed and may contain information that is  propri-
> > etary  and  confidential.  If you are not the intended
> > recipient of this message you are hereby notified that
> > any  review, dissemination, distribution or copying of
> > this message is strictly prohibited.  This  communica-
> > tion  is  for information purposes only and should not
> > be regarded as an offer to sell or as  a  solicitation
> > of an offer to buy any financial product. Email trans-
> > mission cannot be guaranteed to be  secure  or  error-
> > free. P6070214
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: Simplest way to do name-value pairs in DropDownChoice

Posted by Andrew Broderick <ab...@peak6u.com>.
I am using Wicket 1.3. Has Wicket Extensions been updated to 1.3? I got the latest Extensions, but seem to be getting errors.

Thanks

-----Original Message-----
From: jelevy@gmail.com [mailto:jelevy@gmail.com] On Behalf Of Jeremy Levy
Sent: Tuesday, April 01, 2008 11:17 AM
To: users@wicket.apache.org
Subject: Re: Simplest way to do name-value pairs in DropDownChoice

I think you are going to have to use a ChoiceRenderer. It's really not that
complicated. Check out

http://people.apache.org/~tobrien/wicket/apidocs/org/apache/wicket/extensions/markup/html/form/select/SelectOption.html

Jeremy

On Tue, Apr 1, 2008 at 12:02 PM, Andrew Broderick <ab...@peak6u.com>
wrote:

> Hi,
>
> I have looked around at several examples of using DropDownChoice. I see it
> is a very flexible component, with models, IChoiceRenderers and so on. But,
> I just want to pass it simple name/value pairs to use, with a minimum of
> fuss. Surely there must be an easy way to do this, since this is probably
> the main use case for this component. My pairs are just:
>
>                              <option value="All Day">All Day</option>
>                              <option value="7">7:00AM</option>
>                              <option value="8">8:00AM</option>
>                              <option value="9">9:00AM</option>
>                              <option value="10">10:00AM</option>
>                              <option value="11">11:00AM</option>
>                              <option value="12">12:00PM</option>
>                              <option value="13">1:00PM</option>
>                              <option value="14">2:00PM</option>
>                              <option value="15">3:00PM</option>
>                              <option value="16">4:00PM</option>
>                              <option value="17">5:00PM</option>
>                              <option value="18">6:00PM</option>
>
> In HTML. What is the simplest possible way to use these with
> DropDownChoice?
>
> Thanks.
>
>
> _______________________________________________________
>
> The  information in this email or in any file attached
> hereto is intended only for the personal and confiden-
> tial  use  of  the individual or entity to which it is
> addressed and may contain information that is  propri-
> etary  and  confidential.  If you are not the intended
> recipient of this message you are hereby notified that
> any  review, dissemination, distribution or copying of
> this message is strictly prohibited.  This  communica-
> tion  is  for information purposes only and should not
> be regarded as an offer to sell or as  a  solicitation
> of an offer to buy any financial product. Email trans-
> mission cannot be guaranteed to be  secure  or  error-
> free. P6070214
>

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


Re: Simplest way to do name-value pairs in DropDownChoice

Posted by Jeremy Levy <je...@meetmoi.com>.
I think you are going to have to use a ChoiceRenderer. It's really not that
complicated. Check out

http://people.apache.org/~tobrien/wicket/apidocs/org/apache/wicket/extensions/markup/html/form/select/SelectOption.html

Jeremy

On Tue, Apr 1, 2008 at 12:02 PM, Andrew Broderick <ab...@peak6u.com>
wrote:

> Hi,
>
> I have looked around at several examples of using DropDownChoice. I see it
> is a very flexible component, with models, IChoiceRenderers and so on. But,
> I just want to pass it simple name/value pairs to use, with a minimum of
> fuss. Surely there must be an easy way to do this, since this is probably
> the main use case for this component. My pairs are just:
>
>                              <option value="All Day">All Day</option>
>                              <option value="7">7:00AM</option>
>                              <option value="8">8:00AM</option>
>                              <option value="9">9:00AM</option>
>                              <option value="10">10:00AM</option>
>                              <option value="11">11:00AM</option>
>                              <option value="12">12:00PM</option>
>                              <option value="13">1:00PM</option>
>                              <option value="14">2:00PM</option>
>                              <option value="15">3:00PM</option>
>                              <option value="16">4:00PM</option>
>                              <option value="17">5:00PM</option>
>                              <option value="18">6:00PM</option>
>
> In HTML. What is the simplest possible way to use these with
> DropDownChoice?
>
> Thanks.
>
>
> _______________________________________________________
>
> The  information in this email or in any file attached
> hereto is intended only for the personal and confiden-
> tial  use  of  the individual or entity to which it is
> addressed and may contain information that is  propri-
> etary  and  confidential.  If you are not the intended
> recipient of this message you are hereby notified that
> any  review, dissemination, distribution or copying of
> this message is strictly prohibited.  This  communica-
> tion  is  for information purposes only and should not
> be regarded as an offer to sell or as  a  solicitation
> of an offer to buy any financial product. Email trans-
> mission cannot be guaranteed to be  secure  or  error-
> free. P6070214
>