You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Joe Grist <jo...@andersonmorgan.com.au> on 2005/03/06 10:41:29 UTC

Cforms in Lenya

>> If anybody has gotten Cforms going, I'd really
>> appreciate any sample code you could spare.

> How far did you get? What works for you and what doesn't?
> 
> Regards,
> Torsten

Hi Torsten

(Changed the subject line to make it more relevant)

So far I have managed to get the example form working from the Cocoon site
in its own browser window.

I have not managed to integrate the cocoon example into my Lenya look and
feel.  It runs and works, but it runs full screen only.

My challenge is at the moment to understand enough of the Cocoon pipeline
syntax to make the form come up inside my site template.

The main thing I would like to add to the wiki is a basic overview of
pipeline syntax to show how to do this sort of thing (without having to read
the whole cocoon site).  A few examples should do it.  I'm also not 100%
sure that everything on that wiki page is accurate.  For example, I suspect
that the suggested names for files don't work with the sample code (not sure
about this). 

Then I want to get an example publication up there for people to copy.

Thanks for your kind attention

Joe Grist
Anderson Morgan Consulting Pty Ltd
PO Box 141 New Town 7008
6278 3387 / 0400 887 081
joeg@andersonmorgan.com.au / www.andersonmorgan.com.au
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Cforms in Lenya

Posted by "Gregor J. Rothfuss" <gr...@apache.org>.
Joe Grist wrote:
> Hi Torsten
> 
> Forgive me, I am still grappling with this.
> 
> Here are my questions at this point:

once we have this worked out, we should finish the wiki page about it, 
and move it to the website documentation.

-- 
Gregor J. Rothfuss
COO, Wyona       Content Management Solutions    http://wyona.com
Apache Lenya                              http://lenya.apache.org
gregor.rothfuss@wyona.com                       gregor@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


RE: Cforms in Lenya

Posted by Joe Grist <jo...@andersonmorgan.com.au>.
Hi Torsten

> >>    What I can't figure out is
> >>    how in all of this code does my original file get called? I don't
> >>    See how anything will end up parseing "send-us-a-message.html".
>
> This might be the problem. Does it work or does it not?
>
> Is "send-us-a-message.html" and XHTML file with <fi:...> tags in it?

On we go!  Have been reading all about Coccoon, Flowscript, &c... Still
A bit stuck.

Anyhow, I think this is the crux of the problem.  To answer your
question, send-us-a-message.html is the URL that the browser
is requesting.  This should be interpreted by Lenya as, yes, the
XHTML file with the <fi:...> tags, etc.

The issue appears to be that the XHTML is never loaded.  The Wiki
code seems to load the file /forms/registration_template.xml, and
transform/serialize that correctly.  Which means that my
/content/[live|authoring]/[wherever]/index_en.html file never
gets processed.

> all local changes should be done in the sub-sitemap 
> to make it easy to replace sitemap.xmap(s) during a potential Cocoon 
> oder Lenya upgrade. Therefore the Wiki might not necessarily be right.

On investigation, this seems to absolutely correct.  The code example
in section 1.4.4 of the Wiki seems to be quite off base.  Looking
forward to doing a big update of the Wiki!

-- possible problem diagnosis --

I have this in my publication-sitemap.xml at the moment.


      <map:match pattern="registration-display-pipeline">
        <map:generate src="forms/registration_template.xml"/>
        <map:transform type="forms"/>
  <!--        <map:transform type="i18n">
          <map:parameter name="locale" value="en-US"/>
        </map:transform> -->
        <map:transform src="resources/forms-samples-styling.xsl"/>
        <map:serialize/>
      </map:match>

This is called by the flowscript as per the wiki example.  Seems
to me that the line <map:generate src="forms/registration_template.xml"/>
may be the problem. I have no idea how to fix it at the moment though!

Cheers  :)
Thanks so much again
Including my entire publication-sitemap.xml after this message, 
for what it's worth......

