I've moved FlowVelocityGenerator from the velocity block, and added JXPathTransformer and JexlTransformer to the scratchpad. Each of these processes page templates that provide an interface to the Cocoon flow layer. See below for details. I've also added samples of calling each from a Flowscript to the PetStore sample in the scratchpad:

http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/

Let me know what you think.

Regards,

Chris



(1) org.apache.cocoon.transformation.JXPathTransformer

Provides the same tag library as the JPath Xsp logic sheet:

  <if>
  <choose>
  <value-of>
  <for-each>

It also supports XPath as an embedded expression language. The embedded expression language makes it possible to easily access application data and manipulate it in simple ways without having to use Xsp. With the JPath logic sheet, a page author had to use <xsp:attribute> to embed application data in an attribute value:

 <site>
    <xsp:attribute name="signOn">
       <jpath:value-of select="accountForm/signOn"/>
    </xsp:attribute>

The embedded expression language allows a page author to access an object using a simplified syntax such as

<site signOn="{accountForm/signOn}">

Embedded XPath expressions are contained in curly braces.

Note that since, like the JPath logic sheet, JXPathTransformer uses Apache JXPath http://jakarta.apache.org/commons/jxpath/, the referenced objects may be Java Beans, JavaScript objects from the flow layer, or DOM or JDOM objects. The current Web Continuation from the flow script is also available as an XPath variable named "continuation". You would typically access its id:

<form action="{$continuation/id} >

You can also reach previous continuations by using the getContinuation() function:

<form action="{getContinuation($continuation, 1)}" >

The <if> tag allows the conditional execution of its body according to value of a "test" attribute.

  <if test="XPathExpression">
      body
  </if>

The <choose> tag performs conditional block execution by the embedded <when> sub tags. It renders the body of the first <when> tag whose "test" condition evaluates to true. If none of the "test" conditions of nested <whe>n tags evaluate to true, then the body of an <otherwise> tag is evaluated, if present.

  <choose>
    <when test="XPathExpression">
       body
    </when>
    <otherwise>
       body
    </otherwise>
  </choose

The <value-of> tag evaluates an xpath expression and outputs the result of the evaluation.

<value-of select="XPathExpression"/>

The <for-each> tag allows you to iterate over a collection of objects.

  <for-each select="XPathExpression">
     body
  </for-each>


(2) org.apache.cocoon.transformation.JexlTransformer


Provides a similar tag library

  <if>
  <choose>
  <out>
  <forEach>

but provides the JSTL expression language based on Apache Commons Jexl http://jakarta.apache.org/commons/jexl instead of XPath, e.g:

<site signOn="${accountForm.signOn}">

You can access the id of the current Web Continuation like this:

<form action="${continuation.id}"

or a previous one like this:

<form action="${continuation.getContinuation(1).id}">

The <if> tag allows the conditional execution of its body according to value of a "test" attribute.

  <if test="${JexlExpression}">
      body
  </if>

The <choose> tag performs conditional block execution by the embedded <when> sub tags. It renders the body of the first <when> tag whose "test" condition evaluates to true. If none of the "test" conditions of nested <whe>n tags evaluate to true, then the body of an <otherwise> tag is evaluated, if present.

  <choose>
    <when test="${JexlExpression}">
       body
    </when>
    <otherwise>
       body
    </otherwise>
  </choose

The <out> tag evaluates a Jexl expression and outputs the result of the evaluation.

<out value="${JexlExpression}" default="value"/>

The <forEach> tag allows you to iterate over a collection of objects. You specify the collection via the "items" attribute, and the current item is available through a variable named by the "var" attribute.

  <forEach var="name" items="${JexlExpression}">
     body
  </forEach>





Reply via email to