Re: propertycolumn - date column, checkbox column

2009-02-15 Thread Marcelo Morales
I've been using this on 1.3. You could generify to 1.4.

public class DateTimePropertyColumn extends PropertyColumn {
private DateFormat df;
/* ... Constructors */
@Override
protected IModel createLabelModel(IModel itemModel) {
Date date = (Date)
PropertyResolver.getValue(getPropertyExpression(),
itemModel.getObject());
if (date == null) {
return new Model("-");
}
return new Model(df.format(date));
}
}

On Sat, Feb 14, 2009 at 3:32 PM, Christoph Grün  wrote:
> Hi all,
>
>
>
> columns.add(new PropertyColumn(new Model("Title"), "title", " title
> "));
>
>
>
> How can I have such a  property column that displays java.util.dates?
>
> I would also need the same for checkboxes or true/false values.
>
>
>
> Thanks a lot,
>
> Christoph
>
>
>
>



-- 
Marcelo Morales

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



Re: propertycolumn - date column, checkbox column

2009-02-14 Thread James Carman
Perhaps a subclass of AbstractColumn?

public class MessageFormatColumn extends AbstractColumn
{
  private final String pattern;

  public MessageFormatColumn(IModel displayModel, String pattern)
  {
super(displayModel);
this.pattern = pattern;
  }

  public void populateItem(Item> cellItem, String
componentId, IModel model)
  {
cellItem.add(new Label(componentId, MessageFormat.format(pattern,
model.getObject(;
  }
}

This would work for dates, numbers, etc.  You just have to know how to
specify the format pattern.

p.s. Warning, this code is off the top of my head, so it might not
work "out of the box", but it gives you the idea.

On Sat, Feb 14, 2009 at 2:32 PM, Christoph Grün  wrote:
> Hi all,
>
>
>
> columns.add(new PropertyColumn(new Model("Title"), "title", " title
> "));
>
>
>
> How can I have such a  property column that displays java.util.dates?
>
> I would also need the same for checkboxes or true/false values.
>
>
>
> Thanks a lot,
>
> Christoph
>
>
>
>

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



Re: propertycolumn - date column, checkbox column

2009-02-14 Thread Korbinian Bachl - privat

Hi,

use AbstractColumn instead and provide a panel that does what you want, eg:

columns.add(new AbstractColumn(new Model("CHGE"), 
"changed") {


public void populateItem(Item> 
cellItem, String componentId, IModel model) {
cellItem.add(new ChangedCellPanel(componentId, 
model.getObject().isChanged()));

}


@Override
public String getCssClass() {
return "center w50";
}
});

It is usually always a good idea to have a look at the classes you want 
to customise (here: PropertyColumn that extends AbstractColumn) as most 
parts of wicket utilize extensions of abstract classes and/ or 
implementations of interfaces;


Best

PS: the code is from 1.4-rc2, so using generics - in 1.3 you can't do that

Christoph Grün schrieb:

Hi all,

 


columns.add(new PropertyColumn(new Model("Title"), "title", " title
"));

 

How can I have such a  property column that displays java.util.dates? 


I would also need the same for checkboxes or true/false values.

 


Thanks a lot,

Christoph

 





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



propertycolumn - date column, checkbox column

2009-02-14 Thread Christoph Grün
Hi all,

 

columns.add(new PropertyColumn(new Model("Title"), "title", " title
"));

 

How can I have such a  property column that displays java.util.dates? 

I would also need the same for checkboxes or true/false values.

 

Thanks a lot,

Christoph