cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christofer Dutz" <christofer.d...@c-ware.de>
Subject AW: AJAX in CForms... not that simple?!
Date Wed, 15 Oct 2008 08:08:36 GMT
Hi Derek

Well I can help you with the resources ;-)
They are located in jar-files. Depending on the resources you are using 
Cocoon-forms-block.jar: org.apache.cocoon.forms.resources.*
Dojo-rsrc-xxxxxxx.jar: org.apache.cocoon.dojo.rerources.*

I usually make them available using the following pipeline:
      <map:match pattern="**_cocoon/resources/*/**">
        <map:select type="resource-exists">
          <map:when test="resources/{2}/{3}">
            <map:read src="resources/{2}/{3}"/>
          </map:when>
          <map:when test="resource://{2}/{3}">
            <map:read src="resource://{2}/{3}"/>
          </map:when>
          <map:otherwise>
            <map:read src="resource://org/apache/cocoon/{2}/resources/{3}"/>
          </map:otherwise>
        </map:select>
      </map:match>
This way I can override the resources in the jars with my alternate
implementations.

Hope this helps.

Chris



-----Urspr√ľngliche Nachricht-----
Von: Derek Hohls [mailto:DHohls@csir.co.za] 
Gesendet: Dienstag, 14. Oktober 2008 13:49
An: users@cocoon.apache.org
Betreff: AJAX in CForms... not that simple?!

I have been working with Cocoon + CForms for a while now, 
but now have to deal with some more complex processing 
requirements.  I had thought this would be a simple matter, 
but alas not...
 
Issue 1.  I have heavily customized stylesheets that I use for 
form display.  Going back to the default stylesheets is problematic.
 
Issue 2.  Locating the resources?  This message:
http://marc.info/?l=xml-cocoon-users&m=111323898129449&w=2 
(and others) refer to the WEB-INF/classes/org/..../forms/resources
directory.  
This I simply cannot find.  I have "WEB-INF/classes/org/apache/cocoon/forms"

but no resources directory in sight.
 
I have tried to copy & use the various files directly from the Cocoon
installation files... but to no avail.
 
In the end, I have tried to create a small test app, based on the car 
selector sample, with details as shown below.
 
Although the form displays just fine, it does not exhibit any of the 
dynamic behavior of the original sample.  Comparison of the source code 
of the two web pages shows them to be the same!
 
What (probably obvious) element/s am I missing?
 
Thanks
Derek
 

<!-- CAR SELECTOR FILES AND SETUP -->
 
I have the following directory/files:
 
flow/forms_flow_example.js 
 
This file is stripped down to:
cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
function selectCar() {
    var form = new Form("cocoon:/carselector_form");
    form.lookupWidget("make").setValue(cocoon.parameters.defaultMake);
    form.showForm("carselector-display-pipeline.jx");
    cocoon.request.setAttribute("carselectorform", form.getWidget());
    cocoon.sendPage("carselector-success-pipeline.xsp", {make:
form.lookupWidget("make").value, type: form.lookupWidget("type").value,
 model: form.lookupWidget("model").value}
    );
}
 
resources/cforms.js
resources/cocoon-ajax.js
resources/forms-lib.js
resources/forms.css
resources/jx-macros.xml
 
stylesheets/forms/forms-advanced-field-styling.xsl

The above sheet I have altered as follows:

  <xsl:import  href="forms-field-styling.xsl"/>
  <xsl:include href="forms-calendar-styling.xsl"/>
  <xsl:include href="forms-htmlarea-styling.xsl"/>
<!--
  <xsl:template match="head" mode="forms-field">
    <xsl:apply-imports/>
    <script src="{$resources-uri}/forms/mattkruse-lib/AnchorPosition.js"
type="text/javascript"/>
    <script src="{$resources-uri}/forms/mattkruse-lib/PopupWindow.js"
type="text/javascript"/>
    <script src="{$resources-uri}/forms/mattkruse-lib/OptionTransfer.js"
type="text/javascript"/>
    <script src="{$resources-uri}/forms/mattkruse-lib/selectbox.js"
type="text/javascript"/>
    <xsl:apply-templates select="." mode="forms-calendar"/>
    <xsl:apply-templates select="." mode="forms-htmlarea"/>
  </xsl:template>
-->


stylesheets/forms/forms-field-styling.xsl

