Re: [Wicket-user] DownDownChoice problem

2006-09-22 Thread Dumitru Postoronca
Gwyn Evans wrote:
 What does c.getMyOptionValue() return?
 
 This...
 public HomePage() {
 add(new DropDownChoice(
 options,
 new Model(getMyOptionValue()),
 OPTIONS)
 {
 protected String getDefaultChoice(final Object selected) {
 return ; // remove Choose One prompt
 }
 });
 }
 
 private String getMyOptionValue() { return Opt2; }
 }
 works as you'd expect. (The ChoiceRenderer() wasn't doing anything).
 
 /Gwyn

getMyOptionValue() actually returns an Integer.

What I'm trying to acomplish is this:
in my Client object I have stored an Integer myOptionValue, and there 
are 3 possible options, so I want to show an edit form with a 
dropdownchoice with those 3 options and have the selected option to be 
the one that corresponds to the Integer I have stored in myOptionValue.
For Integer(1) - Opt1, Integer(2) - Opt2, etc.

- posto


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] DownDownChoice problem

2006-09-22 Thread Gwyn Evans
How about...

add(new DropDownChoice(
options2,
new Model(getDefaultSelection(getMyOptionValue())),
OPTIONS) {
protected String getDefaultChoice( final Object selected ) {
return ; // remove Choose One prompt
}
});
};

private Integer getMyOptionValue() {
return new Integer(2);
}
private String getDefaultSelection(Integer i) {
return String.valueOf(OPTIONS.get(i.intValue()));
}

/Gwyn

On 22/09/06, Dumitru Postoronca [EMAIL PROTECTED] wrote:
 Gwyn Evans wrote:
  What does c.getMyOptionValue() return?
 
  This...
  public HomePage() {
  add(new DropDownChoice(
  options,
  new Model(getMyOptionValue()),
  OPTIONS)
  {
  protected String getDefaultChoice(final Object selected) {
  return ; // remove Choose One prompt
  }
  });
  }
 
  private String getMyOptionValue() { return Opt2; }
  }
  works as you'd expect. (The ChoiceRenderer() wasn't doing anything).
 
  /Gwyn

 getMyOptionValue() actually returns an Integer.

 What I'm trying to acomplish is this:
 in my Client object I have stored an Integer myOptionValue, and there
 are 3 possible options, so I want to show an edit form with a
 dropdownchoice with those 3 options and have the selected option to be
 the one that corresponds to the Integer I have stored in myOptionValue.
 For Integer(1) - Opt1, Integer(2) - Opt2, etc.

 - posto


 -
 Take Surveys. Earn Cash. Influence the Future of IT
 Join SourceForge.net's Techsay panel and you'll get the chance to share your
 opinions on IT  business topics through brief surveys -- and earn cash
 http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user



-- 
Download Wicket 1.2.2 now! - http://wicketframework.org

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] DownDownChoice problem

2006-09-22 Thread Johan Compagner
This is wrong.This is mentioned before on the list: The model object that is the selected objectshould be the same kind of object that is in the choices (the list)that is just a one-one mapping. 
so if your list is: final static List OPTIONS = Arrays.asList(new String[] {Opt1, Opt2, Opt3});thenc.getMyOptionValue()shoudl return one of those so Opt1, Opt2 or Opt3
if c can only return an int then the options list should just be a Integer array of those possible ints.And the getDisplayValue should return Opt1 for integer1 and Opt2 for integer2 and so on.Thats the idea.. The renderer gives you an method where you can return the display value of a real object.
johanOn 9/21/06, Dumitru Postoronca [EMAIL PROTECTED] wrote:
Hello everyone, I want to create an edit form and I'm trying to set the selected item
of a DropDownChoice to match what I have in the database.The form constructor looks like this:-public ClientEditPage(Client c) {...}-The code that sets the form looks like this:
-final static List OPTIONS = Arrays.asList(new String[] {Opt1, Opt2,Opt3});//...DropDownChoice ddc = new DropDownChoice(options,
new Model(c.getMyOptionValue()),OPTIONS,new ChoiceRenderer() {@Overridepublic String getIdValue(Object arg0, int arg1) {// I also tried to return ((Integer)arg1).toString()
// and it didn't workreturn ((Integer)OPTIONS.indexOf(arg0)).toString();}}){protected String getDefaultChoice(final Object selected){
return ; // remove Choose One prompt}};add(ddc);-No matter what client I select, it always shows me the first option.Also, the rendered HTML looks like this:
option value=0Opt1/optionoption value=1Opt2/optionoption value=2Opt3/optionNo selected=selected attribute.
Can somebody tell me what am I doing wrong?Thank you in advance,- posto-Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share youropinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___Wicket-user mailing listWicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] DownDownChoice problem

2006-09-22 Thread Dumitru Postoronca
Johan Compagner wrote:
 This is wrong.
 
 This is mentioned before on the list: The model object that is the 
 selected object
 should be the same kind of object that is in the choices (the list)
 
 that is just a one-one mapping.
 
 so if your list is:
 final static List OPTIONS = Arrays.asList(new String[] {Opt1, Opt2, 
 Opt3});
 
 then
 
 c.getMyOptionValue()
 
 shoudl return one of those so Opt1, Opt2 or Opt3
 
 if c can only return an int then the options list should just be a 
 Integer array of those possible ints.
 And the getDisplayValue should return Opt1 for integer1 and Opt2 for 
 integer2 and so on.
 
 Thats the idea.. The renderer gives you an method where you can return 
 the display value of a real object.
 
 johan

Thanks! I solved it. I'll add the example to the wiki for future reference.

- posto

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] DownDownChoice problem

