cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz Kossakowski <gkossakow...@apache.org>
Subject Re: Clarification on converter concept
Date Thu, 05 Jul 2007 16:26:39 GMT
Daniel Fagerstrom pisze:
> Grzegorz Kossakowski skrev:
>> Daniel Fagerstrom pisze:
> ...
>> Yes, but I really didn't get the idea fully. Now I think that it may 
>> be just a lack of use cases for converter. Would you be so kind to 
>> provide some examples how it could work in particular cases and how it 
>> would be helpful for Cocoon developer?
>>
>> Sometimes abstract explanations hide the basic idea, actually.
> Didn't my examples from CForms and CTemplate below help you?

I had a feeling that there is much more besides Date/Number/Currency formatting but now I
think that I was suffering from 
over-generalization problem. The converter concept is that simple how you describe it but
it's not wrong because it solves very concrete 
problem.

Now I think that I fully get the idea and we can focus on discussing how to implement it.

> Anyway, say that you have a couple of dates in your model bean that you 
> would like to render on a web page using CTemplate. Then you currently 
> would need to write something like (haven't checked the details):
> 
> <jx:formatDate value="${myobj.startDate}" dateStyle="short" 
> locale="${cocoon.request.locale}">
> 
> for each date. That is of course quite OK to write, but it clearly 
> clutters the code, and it is not that obvious for a non developer. With 
> converters it would be more like:
> 
> ${myobj.startDate#short}
> 
> and
> 
> ${myobj.startDate}

Personally, I prefer ${myboject.startDate}#short syntax because choosing converter should
not be part of expression (it would be hard to 
distinguish where expression part ends and converter name begins in some cases). The syntax
would also imply that conversion is performed 
after obtaining value (object) by evaluating the exception.

> Maybe, but in that case you have one way of handling formating for forms 
> and another way for templates. And you would need two configurations 
> instead of one. Also from a conceptual standpoint it is better to 
> separate the rendering part (template) and the model part (form 
> definition). See my abstract text ;) 
> http://article.gmane.org/gmane.text.xml.cocoon.devel/42968 for more 
> about the model-rendering separation.

Yes, I understand it now.

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

Mime
View raw message