Joe Grist
Anderson Morgan Consulting Pty Ltd
PO Box 141 New Town 7008 Tasmania Australia
6278 3387 / 0400 887 081
Joeg -at- andersonmorgan.com.au / www.andersonmorgan.com.au
 



----------------------------------------------------------------------------
--






<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 1999-2004 The Apache Software Foundation

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<!-- $Id: publication-sitemap.xmap 151073 2005-02-02 22:34:40Z michi $ -->

<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  
  <map:components/>
  
  <map:flow language="javascript">
    <map:script src="flow/contactus.js"/>
  </map:flow>
  
  
  <map:views>
    <map:view from-label="aggregation" name="aggregation">
      <map:serialize type="xml"/>
    </map:view>
  </map:views>
  
  <map:resources>
    <map:resource name="style-cms-page">
      <map:transform type="i18n">      
        <map:parameter name="locale" value="{request:locale}"/>
      </map:transform>   
      <map:transform src="../../xslt/util/page2xhtml.xsl">
        <map:parameter name="contextprefix" value="{request:contextPath}"/>
      </map:transform>
      <map:transform src="../../xslt/util/strip_namespaces.xsl"/>
      <map:transform type="forms"/>
      <!-- <map:transform type="i18n">
          <map:parameter name="locale" value="en-US"/>
        </map:transform> -->
      <map:transform src="resources/forms-samples-styling.xsl"/> 
      <map:select type="parameter">
        <map:parameter name="statusCode" value="{statusCode}"/>
        <map:when test="">
          <map:serialize/>
        </map:when>
        <!-- FIXME workaround for
http://issues.apache.org/bugzilla/show_bug.cgi?id=32336 -->
        <map:when test="404">
          <map:serialize status-code="404"/>
        </map:when>
        <map:otherwise>
          <map:serialize status-code="{statusCode}"/>
        </map:otherwise>
      </map:select>
    </map:resource>
  </map:resources>

  <map:pipelines>

    
    <map:component-configurations>
      <global-variables>
        <cache-dir>work/cache</cache-dir>
      </global-variables>
    </map:component-configurations>
    
    <map:pipeline>
      <map:match pattern="**/">
        <map:redirect-to uri="index.html"/>
        <!--<map:redirect-to uri="{1}.html"/>-->
      </map:match>
    </map:pipeline>
    
    <map:pipeline>
      <!-- pattern="{rendertype}/{area}/{doctype}/{document-path}" -->
      <!-- NOTE: rendertype seems to be 'edit' or 'view' -->
      <map:match pattern="lenya-document-*/*/*/**.xml">
        <map:mount check-reload="true" reload-method="synchron"
src="doctypes.xmap" uri-prefix="lenya-document-"/>
      </map:match>
    </map:pipeline>



    <!-- BX Editor: RNG Schema, CSS -->
    <map:pipeline type="noncaching">
      
      <map:match pattern="*/**.rng">
        <map:generate src="config/doctypes/schemas/{2}.rng"/>
        <map:serialize type="xml"/>
      </map:match>
      
      <map:match pattern="**/*-bxeng.css">
        <map:read mime-type="text/css"
src="resources/misc/bxeng/{2}-bxeng.css"/>
      </map:match>
      
      <map:handle-errors>
        <map:select type="exception">
           <map:when test="resourcenotfound">
             <map:generate src="../../content/util/empty.xml" />
            <map:transform
src="../../xslt/exception/document-does-not-exist.xsl">
              <map:parameter name="documentid"
value="{page-envelope:document-id}"/>
              <map:parameter name="documenturl"