2006-09-21 Thread Dumitru Postoronca
Igor Vaynberg wrote:
 can we see a quickstart?
 
 -Igor
 
I'm sorry but I don't understand what you mean.
(maybe that's because I'm new to java :)

- posto



-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] DownDownChoice problem

2006-09-21 Thread Igor Vaynberg
what you do seems like it should work.so maybe what you can do is download wicket-quickstart project, add the minimum amount of your code to it to reproduce the problem and attach it to the email. that way whoever wants to help you can download the project and run it in the ide and see the problem live. makes it easier much easier for us to help you.
-IgorOn 9/21/06, Dumitru Postoronca [EMAIL PROTECTED] wrote:
Igor Vaynberg wrote: can we see a quickstart? -IgorI'm sorry but I don't understand what you mean.
(maybe that's because I'm new to java :)- posto-Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net
's Techsay panel and you'll get the chance to share youropinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___Wicket-user mailing listWicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] DownDownChoice problem

2006-09-21 Thread Gwyn Evans
What does c.getMyOptionValue() return?

This...
public HomePage() {
add(new DropDownChoice(
options,
new Model(getMyOptionValue()),
OPTIONS)
{
protected String getDefaultChoice(final Object selected) {
return ; // remove Choose One prompt
}
});
}

private String getMyOptionValue() { return Opt2; }
}
works as you'd expect. (The ChoiceRenderer() wasn't doing anything).

/Gwyn

On 21/09/06, Dumitru Postoronca [EMAIL PROTECTED] wrote:
 Hello everyone,

I want to create an edit form and I'm trying to set the selected item
 of a DropDownChoice to match what I have in the database.

 The form constructor looks like this:
 -
 public ClientEditPage(Client c) {...}
 -

 The code that sets the form looks like this:

 -
 final static List OPTIONS = Arrays.asList(new String[] {Opt1, Opt2,
 Opt3});

 //...

 DropDownChoice ddc = new DropDownChoice(
 options,
 new Model(c.getMyOptionValue()),
 OPTIONS,
 new ChoiceRenderer() {
 @Override
 public String getIdValue(Object arg0, int arg1) {
 // I also tried to return ((Integer)arg1).toString()
 // and it didn't work
 return ((Integer)OPTIONS.indexOf(arg0)).toString();
 }
 }
 ){  protected String getDefaultChoice(final Object selected)
 {
 return ; // remove Choose One prompt
 }};

 add(ddc);
 -

 No matter what client I select, it always shows me the first option.
 Also, the rendered HTML looks like this:
 option value=0Opt1/option
 option value=1Opt2/option
 option value=2Opt3/option

 No selected=selected attribute.

 Can somebody tell me what am I doing wrong?

 Thank you in advance,
 - posto


 -
 Take Surveys. Earn Cash. Influence the Future of IT
 Join SourceForge.net's Techsay panel and you'll get the chance to share your
 opinions on IT  business topics through brief surveys -- and earn cash
 http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user



-- 
Download Wicket 1.2.2 now! - http://wicketframework.org

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user