Re: Use Byte for CheckBox instead of Boolean

2011-01-31 Thread MattyDE

@ 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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Use Byte for CheckBox instead of Boolean

2011-01-26 Thread rolandpeng

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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Use Byte vor CheckBox instead of Boolean

2011-01-25 Thread MattyDE

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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Use Byte vor CheckBox instead of Boolean

2011-01-25 Thread Martin Grigorov
On Tue, Jan 25, 2011 at 2:02 PM, MattyDE ufer.mar...@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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Use Byte vor CheckBox instead of Boolean

2011-01-25 Thread Ernesto Reinaldo Barreiro
Can´t you just use a nested model like

public class ByteBooleanModel implements IModelBoolean {

private static final long serialVersionUID = 1L;

private IModelByte model;
public ByteBooleanModel(IModelByte 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 ufer.mar...@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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Use Byte vor CheckBox instead of Boolean

2011-01-25 Thread MattyDE

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 ufer.mar...@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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Use Byte vor CheckBox instead of Boolean

2011-01-25 Thread Jeremy Thomerson
On Tue, Jan 25, 2011 at 7:18 AM, MattyDE ufer.mar...@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*