Just FYI, SimpleConverterAdapter was added to Wicket a while ago to
make writing specific two-way converters a bit easier. Don't forget to
read the Javadocs though.

After the recent converter backport in 1.3, they are not as relevant.

Eelco

On 4/2/07, Thomas R. Corbin <[EMAIL PROTECTED]> wrote:
> On Friday, 30 March 2007 08:07 am, Andrew Moore escreveu:
> > I've got a simple option class (as i've seen in examples)<p/>
> >
> >
> > public class Option {
> >       String key;
> >       String value;
> >
> >       public String getKey() {
> >               return key;
> >       }
> >
> >       public void setKey(String key) {
> >               this.key = key;
> >       }
> >
> >       public String getValue() {
> >               return value;
> >       }
> >
> >       public void setValue(String value) {
> >               this.value = value;
> >       }
> >
> >       public Option(String key, String value) {
> >               this.key = key;
> >               this.value = value;
> >       }
> > }
> >
> >
> > I then populate an ArrayList (called imageList) with several entries of the
> > Option class.<p/>
> >
> > Then I add a dropdownchoice component to my form using:
> > ChoiceRenderer choiceRenderer = new ChoiceRenderer("value", "key");
> > form.add(dropDownChoice = new DropDownChoice("imageCollectionId",
> > imageList, choiceRenderer));
> >
> > This works fine to display the key and value bits correctly in the html,
> > but then how do I get out the key and value properties.
> >
> > The only way I've found so far is to have the imageCollectionId attribute
> > in my POJO business object of type Option, whereas I only want it to be of
> > type String - where it should just hold the 'key' value of the Option
> > class.
> >
> > All I want is to get at the 'key' value, but display the 'value' on the
> > screen.
> >
> > Hope that makes some sense, it's been puzzling me all day, and I thought it
> > would be so simple.
> > Cheers
>
>         What I've found useful is to use a converter.   I use 1.2.5 and an
> IConverter.   I don't fully understand a type converter, as it seems to only
> go one way.   So I have an Area object and an ITypeConverter would only take
> an Area and return a string, but I couldn't figure out how to have a string
> and get an Area.    So I use an IConverter.   And I create my drop down
> choice this way:
>
>  new DropDownChoice( ... )
>         {
>             public IConverter getConverter()
>             {
>                 return new AreaConverter( _areaDao );
>             }
>         };
>
> -------------------------------------------------------------------------
> 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.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> Wicket-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.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to