value="{page-envelope:document-url}"/>
            </map:transform>
            <map:call resource="style-cms-page">
              <map:parameter name="statusCode" value="404"/>
            </map:call>
          </map:when>
      <map:otherwise>
        <map:generate type="notifying"/>
        <map:transform src="../../../stylesheets/system/error2html.xslt">
          <map:parameter name="contextPath" value="{request:contextPath}"/>
        </map:transform>
      </map:otherwise>
        </map:select>
        <map:serialize type="html"/>
      </map:handle-errors>    
      </map:pipeline>
    <!-- /BX Editor: RNG Schema -->

    
    <!-- This is the pipeline that builds the page. It aggregates all
    the navigational elements (breadcrumb, tabs, menu) with the actual
    content of the document. -->
    <map:pipeline>      
      <!-- /lenyabody-{rendertype}/{publication-id}/{area}/{doctype}/{url}
-->
      <map:match pattern="lenyabody-*/*/*/*/**">
        <map:aggregate element="cmsbody">
          <map:part src="cocoon://navigation/{2}/{3}/breadcrumb/{5}.xml"/>
          <map:part src="cocoon://navigation/{2}/{3}/tabs/{5}.xml"/>
          <map:part src="cocoon://navigation/{2}/{3}/menu/{5}.xml"/>
          <map:part src="cocoon://navigation/{2}/{3}/search/{5}.xml"/>
          <map:part
src="cocoon:/lenya-document-{1}/{3}/{4}/{page-envelope:document-path}"/>
        </map:aggregate>
        <map:transform src="xslt/page2xhtml-{4}.xsl">
          <map:parameter name="root"
value="{page-envelope:context-prefix}/{2}/{3}"/>
          <map:parameter name="url" value="{5}"/>
          <map:parameter name="document-id"
value="{page-envelope:document-id}"/>
          <map:parameter name="document-type"
value="{page-envelope:document-type}"/>
        </map:transform>
        <map:select type="parameter">
          <map:parameter name="parameter-selector-test" value="{1}"/>
          <map:when test="view">
	      <map:transform type="link-rewrite"/>
          </map:when>
        </map:select>
        <map:serialize type="xml"/>
      </map:match>
      
    </map:pipeline>
    
    <!-- This is the main entry point into the publication. This
    pipeline uses the uriparametrizer to determine the doctype of this
    request. It then aggregates the lenya menu (for the given area) and
    the lenya body, the actual document. -->
    <map:pipeline>
    
      <map:match pattern="**/send-us-a-message.html">
        <map:call function="contactus"/>
      </map:match>
      <map:match pattern="send-us-a-message.html">
        <map:call function="contactus"/>
      </map:match>
      
      <map:match pattern="**/*.continue">
        <map:call continuation="{2}"/>
      </map:match>
      <map:match pattern="*.continue">
        <map:call continuation="{1}"/>
      </map:match>
      
      <map:match pattern="**.bxe.html">
        <map:generate
src="cocoon:/lenyabody-edit/{page-envelope:publication-id}/{page-envelope:ar
ea}/{page-envelope:document-type}{page-envelope:document-url}"/>
        <map:serialize type="xml"/>
      </map:match>
      
      <map:match pattern="registration-display-pipeline">
        <map:generate src="forms/registration_template.xml"/>
        <map:transform type="forms"/>
  <!--        <map:transform type="i18n">
          <map:parameter name="locale" value="en-US"/>
        </map:transform> -->
        <map:transform src="resources/forms-samples-styling.xsl"/>
        <map:serialize/>
      </map:match>
  
      <map:match pattern="registration-success-pipeline.jx">
        <map:generate type="jx" src="forms/registration_success_jx.xml"/>
        <map:serialize/>
      </map:match>
      
      <map:match pattern="**.html">
        <map:act type="language-exists">
	  <map:select type="resource-exists">
            <map:when test="{global:cache-dir}/{../1}.html">
              <map:read src="{global:cache-dir}/{../1}.html"
mime-type="text/html"/>
            </map:when>
            <map:otherwise>
              <map:generate
src="cocoon:/lenyabody-view/{page-envelope:publication-id}/{page-envelope:ar
ea}/{page-envelope:document-type}{page-envelope:document-url}"/>
              <map:match pattern="authoring/**.html">
                <map:transform
