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 <reaga...@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 <reaga...@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.maku...@koodaripalvelut.com> wrote:
>>
>>> Have you tried if setDefaultModelObject() works for you?
>>>
>>> **
>>> Martin
>>>
>>> 2010/7/27 Eric Reagan <reaga...@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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to