I'm using the "wrapper" (I guess) in 2.1m2 which calls a Cocoon-supplied function that 
in turn calls yours.
This is modeled on the JXForm sample from the scratchpad.  My sitemap looks like:

        <map:match pattern="doform-*">
          <map:call function="jxForm">
            <map:parameter name="function" value="{1}"/>
            <map:parameter name="id" value="form-id-{1}"/> 
            <map:parameter name="validator-schema-ns" 
value="http://www.ascc.net/xml/schematron"/>
            <map:parameter name="validator-schema" value="form/rules-{1}.xml"/> 
            <map:parameter name="scope" value="request"/>
          </map:call>
        </map:match>

For the "request form" match.  The "render form" pipeline with the two xslt's is the 
same.
The function is slightly different in that it takes a "form" parameter and you have to 
call form.setModel(<your data>).  Instead of SendPageAndWait, you call sendView().  
For example:


// Test flowscript for use with JXForms
cocoon.load("resource://org/apache/cocoon/components/jxforms/flow/jxForm.js");

function submit(form) {
  var modelObj = {
      title: "",
      pages: "",
      extra: "",
      // define the group variable, will get a comma-delimited list of all checked 
boxes within it
      checks: [""],  // default to unchecked
      // define a nodeset (list of all checkboxes in a group
      fieldset: [{key:"test1", value:"test1"},    // key=what to display, value=what 
to store in var
                   {key:"test2", value:"test2"],  
    }

  form.setModel(modelObj);

  form.sendView("form/form-submit.xml");
 
  form.finish("result");
}


Doesn't directly answer your question...  But yes, the workflow is kind of long.


> -----Original Message-----
> From: Richard In Public [SMTP:[EMAIL PROTECTED]
> Sent: Monday, August 18, 2003 11:51 AM
> To:   Cocoon Users Mailing List
> Subject:      JXFormsTransfer, Flow Best Practices
> 
> Hi
> 
> ============
> Question/Problem
> ============
> Does anyone have an example using the JXFormsTransformer?
> 
> My best attempt, described below fails with:
> 
> Exception: org.apache.cocoon.ProcessingException: Failed to execute
> pipeline.:
> file:/home/henrysbb/src/webapps/admin/view/supplier.xml:4:84:org.xml.sax.SAXParserException:Form
> not found: supplier
> The quoted line (4:84) refers to the line <xf:form id="supplier" .... > as
> shown below.
> 
> I am very fuzzy as to how the transformer, XForm and model get connected
> when using the transformer - I have used the generator with success.
> 
> ===============
> Flow Aside
> ===============
> I can't help feeling that I'm using the flow in a twisted way.  Here's what
> I'm doing
> 
> 1.  Requests of the form *.do invokes a function
> 2.  Function loads/modifies beans
> 3.  Function invokes an view in the form **.html with cocoon.SendPage or
> cocoon.SendPageAndWait, passing relevant beans
> 4.  The html pipeline generates a view starting with a JXTemplate, then
> 5.  The document is passed through the JXForms transformer to fill in any
> form fields
> 6.  The document is passed through the two JXForms stylesheets
> 7.  The document is passed through a 'skin' stylesheet that adds menus, etc.
> 8.  Serialize to html
> 9.  Continuation invoked, flow updates beans (Hibernate-2.0.2) and SendPages
> the next template (typically a *.do)
> 
> If I do stick with this pattern then I will have a boolean in the model
> indicating whether the form processing stage is required for the given html
> page.
> 
> Any help greatly appreciated!
> 
> Regards,
> 
> Richard Hoberman
> 
> ============
> Relevant Bits
> ============
> 
> I have the pipline:
> 
> <map:match pattern="**.html">
>   <map:generate type="jxt" src="view/{1}.xml" />
>   <map:transform type="jxforms">
>   <map:parameter name="id" value="{1}" />
>   </map:transform>
>   <map:transform type="xslt" src="stylesheets/jxforms-default.xsl" />> 
>   <map:transform type="xslt" src="stylesheets/jxforms2html.xsl" />
>   <map:transform type="xslt" src="skins/basic/stylesheets/site2html.xsl" />
>   <map:serialize type="html" />
> </map:pattern>
> 
> This is invoked with a link to supplier.do?supplierID=1, which invokes
> 
> <map:match pattern="*.do">
>   <map:call function="{1}" />
>   <map:serialize type="xml" />
> </map:match>
> 
> The function, defined in my flow file:
> 
> function supplier() {
>   var supplierID = cocoon.request.getParameter("supplierID");
>   var supplier = ... hibernate code ... log show this to be correctly loaded
> ...
> ...
>  cocoon.sendPageAndWait("supplier.html", { "supplier" : supplier } );
> 
> ....
> ...
> 
> }
> 
> Just prior to the invocation of the JXFormsTransformer I have (captured with
> a view):
> 
>  <document>
> -
>  <xf:form id="supplier" view="edit-supplier" action="supplier.html"
> method="POST">
> -
>  <xf:select1 ref="/status">
> <xf:label>Status:</xf:label>
> -
>  <xf:item>
> <xf:label>inactive</xf:label>
> <xf:value>inactive</xf:value>
> </xf:item>
> -
>  <xf:item>
> <xf:label>active</xf:label>
> <xf:value>active</xf:value>
> </xf:item>
> -
>  <xf:item>
> <xf:label>forthcoming</xf:label>
> <xf:value>forthcoming</xf:value>
> </xf:item>
> </xf:select1>
> -
>  <xf:input ref="/alias">
> <xf:label>Alias:</xf:label>
> </xf:input>
> -
>  <xf:input ref="/label">
> <xf:label>Label:</xf:label>
> </xf:input>
> -
>  <xf:textarea ref="/description">
> <xf:label>Description:</xf:label>
> </xf:textarea>
> -
>  <xf:submit id="next" continuation="forward" class="button">
> <xf:label>Save</xf:label>
> </xf:submit>
> -
>  <!--
> xf:submit id="back" class="button">
>       <xf:label>Revert</xf:label>
>     </xf:submit
> -->
> </xf:form>
> </document>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to