You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by lang <de...@telfort.nl> on 2012/06/01 09:29:19 UTC
Re: Filtercolumn and bigdecimal formatter
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Filtercolumn and bigdecimal formatter
Posted by lang <de...@telfort.nl>.
It worked! Thanks
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Filtercolumn-and-bigdecimal-formatter-tp4649624p4649646.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: Filtercolumn and bigdecimal formatter
Posted by Sebastien <se...@gmail.com>.
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 <se...@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 <de...@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
Re: Filtercolumn and bigdecimal formatter
Posted by Sebastien <se...@gmail.com>.
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 <de...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>