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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to