src="cocoon://lenya-page/{page-envelope:publication-id}/{../../1}.xml?doctyp
e={page-envelope:document-type}"/>
              </map:match>
              <map:transform src="../../xslt/util/strip_namespaces.xsl"/>
              <map:match pattern="live/**.html">
                <map:transform
src="../../xslt/authoring/edit/addSourceTags.xsl">
                  <map:parameter name="source"
value="{global:cache-dir}/live/{1}.html"/>
                </map:transform>
                <map:transform type="write-source">
                  <map:parameter name="serializer" value="html-no-dtd"/>
                </map:transform>
                <map:transform
src="../../xslt/authoring/edit/removeSourceTags.xsl"/>
              </map:match>
              <map:serialize type="html"/>
            </map:otherwise>
	  </map:select>
        </map:act>

        <!-- There is no version of the requested document-id for the
             requested language. -->
        <map:generate type="serverpages"
src="../../content/exception/missing-language.xsp"/>
        <map:transform src="../../xslt/exception/missing-language.xsl"/>
        <map:call resource="style-cms-page"/>

      </map:match>
      
      <map:handle-errors>
        <map:select type="exception">
          <map:when test="document-does-not-exist">
            <map:generate src="../../content/util/empty.xml"/>
            <map:transform
src="../../xslt/exception/document-does-not-exist.xsl">
              <map:parameter name="documentid"
value="{page-envelope:document-id}"/>
              <map:parameter name="documenturl"
value="{page-envelope:document-url}"/>
            </map:transform>
            <map:call resource="style-cms-page">
              <map:parameter name="statusCode" value="404"/>
            </map:call>
          </map:when>
           <map:when test="resourcenotfound">
             <map:generate src="../../content/util/empty.xml" />
            <map:transform
src="../../xslt/exception/document-does-not-exist.xsl">
              <map:parameter name="documentid"
value="{page-envelope:document-id}"/>
              <map:parameter name="documenturl"
value="{page-envelope:document-url}"/>
            </map:transform>
            <map:call resource="style-cms-page">
              <map:parameter name="statusCode" value="404"/>
            </map:call>
          </map:when>
      <map:otherwise>
        <map:generate type="notifying"/>
        <map:transform src="../../../stylesheets/system/error2html.xslt">
          <map:parameter name="contextPath" value="{request:contextPath}"/>
        </map:transform>
      </map:otherwise>
        </map:select>
        <map:serialize type="html"/>
      </map:handle-errors>
      
    </map:pipeline>
  </map:pipelines>
</map:sitemap>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Cforms in Lenya

Posted by Torsten Schlabach <ts...@apache.org>.
Joe,

 >> Forgive me, I am still grappling with this.

No problem, I want you to make this work!

 >> 1. You email says to edit publication-sitemap.xmap as per the Wiki,
 >>    but the wiki says to edit sitemap.xml.  These files appear quite
 >>    similar.  I am assuming the wiki is correct. Am I right?

Just had a look at the Wiki and am scratching my head myself a little bit.

Are you familliar with the way how Cocoon traverses nested sitemaps, 
i.e. sitemaps that are mounted from another sitemap? When it comes to 
components (generators, matchers, transformers) a sub-sitemap inherits 
all the components of it's parent.

