cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: [CForms] Creating an intermediate object in binding
Date Fri, 29 Jul 2005 14:34:41 GMT
Ugo Cei wrote:

> Let's assume I have a Person class:
>
> public class Person {
>   public String getFirstname();
>   public String getLastname();
>   public Address getAddress();
>   ...
> }
>
> and an Address class:
>
> public class Address {
>   public String getStreet();
>   public String getTown();
>   ...
> }
>
> I am building a form interface for editing a Person, with this binding:
>
> <fb:value id="street" path="address/street"/>
>
> Now, when trying to save the form, JXPath will do a  
> jxpathContext.createPathAndSetValue which will fail because  
> person.getAddress() is null and the JXPath context doesn't know how 
> to  create an Address.
>
> I could work around this problem by making sure person.address is not  
> null before loading it into the form, but I don't like this solution. 
> A  better option, maybe, would be setting a factory on the context, 
> like  is shown here:  http://jakarta.apache.org/commons/jxpath/users- 
> guide.html#Creating%20Objects
>
> My problem is: where do I set this factory in CForms, assuming this 
> is  possible at all?


Currently, it is not possible.

The solution would be to allow each JXPath binding to have its own 
factory class. This can be easily implented by adding support for a 
"factory" attribute in JXPathBindingBuilderBase.

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


Mime
View raw message