On Thu, 27 Nov 2008, kan wrote: > I have a MyPojo with property java.util.Date someDate > I use CompoundPropertyModel<MyPojo> > Now I add components on my page, like add(new Label("someDate")) and > it automagically uses IConvertor to convert from Date to string. > But in some places of web-site I need print only "27/11/2008", in some > places better will be "2 days ago", in some places "27/11/2008 > 16:53:34 UTC" and so on. > What is an elegant way to specify a format in particular piece of code?
I'm not sure if it's elegant, but you can do add(new Label("someDate") { @Override public IConverter getConverter(Class type) { return new FooDateConverter(); } }); If these cases get repeated a lot, you can make named top-level subclasses of Label for them. Or a generic custom component with what you can do add(new DateLabel("someDate").setDateConverter(new FooDateConverter())); Best wishes, Timo -- Timo Rantalaiho Reaktor Innovations Oy <URL: http://www.ri.fi/ > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]