You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tim Blommerde <T....@sdb.nl> on 2005/02/11 11:30:55 UTC

Different value rendering in a table

Dear Tapestry Users,

As a rather newbie to Tapestry and having done some of the tutorials I found, I thought I'd dive right into the deep, as most of the time, that works the best for me. So I started on a small timesheet application, using the JodaTime package for the time/date related classes. But I must admit I ran into a problem right away, one I have not yet been able to solve and that's why I turn to you in the hope one of you can help me back on the right track.

So, what's the problem you might be wondering, well, it's the presentation of the values in a table. I know this sounds a bit odd, but let me explain this a bit more. I have some domain classes which have several fields that have types coming from the, previously mentioned, JodaTime package. I was really impressed by Tapestry as I found out how easily I could add a sortable table with all the values in it to my webpage. But that was about the same moment I ran into my problem. The time/date presentation of my objects, which were actually the toString() results of the JodaTime objects, weren't really what I was looking for, I wanted a nicer representation, but was unable to do that in a nice way.

Of course I could use wrapper objects around the JodaTime objects with a different (overloading) toString() method, but that's not what I want as in that case I'm leaking presentation logic into my domain model, something I don't want to do. So now my question to you is, how can I do this in a nice way.

I've had a look at setting the ValueRendererSource, but though it looked promissing and in my humble opinion is probably the way to go, I wasn't really able to completely solve my issues going this direction. So if this is actually the way to go, could someone tell me how to do it correctly?

Thanks in advance for your replies,
Tim

____________________________________________________________

Alle email van SDB wordt gecontroleerd op virussen door McAfee anti-virus
software op de mailserver.
____________________________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Different value rendering in a table

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
The Table component supports an @Block cell rendering override 
capability.  Look up some examples of this from the list and the Table 
documentation.  This is one way to accomplish what you want for a 
specific table.  However, this doesn't generalize for all tables, 
unfortunately.

What would be ideal is to leverage the OGNL TypeConverter facility, 
which is a hook I've added to Tapestry 3.0 (you can specify a custom 
one as an extension).  Unfortunately this doesn't really come into play 
like it should pervasively.

What we did on my last project was to have a custom wrapper around 
@Insert (we called it @Write).  We pass any object into it and for 
special types it renders a formatted version automatically (like times 
and dates) and does the toString thing otherwise.  This works very well 
when used in place of @Insert.  It is a one-stop place to change 
formatting everywhere.  This trick doesn't help with @Table though, 
sorry.

	Erik


On Feb 11, 2005, at 5:30 AM, Tim Blommerde wrote:

> Dear Tapestry Users,
>
> As a rather newbie to Tapestry and having done some of the tutorials I 
> found, I thought I'd dive right into the deep, as most of the time, 
> that works the best for me. So I started on a small timesheet 
> application, using the JodaTime package for the time/date related 
> classes. But I must admit I ran into a problem right away, one I have 
> not yet been able to solve and that's why I turn to you in the hope 
> one of you can help me back on the right track.
>
> So, what's the problem you might be wondering, well, it's the 
> presentation of the values in a table. I know this sounds a bit odd, 
> but let me explain this a bit more. I have some domain classes which 
> have several fields that have types coming from the, previously 
> mentioned, JodaTime package. I was really impressed by Tapestry as I 
> found out how easily I could add a sortable table with all the values 
> in it to my webpage. But that was about the same moment I ran into my 
> problem. The time/date presentation of my objects, which were actually 
> the toString() results of the JodaTime objects, weren't really what I 
> was looking for, I wanted a nicer representation, but was unable to do 
> that in a nice way.
>
> Of course I could use wrapper objects around the JodaTime objects with 
> a different (overloading) toString() method, but that's not what I 
> want as in that case I'm leaking presentation logic into my domain 
> model, something I don't want to do. So now my question to you is, how 
> can I do this in a nice way.
>
> I've had a look at setting the ValueRendererSource, but though it 
> looked promissing and in my humble opinion is probably the way to go, 
> I wasn't really able to completely solve my issues going this 
> direction. So if this is actually the way to go, could someone tell me 
> how to do it correctly?
>
> Thanks in advance for your replies,
> Tim
>
> ____________________________________________________________
>
> Alle email van SDB wordt gecontroleerd op virussen door McAfee 
> anti-virus
> software op de mailserver.
> ____________________________________________________________
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org