Just a quick update. For the solution to be reliable (I previously said it
was not perfect), you will need to implement you own Label like:

    class BigDecimalLabel extends Label
    {
        public BigDecimalLabel(String id, IModel<BigDecimal> model)
        {
            super(id, model);
        }

        public <C> IConverter<C> getConverter(Class<C> type)
        {
            if (BigDecimal.class.isAssignableFrom(type))
            {
                return (IConverter<C>)converter; //TODO: create an instance
of your decimal convertor, preferably in the constructor (you can have look
at DateConverter for help)
            }

            return super.getConverter(type);
        }

Regards,
Sebastien.

On Fri, Jun 1, 2012 at 10:41 AM, Sebastien <seb...@gmail.com> wrote:

> Hi,
>
> I would have done something like that:
>
> public class BigDecimalFilteredPropertyColumn extends
> TextFilteredPropertyColumn<BigDecimal, String>
> {
>     public BigDecimalFilteredPropertyColumn(IModel<String> displayModel,
> String sortProperty, String propertyExpression)
>     {
>         super(displayModel, sortProperty, propertyExpression);
>     }
>
>     public void populateItem(Item<ICellPopulator<BigDecimal>> item, String
> componentId, IModel<BigDecimal> rowModel)
>     {
>         IModel<? extends BigDecimal> model = (IModel<? extends
> BigDecimal>) super.createLabelModel(rowModel);
>
>         item.add(new Label(componentId, new
> Model<String>(String.format("%#,00d", model.getObject())))); //TODO: check
> the string.format pattern
>     }
> }
>
> It is maybe not perfect but I think it should answer the use case...
>
> Regards,
> Sebastien.
>
>
> On Fri, Jun 1, 2012 at 9:29 AM, lang <delan...@telfort.nl> wrote:
>
>> I make my column with
>>        @SuppressWarnings({ "unchecked", "rawtypes" })
>>        private TextFilteredPropertyColumn getVerkoopprijs() {
>>                return new TextFilteredPropertyColumn(
>>                                new Model<String>("Verkoopprijs"),
>> "verkoopprijs", "verkoopprijs") {
>>                        @Override
>>                        public String getCssClass() {
>>                                return "numeric";
>>                        };
>>                };
>>        }
>> But I can not find any propriate method. Do you have an example?
>> Currenty my output is:
>>  for 1 euro       1          but i want to display the amount always 2
>> decimals:  1,00
>>  for 1,50          1,50
>> 1,50 etc
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Filtercolumn-and-bigdecimal-formatter-tp4649624p4649637.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
>>
>>
>

Reply via email to