You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Christopher Oliver <re...@verizon.net> on 2003/02/24 01:01:24 UTC

XMLForm/Flow changes

I've committed changes to support using the Cocoon flow layer with 
XMLForm, which includes a flow-based version of the XMLForm feedback 
sample wizard (http://localhost:8888/samples/xmlform/flow), that you'll 
be able to try yourself as soon as someone fixes the build for the 
samples in cvs ;)

Note: in this implementation there is a 1-1 mapping between validation 
phases and views.

Please test these changes and let me know if they work and if they make 
sense.

The Cocoon flow layer now supports using JavaScript objects as well as 
Java beans, DOM and JDOM objects (or anything else compatible with 
JXPath, see http://jakarta.apache.org/commons/jxpath).

This means you can pass a JavaScript object to sendPage*() and access 
its properties with jpath:value-of in an xsp page. It also means that 
the model you use for your XMLForm can be a JavaScript object.

I've added the XMLForm JavaScript API to system.js 
(http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/system.js?rev=1.7&content-type=text/plain)

Here is a summary of the methods of the JavaScript XForm:

/**
  * Assign the model for this form
  * @param bean Any Java Bean, DOM, JDOM, or JavaScript object
  */
setModel([Object] bean)

/**
  * Return the model used by this form
  * @return a Java Bean, DOM, JDOM or JavaScript object
  */
getModel()

/**
  * Sends view to a presentation pipeline and waits for subsequent
  * submission. Automatically resends view if validation fails.
  * Creates two continuations: one immediately before the page submission
  * and one immediately after. These are used to implement automated
  * support for back/forward navigation in the form. When you move
  * forward in the form the second continuation is invoked. When you move
  * back from the following page the first continuation is invoked.
  *
  * @param view View to send (and phase to validate)
  * @param uri presentation pipeline resource identifier
  * @param validator optional function invoked to perform validation
  *        after the form is populated. The function will be passed the
  *        form as its only parameter.
  *
  */
sendView([String] view, [String] uri, [Function] validator)

/**
  * Sends view to a presentation pipeline but doesn't wait for submission
  * All continuations associated with the form are invalidated.
  *
  * @param view view to send
  * @param uri presentation pipeline uri
  */
finish([String] view, [String] uri)

/**
  * Adds a violation to this form
  * @param xpath XPath expression referencing the field that contains
           invalid data
  * @param message Error message
  */
addViolation([String] path, [String] message)

/**
  * Computes the value of an xpath expression against the model of this
  * form. Useful for testing your model in the Cocoon flow debugger or
  * doing "println" debugging.
  * @param expression Any XPath expression
  * @return Result of computing expression against this form's model
  */
xpath([String] expression)

Regards,
Chris


Re: XMLForm/Flow changes

Posted by Stefano Mazzocchi <st...@apache.org>.
Christopher Oliver wrote:
> I've committed changes to support using the Cocoon flow layer with 
> XMLForm, which includes a flow-based version of the XMLForm feedback 
> sample wizard (http://localhost:8888/samples/xmlform/flow), that you'll 
> be able to try yourself as soon as someone fixes the build for the 
> samples in cvs ;)

I know, I know. Expect an RT on this soon.

-- 
Stefano Mazzocchi                               <st...@apache.org>
    Pluralitas non est ponenda sine necessitate [William of Ockham]
--------------------------------------------------------------------



Re: XMLForm/Flow changes

Posted by Ovidiu Predescu <ov...@apache.org>.
On Sunday, Feb 23, 2003, at 19:53 US/Pacific, Ovidiu Predescu wrote:

>> /**
>>  * Sends view to a presentation pipeline but doesn't wait for 
>> submission
>>  * All continuations associated with the form are invalidated.
>>  *
>>  * @param view view to send
>>  * @param uri presentation pipeline uri
>>  */
>> finish([String] view, [String] uri)
>>
>> [...]
>
> I think 'finish' is too generic, it can refer to anything. Can we 
> rename it to finishForm instead?

Sorry, I thought finish is a top level function, which is not the case. 
Please disregard my previous message.

Regards,
Ovidiu


Re: XMLForm/Flow changes

Posted by Ovidiu Predescu <ov...@apache.org>.
On Sunday, Feb 23, 2003, at 16:01 US/Pacific, Christopher Oliver wrote:

> I've committed changes to support using the Cocoon flow layer with  
> XMLForm, which includes a flow-based version of the XMLForm feedback  
> sample wizard (http://localhost:8888/samples/xmlform/flow), that  
> you'll be able to try yourself as soon as someone fixes the build for  
> the samples in cvs ;)

Great stuff, Chris!

What are the build problems that you mentioned?

> Note: in this implementation there is a 1-1 mapping between validation  
> phases and views.
>
> Please test these changes and let me know if they work and if they  
> make sense.
>
> The Cocoon flow layer now supports using JavaScript objects as well as  
> Java beans, DOM and JDOM objects (or anything else compatible with  
> JXPath, see http://jakarta.apache.org/commons/jxpath).
>
> This means you can pass a JavaScript object to sendPage*() and access  
> its properties with jpath:value-of in an xsp page. It also means that  
> the model you use for your XMLForm can be a JavaScript object.
>
> I've added the XMLForm JavaScript API to system.js  
> (http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-cocoon2/src/java/ 
> org/apache/cocoon/components/flow/javascript/ 
> system.js?rev=1.7&content-type=text/plain)
>
> Here is a summary of the methods of the JavaScript XForm:
>
> [...]
>
> /**
>  * Sends view to a presentation pipeline but doesn't wait for  
> submission
>  * All continuations associated with the form are invalidated.
>  *
>  * @param view view to send
>  * @param uri presentation pipeline uri
>  */
> finish([String] view, [String] uri)
>
> [...]

I think 'finish' is too generic, it can refer to anything. Can we  
rename it to finishForm instead?

Regards,
Ovidiu