Re: DropDownChoice and selected value...

2010-01-09 Thread Martin Makundi
Yeah, or implement IChoiceRenderer?

2010/1/10 Pieter Degraeuwe :
> check your equals() method of the selected object's classes
>
> On Sun, Jan 10, 2010 at 7:03 AM, Facundo Miquel 
> wrote:
>
>> Hi, thanks for the tip.. unfortunately , I tried this, (a shorter version
>> at
>> least..)
>>
>> add(    new DropDownChoice("userProfile.city",
>>                    new PropertyModel(this.getModel(), "userProfile.city"),
>>                    new LoadableDetachableModel() {
>>                       �...@override
>>                        protected Object load() {
>>                            return sysMultivaluesProvider.getMVList("CITY");
>>                        }
>>                    }
>>                )
>> );
>>
>> but the problem is the same the selected value is persisted into the
>> database but when I edit the record the value is not "selected"  in the
>> dropdown.. any clues?
>>
>> I'm obviously missing something!!
>>
>> TIA
>>
>>
>> On Thu, Jan 7, 2010 at 1:43 PM, Kogel, Jonck-van-der <
>> jonck-van-der.ko...@bmw.nl> wrote:
>>
>> > Hi,
>> > I also had this problem once. It turned out to have to do with my list
>> > of choices becoming stale. I solved this by putting the choices in a
>> > LoadableDetachableModel.
>> >
>> > ie:
>> >
>> > IModel> yourObjectsModel = new
>> > LoadableDetachableModel>() {
>> > �...@override
>> >  protected List load() {
>> >  return yourObjectService.findAll();
>> >  }
>> >
>> > };
>> >
>> > add(new YourDropDownChoice("foo",
>> >  new PropertyModel(yourModel, "bar"),
>> >  yourObjectsModel));
>> >
>> >
>> > 
>> >
>> > From: Facundo Miquel [mailto:facu...@easytech.com.ar]
>> > Sent: donderdag 7 januari 2010 15:18
>> > To: users@wicket.apache.org
>> > Subject: DropDownChoice and selected value...
>> >
>> >
>> > Hello all..
>> >
>> > First of all, I know that this has been discussed here, I searched the
>> > archives but could not find an answer, or at least understand one, so
>> > please If someone can help me I would greatly appreciate it...
>> >
>> >
>> > I have a small problem with Drop Down Choices and the selected value
>> > when editing an existing record... and I wanted to validate that I'm
>> > doing things the correct way.. and if so.. if there is a known issue
>> >
>> > the scenario is as follows...
>> >
>> > I created an extended class (just to simplify my work) to generate DDC
>> > from a multivalues tables (aka, a table where one holds different types
>> > of things.. countries, cities, status codes, etc..).
>> >
>> > The rest of the mail will be in RED for readability...
>> >
>> > In my tables I'm required to store the code and not the value so
>> > basically I created the following class..(these are fractions.. I'm
>> > attaching the actual clasess..)
>> >
>> > public class mvDropDownChoice extends DropDownChoice {
>> > ...
>> > static List mvValues = null;
>> > @SuppressWarnings("serial")
>> > public mvDropDownChoice(String id, String mvCode, IModel model) {
>> > super(id, new PropertyModel(model,
>> > id),sysMultivaluesProvider.getMVList(mvCode),new IChoiceRenderer() {
>> > public String getDisplayValue(Object object) {
>> >        SysMultivalues mv = (SysMultivalues) object;
>> >        return mv.getMvMeaning();
>> >    }
>> >    public String getIdValue(Object object, int index) {
>> >    if (index == -1)
>> >    return null;
>> >    return ((SysMultivalues)mvValues.get(index)).getMvCode();
>> >    }
>> > });
>> > mvValues = sysMultivaluesProvider.getMVList(mvCode);
>> > }
>> > ...
>> > ..
>> >
>> >
>> > now I call this in the following way..
>> > ---
>> > 
>> > import net.databinder.valid.hib.ValidDataForm;
>> >
>> > @AuthorizeInstantiation(Roles.USER)
>> > public class updateUserProfile extends Panel{
>> >
>> > private static final long serialVersionUID = 2834437668800017171L;
>> > EditForm form;
>> > ...
>> > public updateUserProfile(String id, String userId) {
>> > super(id);
>> > final Integer userIdInt = Integer.parseInt(userId);
>> > add(form = new EditForm("userProfileForm",
>> > Long.parseLong(userId.trim(;
>> >
>> >
>> >
>> >
>> > }
>> >
>> >
>> >
>> >
>> > protected class EditForm extends ValidDataForm {
>> > @SuppressWarnings({ "serial", "unchecked" })
>> > public EditForm(String id, Long userId) {
>> > super(id, SecUsers.class,userId);
>> > add(new TextField("userName").setRequired(true));
>> > .
>> > add(new mvDropDownChoice("userProfile.country","COUNTRY",
>> > this.getModel()));
>> > .
>> >
>> > and this generates the following HTML output
>> > --
>> > > > wicket:id="userProfile.country">
>> > Choose One
>> >
>> > Argentina
>> > Uruguay
>> > 
>> >
>> > ---
>> >
>> >
>> > Wich is correct, O have the code.. as the value. the description as the
>> > user readable choice.. the CODE is persisted to the database (AKA in a
>> > select country from sec_users the country is returned ARG | UY and not
>> > Argentina | Uruguay which is what I need..) but my problem as stated
>> > before is that I can

Re: DropDownChoice and selected value...

2010-01-09 Thread Pieter Degraeuwe
check your equals() method of the selected object's classes

On Sun, Jan 10, 2010 at 7:03 AM, Facundo Miquel wrote:

> Hi, thanks for the tip.. unfortunately , I tried this, (a shorter version
> at
> least..)
>
> add(new DropDownChoice("userProfile.city",
>new PropertyModel(this.getModel(), "userProfile.city"),
>new LoadableDetachableModel() {
>@Override
>protected Object load() {
>return sysMultivaluesProvider.getMVList("CITY");
>}
>}
>)
> );
>
> but the problem is the same the selected value is persisted into the
> database but when I edit the record the value is not "selected"  in the
> dropdown.. any clues?
>
> I'm obviously missing something!!
>
> TIA
>
>
> On Thu, Jan 7, 2010 at 1:43 PM, Kogel, Jonck-van-der <
> jonck-van-der.ko...@bmw.nl> wrote:
>
> > Hi,
> > I also had this problem once. It turned out to have to do with my list
> > of choices becoming stale. I solved this by putting the choices in a
> > LoadableDetachableModel.
> >
> > ie:
> >
> > IModel> yourObjectsModel = new
> > LoadableDetachableModel>() {
> >  @Override
> >  protected List load() {
> >  return yourObjectService.findAll();
> >  }
> >
> > };
> >
> > add(new YourDropDownChoice("foo",
> >  new PropertyModel(yourModel, "bar"),
> >  yourObjectsModel));
> >
> >
> > 
> >
> > From: Facundo Miquel [mailto:facu...@easytech.com.ar]
> > Sent: donderdag 7 januari 2010 15:18
> > To: users@wicket.apache.org
> > Subject: DropDownChoice and selected value...
> >
> >
> > Hello all..
> >
> > First of all, I know that this has been discussed here, I searched the
> > archives but could not find an answer, or at least understand one, so
> > please If someone can help me I would greatly appreciate it...
> >
> >
> > I have a small problem with Drop Down Choices and the selected value
> > when editing an existing record... and I wanted to validate that I'm
> > doing things the correct way.. and if so.. if there is a known issue
> >
> > the scenario is as follows...
> >
> > I created an extended class (just to simplify my work) to generate DDC
> > from a multivalues tables (aka, a table where one holds different types
> > of things.. countries, cities, status codes, etc..).
> >
> > The rest of the mail will be in RED for readability...
> >
> > In my tables I'm required to store the code and not the value so
> > basically I created the following class..(these are fractions.. I'm
> > attaching the actual clasess..)
> >
> > public class mvDropDownChoice extends DropDownChoice {
> > ...
> > static List mvValues = null;
> > @SuppressWarnings("serial")
> > public mvDropDownChoice(String id, String mvCode, IModel model) {
> > super(id, new PropertyModel(model,
> > id),sysMultivaluesProvider.getMVList(mvCode),new IChoiceRenderer() {
> > public String getDisplayValue(Object object) {
> >SysMultivalues mv = (SysMultivalues) object;
> >return mv.getMvMeaning();
> >}
> >public String getIdValue(Object object, int index) {
> >if (index == -1)
> >return null;
> >return ((SysMultivalues)mvValues.get(index)).getMvCode();
> >}
> > });
> > mvValues = sysMultivaluesProvider.getMVList(mvCode);
> > }
> > ...
> > ..
> >
> >
> > now I call this in the following way..
> > ---
> > 
> > import net.databinder.valid.hib.ValidDataForm;
> >
> > @AuthorizeInstantiation(Roles.USER)
> > public class updateUserProfile extends Panel{
> >
> > private static final long serialVersionUID = 2834437668800017171L;
> > EditForm form;
> > ...
> > public updateUserProfile(String id, String userId) {
> > super(id);
> > final Integer userIdInt = Integer.parseInt(userId);
> > add(form = new EditForm("userProfileForm",
> > Long.parseLong(userId.trim(;
> >
> >
> >
> >
> > }
> >
> >
> >
> >
> > protected class EditForm extends ValidDataForm {
> > @SuppressWarnings({ "serial", "unchecked" })
> > public EditForm(String id, Long userId) {
> > super(id, SecUsers.class,userId);
> > add(new TextField("userName").setRequired(true));
> > .
> > add(new mvDropDownChoice("userProfile.country","COUNTRY",
> > this.getModel()));
> > .
> >
> > and this generates the following HTML output
> > --
> >  > wicket:id="userProfile.country">
> > Choose One
> >
> > Argentina
> > Uruguay
> > 
> >
> > ---
> >
> >
> > Wich is correct, O have the code.. as the value. the description as the
> > user readable choice.. the CODE is persisted to the database (AKA in a
> > select country from sec_users the country is returned ARG | UY and not
> > Argentina | Uruguay which is what I need..) but my problem as stated
> > before is that I can't get the choice to come up with the correct
> > selected value (Argentina / Uruguay) and it always comes out with
> > "Choose One"..
> >
> >
> >
> >
> > TIA
> >
> >
> >
> >
> >
>



-- 
Pieter Degraeuwe
Systemworks bvba
Belgiëlaan 61

Re: DropDownChoice and selected value...

2010-01-09 Thread Facundo Miquel
Hi, thanks for the tip.. unfortunately , I tried this, (a shorter version at
least..)

add(new DropDownChoice("userProfile.city",
new PropertyModel(this.getModel(), "userProfile.city"),
new LoadableDetachableModel() {
@Override
protected Object load() {
return sysMultivaluesProvider.getMVList("CITY");
}
}
)
);

but the problem is the same the selected value is persisted into the
database but when I edit the record the value is not "selected"  in the
dropdown.. any clues?

I'm obviously missing something!!

TIA


On Thu, Jan 7, 2010 at 1:43 PM, Kogel, Jonck-van-der <
jonck-van-der.ko...@bmw.nl> wrote:

> Hi,
> I also had this problem once. It turned out to have to do with my list
> of choices becoming stale. I solved this by putting the choices in a
> LoadableDetachableModel.
>
> ie:
>
> IModel> yourObjectsModel = new
> LoadableDetachableModel>() {
>  @Override
>  protected List load() {
>  return yourObjectService.findAll();
>  }
>
> };
>
> add(new YourDropDownChoice("foo",
>  new PropertyModel(yourModel, "bar"),
>  yourObjectsModel));
>
>
> 
>
> From: Facundo Miquel [mailto:facu...@easytech.com.ar]
> Sent: donderdag 7 januari 2010 15:18
> To: users@wicket.apache.org
> Subject: DropDownChoice and selected value...
>
>
> Hello all..
>
> First of all, I know that this has been discussed here, I searched the
> archives but could not find an answer, or at least understand one, so
> please If someone can help me I would greatly appreciate it...
>
>
> I have a small problem with Drop Down Choices and the selected value
> when editing an existing record... and I wanted to validate that I'm
> doing things the correct way.. and if so.. if there is a known issue
>
> the scenario is as follows...
>
> I created an extended class (just to simplify my work) to generate DDC
> from a multivalues tables (aka, a table where one holds different types
> of things.. countries, cities, status codes, etc..).
>
> The rest of the mail will be in RED for readability...
>
> In my tables I'm required to store the code and not the value so
> basically I created the following class..(these are fractions.. I'm
> attaching the actual clasess..)
>
> public class mvDropDownChoice extends DropDownChoice {
> ...
> static List mvValues = null;
> @SuppressWarnings("serial")
> public mvDropDownChoice(String id, String mvCode, IModel model) {
> super(id, new PropertyModel(model,
> id),sysMultivaluesProvider.getMVList(mvCode),new IChoiceRenderer() {
> public String getDisplayValue(Object object) {
>SysMultivalues mv = (SysMultivalues) object;
>return mv.getMvMeaning();
>}
>public String getIdValue(Object object, int index) {
>if (index == -1)
>return null;
>return ((SysMultivalues)mvValues.get(index)).getMvCode();
>}
> });
> mvValues = sysMultivaluesProvider.getMVList(mvCode);
> }
> ...
> ..
>
>
> now I call this in the following way..
> ---
> 
> import net.databinder.valid.hib.ValidDataForm;
>
> @AuthorizeInstantiation(Roles.USER)
> public class updateUserProfile extends Panel{
>
> private static final long serialVersionUID = 2834437668800017171L;
> EditForm form;
> ...
> public updateUserProfile(String id, String userId) {
> super(id);
> final Integer userIdInt = Integer.parseInt(userId);
> add(form = new EditForm("userProfileForm",
> Long.parseLong(userId.trim(;
>
>
>
>
> }
>
>
>
>
> protected class EditForm extends ValidDataForm {
> @SuppressWarnings({ "serial", "unchecked" })
> public EditForm(String id, Long userId) {
> super(id, SecUsers.class,userId);
> add(new TextField("userName").setRequired(true));
> .
> add(new mvDropDownChoice("userProfile.country","COUNTRY",
> this.getModel()));
> .
>
> and this generates the following HTML output
> --
>  wicket:id="userProfile.country">
> Choose One
>
> Argentina
> Uruguay
> 
>
> ---
>
>
> Wich is correct, O have the code.. as the value. the description as the
> user readable choice.. the CODE is persisted to the database (AKA in a
> select country from sec_users the country is returned ARG | UY and not
> Argentina | Uruguay which is what I need..) but my problem as stated
> before is that I can't get the choice to come up with the correct
> selected value (Argentina / Uruguay) and it always comes out with
> "Choose One"..
>
>
>
>
> TIA
>
>
>
>
>


RE: DropDownChoice and selected value...

2010-01-07 Thread Kogel, Jonck-van-der
Hi,
I also had this problem once. It turned out to have to do with my list
of choices becoming stale. I solved this by putting the choices in a
LoadableDetachableModel.
 
ie:
 
IModel> yourObjectsModel = new
LoadableDetachableModel>() {
 @Override
 protected List load() {
  return yourObjectService.findAll();
 }
 
};
 
add(new YourDropDownChoice("foo",
  new PropertyModel(yourModel, "bar"),
  yourObjectsModel));
 



From: Facundo Miquel [mailto:facu...@easytech.com.ar] 
Sent: donderdag 7 januari 2010 15:18
To: users@wicket.apache.org
Subject: DropDownChoice and selected value...


Hello all.. 

First of all, I know that this has been discussed here, I searched the
archives but could not find an answer, or at least understand one, so
please If someone can help me I would greatly appreciate it...


I have a small problem with Drop Down Choices and the selected value
when editing an existing record... and I wanted to validate that I'm
doing things the correct way.. and if so.. if there is a known issue

the scenario is as follows...

I created an extended class (just to simplify my work) to generate DDC
from a multivalues tables (aka, a table where one holds different types
of things.. countries, cities, status codes, etc..).

The rest of the mail will be in RED for readability...

In my tables I'm required to store the code and not the value so
basically I created the following class..(these are fractions.. I'm
attaching the actual clasess..)

public class mvDropDownChoice extends DropDownChoice {
...
static List mvValues = null;
@SuppressWarnings("serial")
public mvDropDownChoice(String id, String mvCode, IModel model) {
super(id, new PropertyModel(model,
id),sysMultivaluesProvider.getMVList(mvCode),new IChoiceRenderer() {
public String getDisplayValue(Object object) {
SysMultivalues mv = (SysMultivalues) object;
return mv.getMvMeaning();   
}
public String getIdValue(Object object, int index) {
if (index == -1)
return null;
return ((SysMultivalues)mvValues.get(index)).getMvCode(); 
}
});
mvValues = sysMultivaluesProvider.getMVList(mvCode);
}
...
..


now I call this in the following way..
---

import net.databinder.valid.hib.ValidDataForm;

@AuthorizeInstantiation(Roles.USER)
public class updateUserProfile extends Panel{

private static final long serialVersionUID = 2834437668800017171L;
EditForm form;
...
public updateUserProfile(String id, String userId) {
super(id);
final Integer userIdInt = Integer.parseInt(userId);
add(form = new EditForm("userProfileForm",
Long.parseLong(userId.trim(;




}




protected class EditForm extends ValidDataForm {
@SuppressWarnings({ "serial", "unchecked" })
public EditForm(String id, Long userId) {
super(id, SecUsers.class,userId);
add(new TextField("userName").setRequired(true));
.
add(new mvDropDownChoice("userProfile.country","COUNTRY",
this.getModel()));
.

and this generates the following HTML output
--

Choose One

Argentina
Uruguay


---


Wich is correct, O have the code.. as the value. the description as the
user readable choice.. the CODE is persisted to the database (AKA in a
select country from sec_users the country is returned ARG | UY and not
Argentina | Uruguay which is what I need..) but my problem as stated
before is that I can't get the choice to come up with the correct
selected value (Argentina / Uruguay) and it always comes out with
"Choose One".. 




TIA