You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Andreas Lüdtke <sa...@t-online.de> on 2010/02/24 19:43:44 UTC
format float/double in dataview
I'm displaying doubles in an AjaxFallbackDefaultDataTable. Is it possible to
format them i.e. with a precision of 2 digits and right aligned?
Currently I don't see a possibility to do this.
Thanks
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: format float/double in dataview
Posted by Igor Vaynberg <ig...@gmail.com>.
you can create your own column that uses a label with a specific
converter. or a model that does the conversion.
-igor
On Wed, Feb 24, 2010 at 10:43 AM, Andreas Lüdtke
<sa...@t-online.de> wrote:
> I'm displaying doubles in an AjaxFallbackDefaultDataTable. Is it possible to
> format them i.e. with a precision of 2 digits and right aligned?
>
> Currently I don't see a possibility to do this.
>
> Thanks
>
> Andreas
>
>
> ---------------------------------------------------------------------
> 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: format float/double in dataview
Posted by James Carman <jc...@carmanconsulting.com>.
Using CSS makes it XHTML compatible.
On Fri, Feb 26, 2010 at 9:18 AM, Riyad Kalla <rk...@gmail.com> wrote:
> DOH, Wilhelmsen thanks for catching that.
>
> On Fri, Feb 26, 2010 at 7:08 AM, Wilhelmsen Tor Iver <To...@arrive.no>wrote:
>
>> > new SimpleAttributeModifier("text-align", "right") on the Label?
>>
>> "text-align" is not a known attribute. It is a CSS property so
>> SimpleAttributeModifier("style", "text-align: right") could work, or there
>> is an attribute "align" that may or may not be OK depending on HTML spec.
>>
>> - Tor Iver
>>
>> ---------------------------------------------------------------------
>> 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: format float/double in dataview
Posted by Riyad Kalla <rk...@gmail.com>.
DOH, Wilhelmsen thanks for catching that.
On Fri, Feb 26, 2010 at 7:08 AM, Wilhelmsen Tor Iver <To...@arrive.no>wrote:
> > new SimpleAttributeModifier("text-align", "right") on the Label?
>
> "text-align" is not a known attribute. It is a CSS property so
> SimpleAttributeModifier("style", "text-align: right") could work, or there
> is an attribute "align" that may or may not be OK depending on HTML spec.
>
> - Tor Iver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: format float/double in dataview
Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> new SimpleAttributeModifier("text-align", "right") on the Label?
"text-align" is not a known attribute. It is a CSS property so SimpleAttributeModifier("style", "text-align: right") could work, or there is an attribute "align" that may or may not be OK depending on HTML spec.
- Tor Iver
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: format float/double in dataview
Posted by Riyad Kalla <rk...@gmail.com>.
Andreas,
Thanks for sharing that. I'm glad you got it working.
_R
On Fri, Feb 26, 2010 at 7:40 AM, Andreas Lüdtke <sa...@t-online.de>wrote:
> Riyad,
>
> my code is as follows:
>
> @Override
> public void populateItem(Item<ICellPopulator<T>> item, java.lang.String
> componentId, IModel<T> rowModel)
> {
> item.add(new AttributeAppender("align", true, Model.of("right"), ";"));
> super.populateItem(item, componentId, rowModel);
> }
>
> This way, the cell is right aligned.
>
> Andreas
>
> > -----Original Message-----
> > From: Riyad Kalla [mailto:rkalla@gmail.com]
> > Sent: Friday, February 26, 2010 3:06 PM
> > To: users@wicket.apache.org
> > Subject: Re: format float/double in dataview
> >
> > new SimpleAttributeModifier("text-align", "right") on the Label?
> >
> > On Thu, Feb 25, 2010 at 4:39 AM, James Carman
> > <jc...@carmanconsulting.com>wrote:
> >
> > > I would think that you'd add either a style or class
> > attribute to the
> > > cell, perhaps?
> > >
> > > On Thu, Feb 25, 2010 at 6:02 AM, Andreas Lüdtke
> > <sa...@t-online.de>
> > > wrote:
> > > > James,
> > > >
> > > > thanks a lot for the code snippet. My numbers are now perfectly
> > > formatted. Do
> > > > you know how to right align the column? Normally, I would
> > do this in the
> > > > markup but I don't see a possibility where I can modify
> > this in the code.
> > > >
> > > > Thanks again
> > > >
> > > > Andreas
> > > >
> > > >> -----Original Message-----
> > > >> From: James Carman [mailto:jcarman@carmanconsulting.com]
> > > >> Sent: Wednesday, February 24, 2010 8:35 PM
> > > >> To: users@wicket.apache.org
> > > >> Subject: Re: format float/double in dataview
> > > >>
> > > >> public class MessageFormatColumn<T> extends PropertyColumn<T>
> > > >> {
> > > >> private final String pattern;
> > > >>
> > > >> public MessageFormatColumn(IModel<String>
> > displayModel, String
> > > >> propertyExpression, String pattern)
> > > >> {
> > > >> super(displayModel, propertyExpression);
> > > >> this.pattern = pattern;
> > > >> }
> > > >>
> > > >> public MessageFormatColumn(IModel<String>
> > displayModel, String
> > > >> sortProperty, String propertyExpression, String pattern)
> > > >> {
> > > >> super(displayModel, sortProperty, propertyExpression);
> > > >> this.pattern = pattern;
> > > >> }
> > > >>
> > > >> @Override
> > > >> protected IModel<?> createLabelModel(IModel<T> itemModel)
> > > >> {
> > > >> IModel<?> superModel = super.createLabelModel(itemModel);
> > > >> return new Model<String>(MessageFormat.format(pattern,
> > > >> superModel.getObject()));
> > > >> }
> > > >> }
> > > >>
> > > >>
> > > >> On Wed, Feb 24, 2010 at 1:43 PM, Andreas Lüdtke
> > > >> <sa...@t-online.de> wrote:
> > > >> > I'm displaying doubles in an AjaxFallbackDefaultDataTable.
> > > >> Is it possible to
> > > >> > format them i.e. with a precision of 2 digits and
> > right aligned?
> > > >> >
> > > >> > Currently I don't see a possibility to do this.
> > > >> >
> > > >> > Thanks
> > > >> >
> > > >> > Andreas
> > > >> >
> > > >> >
> > > >> >
> > > >>
> > ---------------------------------------------------------------------
> > > >> > 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
> > > >>
> > > >>
> > > >
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > 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
> > >
> > >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
RE: format float/double in dataview
Posted by Andreas Lüdtke <sa...@t-online.de>.
Riyad,
my code is as follows:
@Override
public void populateItem(Item<ICellPopulator<T>> item, java.lang.String
componentId, IModel<T> rowModel)
{
item.add(new AttributeAppender("align", true, Model.of("right"), ";"));
super.populateItem(item, componentId, rowModel);
}
This way, the cell is right aligned.
Andreas
> -----Original Message-----
> From: Riyad Kalla [mailto:rkalla@gmail.com]
> Sent: Friday, February 26, 2010 3:06 PM
> To: users@wicket.apache.org
> Subject: Re: format float/double in dataview
>
> new SimpleAttributeModifier("text-align", "right") on the Label?
>
> On Thu, Feb 25, 2010 at 4:39 AM, James Carman
> <jc...@carmanconsulting.com>wrote:
>
> > I would think that you'd add either a style or class
> attribute to the
> > cell, perhaps?
> >
> > On Thu, Feb 25, 2010 at 6:02 AM, Andreas Lüdtke
> <sa...@t-online.de>
> > wrote:
> > > James,
> > >
> > > thanks a lot for the code snippet. My numbers are now perfectly
> > formatted. Do
> > > you know how to right align the column? Normally, I would
> do this in the
> > > markup but I don't see a possibility where I can modify
> this in the code.
> > >
> > > Thanks again
> > >
> > > Andreas
> > >
> > >> -----Original Message-----
> > >> From: James Carman [mailto:jcarman@carmanconsulting.com]
> > >> Sent: Wednesday, February 24, 2010 8:35 PM
> > >> To: users@wicket.apache.org
> > >> Subject: Re: format float/double in dataview
> > >>
> > >> public class MessageFormatColumn<T> extends PropertyColumn<T>
> > >> {
> > >> private final String pattern;
> > >>
> > >> public MessageFormatColumn(IModel<String>
> displayModel, String
> > >> propertyExpression, String pattern)
> > >> {
> > >> super(displayModel, propertyExpression);
> > >> this.pattern = pattern;
> > >> }
> > >>
> > >> public MessageFormatColumn(IModel<String>
> displayModel, String
> > >> sortProperty, String propertyExpression, String pattern)
> > >> {
> > >> super(displayModel, sortProperty, propertyExpression);
> > >> this.pattern = pattern;
> > >> }
> > >>
> > >> @Override
> > >> protected IModel<?> createLabelModel(IModel<T> itemModel)
> > >> {
> > >> IModel<?> superModel = super.createLabelModel(itemModel);
> > >> return new Model<String>(MessageFormat.format(pattern,
> > >> superModel.getObject()));
> > >> }
> > >> }
> > >>
> > >>
> > >> On Wed, Feb 24, 2010 at 1:43 PM, Andreas Lüdtke
> > >> <sa...@t-online.de> wrote:
> > >> > I'm displaying doubles in an AjaxFallbackDefaultDataTable.
> > >> Is it possible to
> > >> > format them i.e. with a precision of 2 digits and
> right aligned?
> > >> >
> > >> > Currently I don't see a possibility to do this.
> > >> >
> > >> > Thanks
> > >> >
> > >> > Andreas
> > >> >
> > >> >
> > >> >
> > >>
> ---------------------------------------------------------------------
> > >> > 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
> > >>
> > >>
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > 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
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: format float/double in dataview
Posted by Riyad Kalla <rk...@gmail.com>.
new SimpleAttributeModifier("text-align", "right") on the Label?
On Thu, Feb 25, 2010 at 4:39 AM, James Carman
<jc...@carmanconsulting.com>wrote:
> I would think that you'd add either a style or class attribute to the
> cell, perhaps?
>
> On Thu, Feb 25, 2010 at 6:02 AM, Andreas Lüdtke <sa...@t-online.de>
> wrote:
> > James,
> >
> > thanks a lot for the code snippet. My numbers are now perfectly
> formatted. Do
> > you know how to right align the column? Normally, I would do this in the
> > markup but I don't see a possibility where I can modify this in the code.
> >
> > Thanks again
> >
> > Andreas
> >
> >> -----Original Message-----
> >> From: James Carman [mailto:jcarman@carmanconsulting.com]
> >> Sent: Wednesday, February 24, 2010 8:35 PM
> >> To: users@wicket.apache.org
> >> Subject: Re: format float/double in dataview
> >>
> >> public class MessageFormatColumn<T> extends PropertyColumn<T>
> >> {
> >> private final String pattern;
> >>
> >> public MessageFormatColumn(IModel<String> displayModel, String
> >> propertyExpression, String pattern)
> >> {
> >> super(displayModel, propertyExpression);
> >> this.pattern = pattern;
> >> }
> >>
> >> public MessageFormatColumn(IModel<String> displayModel, String
> >> sortProperty, String propertyExpression, String pattern)
> >> {
> >> super(displayModel, sortProperty, propertyExpression);
> >> this.pattern = pattern;
> >> }
> >>
> >> @Override
> >> protected IModel<?> createLabelModel(IModel<T> itemModel)
> >> {
> >> IModel<?> superModel = super.createLabelModel(itemModel);
> >> return new Model<String>(MessageFormat.format(pattern,
> >> superModel.getObject()));
> >> }
> >> }
> >>
> >>
> >> On Wed, Feb 24, 2010 at 1:43 PM, Andreas Lüdtke
> >> <sa...@t-online.de> wrote:
> >> > I'm displaying doubles in an AjaxFallbackDefaultDataTable.
> >> Is it possible to
> >> > format them i.e. with a precision of 2 digits and right aligned?
> >> >
> >> > Currently I don't see a possibility to do this.
> >> >
> >> > Thanks
> >> >
> >> > Andreas
> >> >
> >> >
> >> >
> >> ---------------------------------------------------------------------
> >> > 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
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > 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: format float/double in dataview
Posted by James Carman <jc...@carmanconsulting.com>.
I would think that you'd add either a style or class attribute to the
cell, perhaps?
On Thu, Feb 25, 2010 at 6:02 AM, Andreas Lüdtke <sa...@t-online.de> wrote:
> James,
>
> thanks a lot for the code snippet. My numbers are now perfectly formatted. Do
> you know how to right align the column? Normally, I would do this in the
> markup but I don't see a possibility where I can modify this in the code.
>
> Thanks again
>
> Andreas
>
>> -----Original Message-----
>> From: James Carman [mailto:jcarman@carmanconsulting.com]
>> Sent: Wednesday, February 24, 2010 8:35 PM
>> To: users@wicket.apache.org
>> Subject: Re: format float/double in dataview
>>
>> public class MessageFormatColumn<T> extends PropertyColumn<T>
>> {
>> private final String pattern;
>>
>> public MessageFormatColumn(IModel<String> displayModel, String
>> propertyExpression, String pattern)
>> {
>> super(displayModel, propertyExpression);
>> this.pattern = pattern;
>> }
>>
>> public MessageFormatColumn(IModel<String> displayModel, String
>> sortProperty, String propertyExpression, String pattern)
>> {
>> super(displayModel, sortProperty, propertyExpression);
>> this.pattern = pattern;
>> }
>>
>> @Override
>> protected IModel<?> createLabelModel(IModel<T> itemModel)
>> {
>> IModel<?> superModel = super.createLabelModel(itemModel);
>> return new Model<String>(MessageFormat.format(pattern,
>> superModel.getObject()));
>> }
>> }
>>
>>
>> On Wed, Feb 24, 2010 at 1:43 PM, Andreas Lüdtke
>> <sa...@t-online.de> wrote:
>> > I'm displaying doubles in an AjaxFallbackDefaultDataTable.
>> Is it possible to
>> > format them i.e. with a precision of 2 digits and right aligned?
>> >
>> > Currently I don't see a possibility to do this.
>> >
>> > Thanks
>> >
>> > Andreas
>> >
>> >
>> >
>> ---------------------------------------------------------------------
>> > 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
>>
>>
>
>
> ---------------------------------------------------------------------
> 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: format float/double in dataview
Posted by Andreas Lüdtke <sa...@t-online.de>.
James,
thanks a lot for the code snippet. My numbers are now perfectly formatted. Do
you know how to right align the column? Normally, I would do this in the
markup but I don't see a possibility where I can modify this in the code.
Thanks again
Andreas
> -----Original Message-----
> From: James Carman [mailto:jcarman@carmanconsulting.com]
> Sent: Wednesday, February 24, 2010 8:35 PM
> To: users@wicket.apache.org
> Subject: Re: format float/double in dataview
>
> public class MessageFormatColumn<T> extends PropertyColumn<T>
> {
> private final String pattern;
>
> public MessageFormatColumn(IModel<String> displayModel, String
> propertyExpression, String pattern)
> {
> super(displayModel, propertyExpression);
> this.pattern = pattern;
> }
>
> public MessageFormatColumn(IModel<String> displayModel, String
> sortProperty, String propertyExpression, String pattern)
> {
> super(displayModel, sortProperty, propertyExpression);
> this.pattern = pattern;
> }
>
> @Override
> protected IModel<?> createLabelModel(IModel<T> itemModel)
> {
> IModel<?> superModel = super.createLabelModel(itemModel);
> return new Model<String>(MessageFormat.format(pattern,
> superModel.getObject()));
> }
> }
>
>
> On Wed, Feb 24, 2010 at 1:43 PM, Andreas Lüdtke
> <sa...@t-online.de> wrote:
> > I'm displaying doubles in an AjaxFallbackDefaultDataTable.
> Is it possible to
> > format them i.e. with a precision of 2 digits and right aligned?
> >
> > Currently I don't see a possibility to do this.
> >
> > Thanks
> >
> > Andreas
> >
> >
> >
> ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: format float/double in dataview
Posted by James Carman <jc...@carmanconsulting.com>.
public class MessageFormatColumn<T> extends PropertyColumn<T>
{
private final String pattern;
public MessageFormatColumn(IModel<String> displayModel, String
propertyExpression, String pattern)
{
super(displayModel, propertyExpression);
this.pattern = pattern;
}
public MessageFormatColumn(IModel<String> displayModel, String
sortProperty, String propertyExpression, String pattern)
{
super(displayModel, sortProperty, propertyExpression);
this.pattern = pattern;
}
@Override
protected IModel<?> createLabelModel(IModel<T> itemModel)
{
IModel<?> superModel = super.createLabelModel(itemModel);
return new Model<String>(MessageFormat.format(pattern,
superModel.getObject()));
}
}
On Wed, Feb 24, 2010 at 1:43 PM, Andreas Lüdtke <sa...@t-online.de> wrote:
> I'm displaying doubles in an AjaxFallbackDefaultDataTable. Is it possible to
> format them i.e. with a precision of 2 digits and right aligned?
>
> Currently I don't see a possibility to do this.
>
> Thanks
>
> Andreas
>
>
> ---------------------------------------------------------------------
> 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