In this above sheet I have altered the scripts to point directly at
the files in the same app. ie.
  <xsl:template match="head" mode="forms-field">
    <script src="../../resources/forms-lib.js" type="text/javascript"/>
    <script src="../../resources/cocoon-ajax.js" type="text/javascript"/>
    <script src="../../resources/cforms.js" type="text/javascript"/>
    <link rel="stylesheet" type="text/css"
href="../../resources/forms.css"/>
  </xsl:template>

stylesheets/forms/forms-page-styling.xsl
stylesheets/forms/forms-samples-styling.xsl

In this aboove sheet I have altered the includes to point directly at
the other files in the same directory ie.

  <xsl:include href="forms-page-styling.xsl"/>
  <xsl:include href="forms-advanced-field-styling.xsl"/>
 
stylesheets/doc/simple-page2html.xsl
 
tables/carselector_form.xml
tables/carselector_template.xml
tables/carselector_success_jx.xml
 
forms/car-db.xml
forms/carfilter.xsl
 

Finally, the sitemap has entries here:
  <map:transformers default="xslt">
   <map:transformer name="browser-update"
src="org.apache.cocoon.ajax.BrowserUpdateTransformer"/>
 
and here:
  <map:selectors default="browser">
   <map:selector name="ajax-request"
src="org.apache.cocoon.ajax.AjaxRequestSelector"/>
 
and finally, at the top of the <map:pipelines><map:pipeline>  :
 <!-- ============================== AJAX ============================ -->
   
    <!-- generate form -->
     <!-- handle dynamic form definition generation -->
     <map:match pattern="*_form">
        <map:generate src="tables/{1}_form.xml" type="jx" label="dbg1">
        <map:parameter name="userrole" value="{session-attr:usersrole}"/>
       </map:generate>
        <map:serialize type="xml" />
      </map:match>   
   
     <map:match pattern="*-success-pipeline.xsp">
       <map:generate type="jx" src="tables/{1}_success_jx.xml"/>
       <map:call resource="simple-page2html">
         <map:parameter name="file" value="tables/{1}_template_jx.xml"/>
       </map:call>
       <map:serialize/>
     </map:match>      
   
     <map:match pattern="docs/carselector">
       <map:call function="selectCar">
         <map:parameter name="defaultMake" value="Maserati"/>
       </map:call>
     </map:match>   
   
     <!--
        | Show a form, using the jx template macros
        -->
     <map:match pattern="*-display-pipeline.jx">
       <map:generate type="jx" src="tables/{1}_template.xml"   label="dbg1">
         <map:parameter name="locale" value="{flow-attribute:locale}"/>
       </map:generate>
       <map:transform type="browser-update"  label="dbg2"/>
       <map:transform type="i18n"  label="dbg3">
         <map:parameter name="locale" value="{flow-attribute:locale}"/>
       </map:transform>
       <map:call resource="simple-page2html"  label="db4">
         <map:parameter name="file" value="forms/{1}_template.xml"/>
       </map:call>
       <map:transform src="stylesheets/forms/forms-samples-styling.xsl"/> 
       <map:transform type="i18n">
         <map:parameter name="locale" value="{flow-attribute:locale}"/>
       </map:transform>
       <map:select type="ajax-request">
         <map:when test="true">
           <map:serialize type="xml"/>
         </map:when>
         <map:otherwise>
           <map:serialize type="html"/>
         </map:otherwise>
       </map:select> 
   </map:match>   
  
     <!--
         | Car selector sample.
         -->
 
     <map:match pattern="cars">
       <map:generate src="forms/car-db.xml"/>
       <map:transform src="forms/carfilter.xsl">
         <map:parameter name="list" value="makes"/>
       </map:transform>
       <map:serialize type="xml"/>
     </map:match>
 
     <map:match pattern="cars/*">
       <map:generate src="forms/car-db.xml"/>
       <map:transform src="forms/carfilter.xsl">
         <map:parameter name="list" value="types"/>
         <map:parameter name="make" value="{1}"/>
       </map:transform>
       <map:serialize type="xml"/>
     </map:match>
     
     <map:match pattern="cars/*/*">
       <map:generate src="forms/car-db.xml"/>
       <map:transform src="forms/carfilter.xsl">
         <map:parameter name="list" value="models"/>
         <map:parameter name="make" value="{1}"/>
         <map:parameter name="type" value="{2}"/>
       </map:transform>
       <map:serialize type="xml"/>
     </map:match>
 
     <map:match pattern="carselector">
       <map:call function="selectCar">
         <map:parameter name="defaultMake" value="Maserati"/>
       </map:call>
     </map:match> 
 
 

 

-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by
MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for
their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message