This is the code that uses the ConverterModel:
....
List<String> choices = Arrays.asList(new String[]{"Ja", "Nee"});
JaNeeToBooleanConverterModel converter = new
JaNeeToBooleanConverterModel(new PropertyModel(model, "buitenlands"));
final RadioGroup group = new RadioGroup("buitenlands", converter);
group.setOutputMarkupId(true);
....
As you can see, the converter is passed as the model to the radiogroup.
The thing I passed in the ConverterModel is a PropertyModel:
new PropertyModel(model, "buitenlands")
And model is inherited from the Panel the above code is added to. That model
has a POJO with a boolean field "buitenlands".
hth
2008/1/15, Mead Lai <[EMAIL PROTECTED]>:
>
>
> could U give more detail code about it? add the Java(form)& html code!
> and what is your version of wicket? it does not work well in my pc
>
> > From: [EMAIL PROTECTED]
> > To: [email protected]
> > Subject: RE: how to convert wicket-CheckBox's Boolean Type to Character
> Type!
> > Date: Tue, 15 Jan 2008 15:24:04 +0800
> >
> >
> > thanks, but the code following get something wrong like that:
> >
> > wrappedModel.getObject();
> > //The method getObject(Component) in the type IModel is not applicable
> for the arguments ()
> > wrappedModel.setObject(value);
> > //The method setObject(Component, Object) in the type IModel is not
> applicable for the arguments
> > (Boolean)
> > I am a fresh, thanks for instruction.
> >
> >
> > > Date: Tue, 15 Jan 2008 07:59:27 +0100
> > > From: [EMAIL PROTECTED]
> > > To: [email protected]
> > > Subject: Re: how to convert wicket-CheckBox's Boolean Type to
> Character Type!
> > >
> > > I did something similar, converting a boolean radio to the Dutch words
> "Ja"
> > > and "Nee" (yes / no).
> > > This is the code:
> > >
> > > public class JaNeeToBooleanConverterModel extends Model {
> > >
> > > private IModel wrappedModel;
> > >
> > > public JaNeeToBooleanConverterModel(IModel model) {
> > > wrappedModel = model;
> > > }
> > >
> > > @Override
> > > public Object getObject() {
> > > Boolean b = (Boolean)wrappedModel.getObject();
> > > return b.booleanValue() ? "Ja" : "Nee";
> > > }
> > >
> > > @Override
> > > public void setObject(Object object) {
> > > Boolean value = "Ja".equals(object) ? Boolean.TRUE :
> Boolean.FALSE;
> > > wrappedModel.setObject(value);
> > > }
> > > }
> > >
> > > 2008/1/15, Mead Lai <[EMAIL PROTECTED]>:
> > > >
> > > >
> > > > Hi, Well,I am use MySql, and there is no boolean type in mysql
> database.
> > > > so I use Char(1) in the database, and in html I use CheckBox.butCheckBox
> > > > only contain Boolean type.
> > > > How to solve this problem? Use IConverter interface? Thanks
> > > > _________________________________________________________________
> > > > Express yourself instantly with MSN Messenger! Download today it's
> FREE!
> > > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > >
> > >
> > >
> > >
> > > --
> > > Martijn Lindhout
> > > JointEffort IT Services
> > > http://www.jointeffort.nl
> > > [EMAIL PROTECTED]
> > > +31 (0)6 18 47 25 29
> >
> > _________________________________________________________________
> > Express yourself instantly with MSN Messenger! Download today it's FREE!
> > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
--
Martijn Lindhout
JointEffort IT Services
http://www.jointeffort.nl
[EMAIL PROTECTED]
+31 (0)6 18 47 25 29