cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <>
Subject Re: [CForms] Creating an intermediate object in binding
Date Fri, 29 Jul 2005 14:34:25 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: 
> guide.html#Creating%20Objects
> My problem is: where do I set this factory in CForms, assuming this is  
> possible at all?
I do not think this is possible in current implementation (I am not sure 
though). Still the approach implemented by JXPath does not scale well - 
  you would have to duplicate all info about relationships in your OR 

There is one more thing that is awkward with binding: imagine you have a 
  OR model with many-to-many relationship. Cforms will allow you to 
create  a form with a selection list to define those relationships. But 
wait: what you get are the ids of entities not entities themselves.

Binding API does not give you access to service manager so you won't be 
able to lookup some dao and load the entity by its id.

Leszek Gawron                            
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                    
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

View raw message