Looking at the sitemaps that you will find in lenya 
(http://wiki.apache.org/lenya/SitemapStructure) it's somewhat your 
choice where you put something, at least when it comes to components 
such as generators, transformers, etc.

When it comes to what matches where, then you need to take a look at 
what a sitemap matches itself and what is passes on to a sub-sitemap. 
Therefore it *does* matter where you put it.

The idea of sitemap.xmap and global-sitemap.xmap on the Lenya level as 
well as sitemap.xmap and publication-sitemap.map on the publication 
levelk is to my understanding that the sitemap.xmap should usually 
remain unchanged and all local changes should be done in the sub-sitemap 
to make it easy to replace sitemap.xmap(s) during a potential Cocoon 
oder Lenya upgrade. Therefore the Wiki might not necessarily be right.

 >>    What I can't figure out is
 >>    how in all of this code does my original file get called? I don't
 >>    See how anything will end up parseing "send-us-a-message.html".

This might be the problem. Does it work or does it not?

Is "send-us-a-message.html" and XHTML file with <fi:...> tags in it?

Regards,
Torsten

Joe Grist schrieb:
> Hi Torsten
> 
> Forgive me, I am still grappling with this.
> 
> Here are my questions at this point:
> 
> 1. You email says to edit publication-sitemap.xmap as per the Wiki, 
>    but the wiki says to edit sitemap.xml.  These files appear quite 
>    similar.  I am assuming the wiki is correct. Am I right?
> 
> 2. My sitemap.xml appears to be matching correctly on this line:
> 
>         <map:match pattern="**/send-us-a-message.html">
>           <map:call function="contactus"/>
>         </map:match>
> 
>    This then calls my flowscript titled "contactus".  The flowscript
>    then createa a form instance and calls a pipeline:
> 
> 	  form.showForm("registration-display-pipeline");
> 
>    This is matched by sitemap.xml:
> 
>         <map:match pattern="registration-display-pipeline">
>           <map:generate src="forms/registration_template.xml"/>
> 
>    Which directly calls the form code.  What I can't figure out is
>    how in all of this code does my original file get called? I don't
>    See how anything will end up parseing "send-us-a-message.html".
> 
>    Is it just supposed to pass through to another pipeline 
>    automagically? I imagine so.  Have I given you enough 
>    information to see why it does not?
> 
> 
> Thank you so much for spending your valuable time on this. Your Last 
> message was highly informative and useful.
> 
> 
>>I found the overhead of passing all pages through the forms and JX 
>>transformer neglectible.
> 
> 
> If I have any problems, I'll just add more RAM :)
> 
> 
> Joe Grist
> Anderson Morgan Consulting Pty Ltd
> PO Box 141 New Town 7008 Tasmania Australia
> 6278 3387 / 0400 887 081
> Joeg at andersonmorgan.com.au / www.andersonmorgan.com.au
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


RE: Cforms in Lenya

Posted by Joe Grist <jo...@andersonmorgan.com.au>.
Hi Torsten

Forgive me, I am still grappling with this.

Here are my questions at this point:

1. You email says to edit publication-sitemap.xmap as per the Wiki, 
   but the wiki says to edit sitemap.xml.  These files appear quite 
   similar.  I am assuming the wiki is correct. Am I right?

2. My sitemap.xml appears to be matching correctly on this line:

        <map:match pattern="**/send-us-a-message.html">
          <map:call function="contactus"/>
        </map:match>

   This then calls my flowscript titled "contactus".  The flowscript
   then createa a form instance and calls a pipeline:

	  form.showForm("registration-display-pipeline");

   This is matched by sitemap.xml:

        <map:match pattern="registration-display-pipeline">
          <map:generate src="forms/registration_template.xml"/>

   Which directly calls the form code.  What I can't figure out is
   how in all of this code does my original file get called? I don't
   See how anything will end up parseing "send-us-a-message.html".

   Is it just supposed to pass through to another pipeline 
   automagically? I imagine so.  Have I given you enough 
   information to see why it does not?


Thank you so much for spending your valuable time on this. Your Last 
message was highly informative and useful.

> I found the overhead of passing all pages through the forms and JX 
> transformer neglectible.

If I have any problems, I'll just add more RAM :)


Joe Grist
Anderson Morgan Consulting Pty Ltd
PO Box 141 New Town 7008 Tasmania Australia
6278 3387 / 0400 887 081
Joeg at andersonmorgan.com.au / www.andersonmorgan.com.au
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Cforms in Lenya

Posted by Torsten Schlabach <ts...@apache.org>.
Joe,

 >> I have not managed to integrate the cocoon example into my Lenya look
 >> and feel.  It runs and works, but it runs full screen only.

I see. Let me try to give you some (hopefully useful) hints:

In easy words the integation means:

- Put the ft:form-template and ft:widget-label and ft:widget tags into 
the page you want the form to be part of. (Make sure you add 
xmlns:ft="http://apache.org/cocoon/forms/1.0#template" to the xml 
declaration to keep the document valid.)
- Modify the publication-sitemap.xmap as explained in section 1.4.4 of 
the Wiki page.
- Make sure you don't call the pipeline that would usually render this 
page (if it did not have any ft: tags) directly BUT make sure you call 
ir from a piece of flowscript (JavaScript) that first instantiates a 
form instance.

That's it basically.

I can understand you problems as it took me weeks to figure this out. 
When I was sitting back afterwards, I found that I had most trouble 
understanding the stuff because I had not really understood how Lenya 
builds a page in response to a request. But this is damn simple once you 
understood it:

It will

1. Find the source file. There is some Java code in between the URL and 
the file, i.e. the file for /concepts.html is called index_en.xml and 
lives in a folder called concepts. Just ignore this for now and rely on 
the magic that the file will be found.

2. Lenya will use a ResourceTypeAction (a concept borrowed from Forrest, 
see http://forrest.apache.org/docs/cap.html) to find out what kind of 
file it holds in its hands and what XSLT to use to transform this to 
XHTML (i.e. xhtml2xhtml, links2xhtml, yourressourcetyp2xhtml, ...). 
XHTML is used as a common denominator here. But not that at this point 
in time there will be an XHTML page, but without site navigation.

3. Lenya will aggregate the XHTML together with navigation elements into 
a XML document of type "page" and then use "page2xhtml.xsl" to do the 
final rendering that goes out to the browser.

You hook just before that step and have the forms and jx transformers to 
their work by replacing the tags (which are still in that page) with the 
rendered content and widgets.

I had experimented with several approaches and found the easiest was to 
just add the steps that deal with forms to the one and only pipeline 
that all doctypes (resources types in newer terminology) must pass. If 
there are any ft: tags in a document they will get treated. If not, I 
found the overhead of passing all pages through the forms and JX 
transformer neglectible.

Hope this helps taking you a step further ...

Otherwise, please ask specifically what you don't understand and I will 
try to explain it in a different way.

Regards,
Torsten


Joe Grist schrieb:
>>>If anybody has gotten Cforms going, I'd really
>>>appreciate any sample code you could spare.
> 
> 
>>How far did you get? What works for you and what doesn't?
>>
>>Regards,
>>Torsten
> 
> 
> Hi Torsten
> 
> (Changed the subject line to make it more relevant)
> 
> So far I have managed to get the example form working from the Cocoon site
> in its own browser window.
> 
> I have not managed to integrate the cocoon example into my Lenya look and
> feel.  It runs and works, but it runs full screen only.
> 
> My challenge is at the moment to understand enough of the Cocoon pipeline
> syntax to make the form come up inside my site template.
> 
> The main thing I would like to add to the wiki is a basic overview of
> pipeline syntax to show how to do this sort of thing (without having to read
> the whole cocoon site).  A few examples should do it.  I'm also not 100%
> sure that everything on that wiki page is accurate.  For example, I suspect
> that the suggested names for files don't work with the sample code (not sure
> about this). 
> 
> Then I want to get an example publication up there for people to copy.
> 
> Thanks for your kind attention
> 
> Joe Grist
> Anderson Morgan Consulting Pty Ltd
> PO Box 141 New Town 7008
> 6278 3387 / 0400 887 081
> joeg@andersonmorgan.com.au / www.andersonmorgan.com.au
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org