Apache » Cocoon »

  Cocoon Forms
      1.0
   homepage

Cocoon Forms 1.0

Cocoon Forms: Javascript API

Javascript API

Introduction

This API lets you manipulate Cocoon Forms using Flowacript

Widgets

A Form is basically a collection of Widgets,  and this API lets you get a reference to a single widget (using getChild or lookupWidget methods of the Form objects) and manipulate it using the Widget interface. A Form is itself a Widget, hence you acan access its Widget interface using the getModel method. To set the state of a Widget, the WidgeState class has to be imported, with this statement:

importClass(org.apache.cocoon.forms.formmodel.WidgetState);

While the state is set with setState method, like in:

form1.getChild("msg").setState(WidgetState.OUTPUT);

Form object reference

Constructors

Form(formDef)

Is the Formo object cxontructor.

formDef is the form definition XML, which could be expressed as an URI, Source or DOM.

Properties

isValid

Set to true if theuser input has successfily passed validation, false otherwise.

submitId

It is the id of the widget that triggered the form submit (can be null).

locale

The form locale (default locale is used if not set).

cleanupHook

It is a function called after having sent the page displaying the form. This is equivalent to the "fun" argument of sendPageAndWait(), which allows to perform some cleanup when the pipeline has been processed. The function

is called with a single parameter which is the form it is attached to.

cleanupHook

It is a function called before processing the form when it has been submitted by  the browser. This allows to restore some environment that is needed by the form processing.  The function is called with a single parameter which is the form it is attached to.

Methods

getModel()

Returns the form as a Widget Java class.

getChild(id)

Returns a widget (as a Widget Java class) given its id

id widget id.

lookupWidget(path)

Returns a widget (as a Widget Java class) given its path

path widget path.

showForm(uri, viewData, ttl)

Returns a widget (as a Widget Java class) given its path

uri the page uri (like in cocoon.sendPageAndWait()).

viewData some data for the view (like in cocoon.sendPageAndWait()). The "{FormsPipelineConfig.CFORMSKEY}" and "locale" properties are added to this object.

ttl the time to live of the continuation used to display the form.

sendForm 

Show form statelessly, without creating a continuation.

uri the page uri (like in cocoon.sendPageAndWait())

viewdata some data for the view (like in cocoon.sendPageAndWait()).

Errors and Improvements? If you see any errors or potential improvements in this document please help us: View, Edit or comment on the latest development version (registration required).