You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Niels van Kampenhout <n....@hippo.nl> on 2007/05/30 14:04:49 UTC
Incorrect JXPathContext in custom binding
Hi,
While upgrading an application from Cocoon 2.1.8 to the latest 2.1.X
branch, I encountered a problem with a custom binding class that used to
work correctly.
The class extends AbstractCustomBinding, and overrides the methods
"doLoad(Widget frmModel, JXPathContext context)" and "doSave(Widget
frmModel, JXPathContext context)". It binds a certain form field
(containing an XHTML fragment) to an element inside a DOM. While with
Cocoon 2.1.8 "context" would point to the correct specific element
inside the DOM, with Cocoon 2.1.10 it points to the root element, which
of course results in a corrupt document in the end.
Example:
In the binding definition the form field is bound to /root/body. But now
with Cocoon 2.1.10 the context points to /root instead of /root/body, so
I end up with my form field contents saved under the root element.
Has anyone seen this behaviour before?
Thanks,
Niels
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Incorrect JXPathContext in custom binding
Posted by Niels van Kampenhout <n....@hippo.nl>.
Niels van Kampenhout wrote:
> While upgrading an application from Cocoon 2.1.8 to the latest 2.1.X
> branch, I encountered a problem with a custom binding class that used to
> work correctly.
>
> The class extends AbstractCustomBinding, and overrides the methods
> "doLoad(Widget frmModel, JXPathContext context)" and "doSave(Widget
> frmModel, JXPathContext context)". It binds a certain form field
> (containing an XHTML fragment) to an element inside a DOM. While with
> Cocoon 2.1.8 "context" would point to the correct specific element
> inside the DOM, with Cocoon 2.1.10 it points to the root element, which
> of course results in a corrupt document in the end.
>
> Example:
> In the binding definition the form field is bound to /root/body. But now
> with Cocoon 2.1.10 the context points to /root instead of /root/body, so
> I end up with my form field contents saved under the root element.
I think I solved the problem by replacing
Pointer pointer = context.getContextPointer()
Node contextNode = (Node) pointer.getNode();
with
Pointer pointer = context.getPointer(this.getXpath());
Node contextNode = (Node) pointer.getNode();
inside doLoad() and doSave(). Now contextNode points to the context node
instead of the root node like with Cocoon 2.1.8.
Apparently the behaviour of the API changed between 2.1.8 and 2.1.10,
which is acceptable I guess since CForms only became stable in 2.1.9 iirc.
Niels
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org