Re: How to set the value of a Drop Down Choice

2010-07-28 Thread vov

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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



How to set the value of a Drop Down Choice

2010-07-27 Thread Eric Reagan
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

2010-07-27 Thread Martin Makundi
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


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



Re: How to set the value of a Drop Down Choice

2010-07-27 Thread Eric Reagan
Martin,
I have the following. All I am getting is a null value. Am I setting the
model object wrong?

IModelString stringObjectModel = new LoadableDetachableModel
String()
{
/**
 *
 */
private static final long serialVersionUID =
2165619560012612599L;
private String text;

@Override
protected String load()
{
return text;
}

};

stringObjectModel.setObject(abc);

DropDownChoiceString programList = new
DropDownChoiceString(users,stringObjectModel, users.getAll(), new
IChoiceRendererObject()
{
/**
 * 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?

 IModelString stringObjectModel = new LoadableDetachableModelString()
 {
 /**
  *
  */
 private static final long serialVersionUID =
 2165619560012612599L;
 private String text;

 @Override
 protected String load()
 {
 return text;
 }

 };

 stringObjectModel.setObject(abc);

 DropDownChoiceString programList = new
 DropDownChoiceString(users,stringObjectModel, users.getAll(), new
 IChoiceRendererObject()
 {
 /**
  * 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


Re: How to set the value of a Drop Down Choice

2010-07-27 Thread Eric Reagan
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 reaga...@gmail.com wrote:

 Martin,
 I have the following. All I am getting is a null value. Am I setting
 the model object wrong?

 IModelString stringObjectModel = new LoadableDetachableModel
 String()
 {
 /**
  *
  */
 private static final long serialVersionUID =
 2165619560012612599L;
 private String text;

 @Override
 protected String load()
 {
 return text;
 }

 };

 stringObjectModel.setObject(abc);

 DropDownChoiceString programList = new
 DropDownChoiceString(users,stringObjectModel, users.getAll(), new
 IChoiceRendererObject()
 {
 /**
  * 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?

 IModelString stringObjectModel = new LoadableDetachableModelString()
 {
 /**
  *
  */
 private static final long serialVersionUID =
 2165619560012612599L;
 private String text;

 @Override
 protected String load()
 {
 return text;
 }

 };

 stringObjectModel.setObject(abc);

 DropDownChoiceString programList = new
 DropDownChoiceString(users,stringObjectModel, users.getAll(), new
 IChoiceRendererObject()
 {
 /**
  * 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




-- 
Eric Reagan


Re: How to set the value of a Drop Down Choice

2010-07-27 Thread James Carman
Why not set up a property on your page/component for the selected text
and use a PropertyModelString?

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?

 IModelString stringObjectModel = new LoadableDetachableModel
 String()
        {
            /**
             *
             */
            private static final long serialVersionUID =
 2165619560012612599L;
            private String text;

           �...@override
            protected String load()
            {
                return text;
            }

        };

 stringObjectModel.setObject(abc);

 DropDownChoiceString programList = new
 DropDownChoiceString(users,stringObjectModel, users.getAll(), new
 IChoiceRendererObject()
 {
    /**
     * 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?

 IModelString stringObjectModel = new LoadableDetachableModelString()
         {
             /**
              *
              */
             private static final long serialVersionUID =
 2165619560012612599L;
             private String text;

             @Override
             protected String load()
             {
                 return text;
             }

         };

 stringObjectModel.setObject(abc);

 DropDownChoiceString programList = new
 DropDownChoiceString(users,stringObjectModel, users.getAll(), new
 IChoiceRendererObject()
 {
     /**
      * 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