cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bart Molenkamp" <>
Subject RE: Custom JXPath binding
Date Mon, 23 Aug 2004 08:34:33 GMT
Hi Leszek,

I already provided the patch here:


-----Original Message-----
From: Leszek Gawron [] 
Sent: Friday, August 20, 2004 8:47 PM
Subject: Re: Custom JXPath binding

Bart Molenkamp wrote:
> Hi all,
> I have  a little problem with JXPath bindings. Suppose I have a class
> Person, and a class Project (persistent, via OJB). When I create a new
> person (using a form of course), I can select on which project he/she
> will be working, via a selection list. When the form is submitted, it
> contains the ID of the project that has been selected. In a custom
> binding I want to lookup the project object using the ID that is
> submitted with the form, and then set that object as the project in
> person object that I've just created.
> I thought this could be done using custom bindings. However, I see two
> problems here:
> 1., line 83: the statement:
> JXPathContext context =
> jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
> throws a JXPath exception. That is because the project object in the
> person object is null. What I need to do in my custom binding is
> something like:
> jxpc.setValue(this.xpath, theSelectedProject);
> Maybe this is even a more generic problem. Try to bind a String this
> in where the String in the bean is null (throws same JXPath exception
> because the String is null). So, is the getRelativeContext statement
> needed there? Isn't it better to pass the xpath string along with the
> context to the custom binding? This would solve my problem.
> 2. It might be useful for custom bindings to have access to a service
> manager. This can be done fairly easy. The CustomJXPathBindingBuilder
> has access to the service manager in it's Assistant. It could pass it
> in the CustomJXPathBinding instances that it creates. These instances
> could pass it on to custom bindings that implement the Serviceable
> interface (e.g. using the LifecycleHelper class). This would have no
> effect on existing bindings (I think).
> I think my problem is a more generic problem (binding between ID in
> -> real object in bean), and it would be nice if this could be done
> inside the binding framework.
I think this is a very good enhancement - I have the same problems with 
my hibernate entities. Had to implement dummy java classes for that 

I would recommend you to provide a patch - that is the fastest way to 
incorporate your proposals. I am not a commiter though so I cannot 
guarantee you that it will be commited.

Leszek Gawron                            

View raw message