You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by MattyDE <uf...@gmail.com> on 2011/01/25 14:02:45 UTC
Use Byte vor CheckBox instead of Boolean
Everyone know what i want.... Byte 0 = False Byte 1 = True.
But unfornately "getConverter" is final in CheckBox so i cant place my own
converter there.
Any ideas?
Thanks :)
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-Byte-vor-CheckBox-instead-of-Boolean-tp3236065p3236065.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Use Byte for CheckBox instead of Boolean
Posted by MattyDE <uf...@gmail.com>.
@ rolandpeng: Thanks alot. It works great!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-Byte-for-CheckBox-instead-of-Boolean-tp3236065p3248333.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Use Byte for CheckBox instead of Boolean
Posted by rolandpeng <ro...@cht.com.tw>.
Hi, this is YesNoCheckBox referred from previous posts. You can modify to fit
your need.
Roland.
--
public class YesNoCheckBox extends CheckBox {
public YesNoCheckBox(String id) {
super(id);
}
@Override
protected IModel initModel() {
return new CheckBoxYesNoModel(super.initModel());
}
private class CheckBoxYesNoModel implements IModel {
final IModel model;
public CheckBoxYesNoModel(IModel model) {
this.model = model;
}
public void detach() {
model.detach();
}
public Object getObject() {
return convertToComponent(model.getObject());
}
public void setObject(Object object) {
model.setObject(convertFromComponent(object));
}
protected Object convertToComponent(Object o) {
if (o.toString().equalsIgnoreCase("y"))
return true;
else
return false;
}
protected Object convertFromComponent(Object o) {
if (((Boolean) o) == true)
return "y";
else
return "n";
}
}
}
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-Byte-for-CheckBox-instead-of-Boolean-tp3236065p3238209.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Use Byte vor CheckBox instead of Boolean
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Can´t you just use a nested model like
public class ByteBooleanModel implements IModel<Boolean> {
private static final long serialVersionUID = 1L;
private IModel<Byte> model;
public ByteBooleanModel(IModel<Byte> model) {
this.model = model;
}
/* (non-Javadoc)
* @see org.apache.wicket.model.IModel#getObject()
*/
@Override
public Boolean getObject() {
if(model.getObject()== null)
return null;
if(model.getObject().equals(1))
return Boolean.TRUE;
return Boolean.FALSE;
}
/* (non-Javadoc)
* @see org.apache.wicket.model.IModel#setObject(java.lang.Object)
*/
@Override
public void setObject(Boolean object) {
if(object == null)
this.model.setObject(null);
if(object)
this.model.setObject((byte)1);
else
this.model.setObject((byte)0);
}
/* (non-Javadoc)
* @see org.apache.wicket.model.IDetachable#detach()
*/
@Override
public void detach() {
this.model.detach();
}
}
to allow value be stored as a byte?
Ernesto
On Tue, Jan 25, 2011 at 2:02 PM, MattyDE <uf...@gmail.com> wrote:
>
> Everyone know what i want.... Byte 0 = False Byte 1 = True.
>
> But unfornately "getConverter" is final in CheckBox so i cant place my own
> converter there.
>
> Any ideas?
>
> Thanks :)
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-Byte-vor-CheckBox-instead-of-Boolean-tp3236065p3236065.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Use Byte vor CheckBox instead of Boolean
Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Tue, Jan 25, 2011 at 7:18 AM, MattyDE <uf...@gmail.com> wrote:
> its not the
> wicket-way right?
>
It's *a* wicket way. I'd say it's better than Martin's suggestion of
copy-and-paste code. But, at the end of the day, it's up to your style
preference.
--
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket? Use Brix! http://brixcms.org*
Re: Use Byte vor CheckBox instead of Boolean
Posted by MattyDE <uf...@gmail.com>.
Thanks for the fast reply. I thought about this also, but ... its not the
wicket-way right?
Martin Grigorov-4 wrote:
>
> On Tue, Jan 25, 2011 at 2:02 PM, MattyDE <uf...@gmail.com> wrote:
>
>>
>> Everyone know what i want.... Byte 0 = False Byte 1 = True.
>>
>> But unfornately "getConverter" is final in CheckBox so i cant place my
>> own
>> converter there.
>>
>> Any ideas?
>>
> Copy CheckBox to MyCheckBox and hack it however you want.
>
>>
>> Thanks :)
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Use-Byte-vor-CheckBox-instead-of-Boolean-tp3236065p3236065.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-Byte-for-CheckBox-instead-of-Boolean-tp3236065p3236118.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Use Byte vor CheckBox instead of Boolean
Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Jan 25, 2011 at 2:02 PM, MattyDE <uf...@gmail.com> wrote:
>
> Everyone know what i want.... Byte 0 = False Byte 1 = True.
>
> But unfornately "getConverter" is final in CheckBox so i cant place my own
> converter there.
>
> Any ideas?
>
Copy CheckBox to MyCheckBox and hack it however you want.
>
> Thanks :)
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Use-Byte-vor-CheckBox-instead-of-Boolean-tp3236065p3236065.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>