You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eric Reagan <re...@gmail.com> on 2010/07/27 21:01:35 UTC
How to set the value of a Drop Down Choice
Hello,
I was wondering how to set the currently selected value for a
DropDownList? Currently I have a .properties file which sets the value when
I have a null selection, however, I was wondering how do I change the
currently selected value to a different one (e.g. if I am pulling a
previous selection from a database?)
Thank you,
--
Eric Reagan
Re: How to set the value of a Drop Down Choice
Posted by vov <vo...@mail.ru>.
Hi
There are mistake in your code:
programList.setDefaultModelObject(stringObjectModel);
...may be you want to call programList.setDefaultModel(stringObjectModel);
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-set-the-value-of-a-Drop-Down-Choice-tp2303973p2304514.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to set the value of a Drop Down Choice
Posted by Eric Reagan <re...@gmail.com>.
Martin,
Thanks for the advice. I had a mental fart and left out the setter
function. Once you add the setter...works like a charm. Thanks again.
Thank you,
On Tue, Jul 27, 2010 at 2:34 PM, Eric Reagan <re...@gmail.com> wrote:
> Martin,
> I have the following. All I am getting is a null value. Am I setting
> the model object wrong?
>
> IModel<String> stringObjectModel = new LoadableDetachableModel<
> String>()
> {
> /**
> *
> */
> private static final long serialVersionUID =
> 2165619560012612599L;
> private String text;
>
> @Override
> protected String load()
> {
> return text;
> }
>
> };
>
> stringObjectModel.setObject("abc");
>
> DropDownChoice<String> programList = new
> DropDownChoice<String>("users",stringObjectModel, users.getAll(), new
> IChoiceRenderer<Object>()
> {
> /**
> * Generated
> */
> private static final long serialVersionUID = -7278851941695545331L;
>
> @Override
> public Object getDisplayValue(Object object)
> {
> return object.toString();
> }
>
> @Override
> public String getIdValue(Object object, int index)
> {
> object.toString()
> }
> }
> );
>
> programList.setDefaultModelObject(stringObjectModel);
>
>
> On Tue, Jul 27, 2010 at 2:33 PM, Eric Reagan <re...@gmail.com> wrote:
>
>> Martin,
>> I have the following. All I am getting is a null value. Am I setting
>> the model object wrong?
>>
>> IModel<String> stringObjectModel = new LoadableDetachableModel<String>()
>> {
>> /**
>> *
>> */
>> private static final long serialVersionUID =
>> 2165619560012612599L;
>> private String text;
>>
>> @Override
>> protected String load()
>> {
>> return text;
>> }
>>
>> };
>>
>> stringObjectModel.setObject("abc");
>>
>> DropDownChoice<String> programList = new
>> DropDownChoice<String>("users",stringObjectModel, users.getAll(), new
>> IChoiceRenderer<Object>()
>> {
>> /**
>> * Generated
>> */
>> private static final long serialVersionUID = -7278851941695545331L;
>>
>> @Override
>> public Object getDisplayValue(Object object)
>> {
>> return object.toString();
>> }
>>
>> @Override
>> public String getIdValue(Object object, int index)
>> {
>> object.toString()
>> }
>> }
>> );
>>
>> programList.setDefaultModelObject(stringObjectModel);
>>
>>
>>
>> On Tue, Jul 27, 2010 at 2:05 PM, Martin Makundi <
>> martin.makundi@koodaripalvelut.com> wrote:
>>
>>> Have you tried if setDefaultModelObject() works for you?
>>>
>>> **
>>> Martin
>>>
>>> 2010/7/27 Eric Reagan <re...@gmail.com>:
>>> > Hello,
>>> > I was wondering how to set the currently selected value for a
>>> > DropDownList? Currently I have a .properties file which sets the value
>>> when
>>> > I have a null selection, however, I was wondering how do I change the
>>> > currently selected value to a different one (e.g. if I am pulling a
>>> > previous selection from a database?)
>>> > Thank you,
>>> >
>>> > --
>>> > Eric Reagan
>>> >
>>>
>>
>>
>>
>> --
>> Eric Reagan
>>
>
>
>
> --
> Eric Reagan
>
--
Eric Reagan
Re: How to set the value of a Drop Down Choice
Posted by James Carman <ja...@carmanconsulting.com>.
Why not set up a property on your page/component for the selected text
and use a PropertyModel<String>?
On Tue, Jul 27, 2010 at 3:34 PM, Eric Reagan <re...@gmail.com> wrote:
> Martin,
> I have the following. All I am getting is a null value. Am I setting the
> model object wrong?
>
> IModel<String> stringObjectModel = new LoadableDetachableModel<
> String>()
> {
> /**
> *
> */
> private static final long serialVersionUID =
> 2165619560012612599L;
> private String text;
>
> @Override
> protected String load()
> {
> return text;
> }
>
> };
>
> stringObjectModel.setObject("abc");
>
> DropDownChoice<String> programList = new
> DropDownChoice<String>("users",stringObjectModel, users.getAll(), new
> IChoiceRenderer<Object>()
> {
> /**
> * Generated
> */
> private static final long serialVersionUID = -7278851941695545331L;
>
> @Override
> public Object getDisplayValue(Object object)
> {
> return object.toString();
> }
>
> @Override
> public String getIdValue(Object object, int index)
> {
> object.toString()
> }
> }
> );
>
> programList.setDefaultModelObject(stringObjectModel);
>
>
> On Tue, Jul 27, 2010 at 2:33 PM, Eric Reagan <re...@gmail.com> wrote:
>
>> Martin,
>> I have the following. All I am getting is a null value. Am I setting
>> the model object wrong?
>>
>> IModel<String> stringObjectModel = new LoadableDetachableModel<String>()
>> {
>> /**
>> *
>> */
>> private static final long serialVersionUID =
>> 2165619560012612599L;
>> private String text;
>>
>> @Override
>> protected String load()
>> {
>> return text;
>> }
>>
>> };
>>
>> stringObjectModel.setObject("abc");
>>
>> DropDownChoice<String> programList = new
>> DropDownChoice<String>("users",stringObjectModel, users.getAll(), new
>> IChoiceRenderer<Object>()
>> {
>> /**
>> * Generated
>> */
>> private static final long serialVersionUID = -7278851941695545331L;
>>
>> @Override
>> public Object getDisplayValue(Object object)
>> {
>> return object.toString();
>> }
>>
>> @Override
>> public String getIdValue(Object object, int index)
>> {
>> object.toString()
>> }
>> }
>> );
>>
>> programList.setDefaultModelObject(stringObjectModel);
>>
>>
>>
>> On Tue, Jul 27, 2010 at 2:05 PM, Martin Makundi <
>> martin.makundi@koodaripalvelut.com> wrote:
>>
>>> Have you tried if setDefaultModelObject() works for you?
>>>
>>> **
>>> Martin
>>>
>>> 2010/7/27 Eric Reagan <re...@gmail.com>:
>>> > Hello,
>>> > I was wondering how to set the currently selected value for a
>>> > DropDownList? Currently I have a .properties file which sets the value
>>> when
>>> > I have a null selection, however, I was wondering how do I change the
>>> > currently selected value to a different one (e.g. if I am pulling a
>>> > previous selection from a database?)
>>> > Thank you,
>>> >
>>> > --
>>> > Eric Reagan
>>> >
>>>
>>
>>
>>
>> --
>> Eric Reagan
>>
>
>
>
> --
> Eric Reagan
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to set the value of a Drop Down Choice
Posted by Eric Reagan <re...@gmail.com>.
Martin,
I have the following. All I am getting is a null value. Am I setting the
model object wrong?
IModel<String> stringObjectModel = new LoadableDetachableModel<
String>()
{
/**
*
*/
private static final long serialVersionUID =
2165619560012612599L;
private String text;
@Override
protected String load()
{
return text;
}
};
stringObjectModel.setObject("abc");
DropDownChoice<String> programList = new
DropDownChoice<String>("users",stringObjectModel, users.getAll(), new
IChoiceRenderer<Object>()
{
/**
* Generated
*/
private static final long serialVersionUID = -7278851941695545331L;
@Override
public Object getDisplayValue(Object object)
{
return object.toString();
}
@Override
public String getIdValue(Object object, int index)
{
object.toString()
}
}
);
programList.setDefaultModelObject(stringObjectModel);
On Tue, Jul 27, 2010 at 2:33 PM, Eric Reagan <re...@gmail.com> wrote:
> Martin,
> I have the following. All I am getting is a null value. Am I setting
> the model object wrong?
>
> IModel<String> stringObjectModel = new LoadableDetachableModel<String>()
> {
> /**
> *
> */
> private static final long serialVersionUID =
> 2165619560012612599L;
> private String text;
>
> @Override
> protected String load()
> {
> return text;
> }
>
> };
>
> stringObjectModel.setObject("abc");
>
> DropDownChoice<String> programList = new
> DropDownChoice<String>("users",stringObjectModel, users.getAll(), new
> IChoiceRenderer<Object>()
> {
> /**
> * Generated
> */
> private static final long serialVersionUID = -7278851941695545331L;
>
> @Override
> public Object getDisplayValue(Object object)
> {
> return object.toString();
> }
>
> @Override
> public String getIdValue(Object object, int index)
> {
> object.toString()
> }
> }
> );
>
> programList.setDefaultModelObject(stringObjectModel);
>
>
>
> On Tue, Jul 27, 2010 at 2:05 PM, Martin Makundi <
> martin.makundi@koodaripalvelut.com> wrote:
>
>> Have you tried if setDefaultModelObject() works for you?
>>
>> **
>> Martin
>>
>> 2010/7/27 Eric Reagan <re...@gmail.com>:
>> > Hello,
>> > I was wondering how to set the currently selected value for a
>> > DropDownList? Currently I have a .properties file which sets the value
>> when
>> > I have a null selection, however, I was wondering how do I change the
>> > currently selected value to a different one (e.g. if I am pulling a
>> > previous selection from a database?)
>> > Thank you,
>> >
>> > --
>> > Eric Reagan
>> >
>>
>
>
>
> --
> Eric Reagan
>
--
Eric Reagan
Re: How to set the value of a Drop Down Choice
Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Have you tried if setDefaultModelObject() works for you?
**
Martin
2010/7/27 Eric Reagan <re...@gmail.com>:
> Hello,
> I was wondering how to set the currently selected value for a
> DropDownList? Currently I have a .properties file which sets the value when
> I have a null selection, however, I was wondering how do I change the
> currently selected value to a different one (e.g. if I am pulling a
> previous selection from a database?)
> Thank you,
>
> --
> Eric Reagan
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org