Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cocoon.forms.binding
Class JavaScriptJXPathBindingBuilder

    java.lang.Object
      org.apache.cocoon.forms.binding.JXPathBindingBuilderBase
          org.apache.cocoon.forms.binding.JavaScriptJXPathBindingBuilder

All Implemented Interfaces:
  JXPathBindingBuilder

public class JavaScriptJXPathBindingBuilder
extends JXPathBindingBuilderBase

Builds a `Binding` based on two JavaScript snippets, respectively for loading and saving the form. This binding also optionally accepts named child bindings, which are useful when the bound widget is a container.

The syntax for this binding is as follows:

       <fb:javascript id="foo" path="@foo">
         <fb:load-form>
           var appValue = jxpathPointer.getValue();
           var formValue = doLoadConversion(appValue);
           widget.setValue(formValue);
           childBindings["foo"].loadFormFromModel(widget, jxpathContext);
         </fb:load-form>
         <fb:save-form>
           var formValue = widget.getValue();
           var appValue = doSaveConversion(formValue);
           jxpathPointer.setValue(appValue);
           childBindings["foo"].saveFormToModel(widget, jxpathContext);
         </fb:save-form>
         <fb:child-binding name="foo">
           <fb:value id="bar" path="baz"/>
         </fb:child-binding>
       </fb:javascript>

This example is rather trivial and could be replaced by a simple <fb:value>, but it shows the available variables in the script:

- `widget`: the widget identified by the "id" attribute,
- `jxpathPointer`: the JXPath pointer corresponding to the "path" attribute,
- `jxpathContext` (not shown): the JXPath context corresponding to the "path" attribute

Notes:

- The <fb:save-form> snippet should be ommitted if the "direction" attribute is set to "load".
- The <fb:load-form> snippet should be ommitted if the "direction" attribute is set to "save".

Version:
  $Id: JavaScriptJXPathBindingBuilder.java 587759 2007-10-24 03:00:37Z vgritsenko $

Nested Class Summary

Nested classes inherited from class org.apache.cocoon.forms.binding.JXPathBindingBuilderBase
`JXPathBindingBuilderBase.CommonAttributes`

Constructor Summary
`JavaScriptJXPathBindingBuilder()`

Method Summary
`JXPathBindingBase` | `buildBinding(Element element, JXPathBindingManager.Assistant assistant)` Builds a configured binding object based on the configuration as described in the bindingElement.
`void` | `setProcessInfoProvider(org.apache.cocoon.processing.ProcessInfoProvider processInfoProvider)`

Methods inherited from class org.apache.cocoon.forms.binding.JXPathBindingBuilderBase
`getCommonAttributes, mergeCommonAttributes`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JavaScriptJXPathBindingBuilder

    public JavaScriptJXPathBindingBuilder()

Method Detail

### buildBinding

    public JXPathBindingBase buildBinding(Element element,
                                          JXPathBindingManager.Assistant assistant)
                                   throws BindingException

  Description copied from interface: `JXPathBindingBuilder`
  Builds a configured binding object based on the configuration as described in the bindingElement. The BuilderMap can be used to find appropriate builders for possible subBinders.

  Parameters:
    `element` -
    `assistant` -
  Returns:
    JXPathBindingBase
  Throws:
    `BindingException`

### setProcessInfoProvider

    public void setProcessInfoProvider(org.apache.cocoon.processing.ProcessInfoProvider processInfoProvider)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.