cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Ekstedt <>
Subject Re: [RT] Attribute Rendering and CForms Convertors (was: Templating Engine - Next steps?)
Date Tue, 02 Nov 2004 21:10:30 GMT
On Tue, 2004-11-02 at 19:21 +0100, Daniel Fagerstrom wrote:

> Ok, the idea is as follows: we have a converter component, that is like 
> the renderer component above, but bidirectional. I.e. both rendering: 
> data type -> displayable string and input conversion: input string -> 
> data type. The converter is configured in the same way as described for 
> the renderer above.

I've been working along the same line [1] (it's about a widget framework
but contains elements that are relevant to your idea as well). The idea
is that data is wrapped by a model that works directly on my data but
that can perform any conversions, validations etc through its
getValue/setValue functions:

public interface Model {
  public String getValue(String path);
  public void setValue(String path, String value);

For example if my data is a bean containing a Date then a
ConvertingBeanModel wrapping my bean would have a getValue function
performing the Date->String conversion (according to whatever locale is
chosen). And vice versa with setValue. The benefit with having an
abstract view of the model would be that you can implement any type of
conversion in the setValue/getValue functions. You could have a generic
set of conversions for the basic types as well as special conversions
unique to your application. Eg. if your underlying data is a resultset
then you can convert values to SQL types rather than java types. 


Cheers Jonas

View raw message