cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Lutz <mat...@gmx.at>
Subject Re: CForms: need some design help
Date Tue, 09 Aug 2005 08:02:06 GMT
yep, thats quite the same approach. there's only one difference, my html 
renderer takes care of both form and no form content. Here are some 
fragments from my sitemap...

        <map:match pattern="*.form.do">
          <map:call function="genericForm" />
        </map:match>

This intercepts all requests that result in a edit form. I have similar 
matchers for views, details, deletes,... classical new edit delete stuff.

Then the genericForm function goes crazy (do binding, attach 
formhandler, get data from by j2ee layer...) and quits with:

form.show(tFormName + ".formobj.html");

This is handled by my generic renderer:

        <map:match pattern="*.*.html">
          <map:aggregate element="root">
            <map:part src="cocoon:/menu/{0}"/>
            <map:part src="cocoon:/c_{2}/{1}.xml" element="content" 
label="content"/>
          </map:aggregate>
          <map:transform src="simple2page.xsl">
            <map:parameter name="contextPath" 
value="{request:contextPath}"/>
            <map:parameter name="page" value="{0}"/>
            <map:parameter name="locale" value="{../locale}"/>
          </map:transform>
          <map:transform 
src="context://resources/xsl/html/aim-page2html.xsl">
            <map:parameter name="contextPath" 
value="{request:contextPath}"/>
            <map:parameter name="page" value="{0}"/>
            <map:parameter name="locale" value="{../locale}"/>
          </map:transform>
          <map:transform type="i18n">
            <map:parameter name="locale" value="{../locale}"/>
          </map:transform>                     
          <map:serialize type="xhtml"/>
        </map:match>

The aggregator generates a document with menu and content information, 
the simple2page.xsl creates a content layout with some metatags, which 
are rendered to html (or someday to pdf...) with the second stylesheet.
My header and footer is rather static, so I add it in the 
aim-page2html.xsl... but there's not much difference to your aggregation.

The important line is:

<map:part src="cocoon:/c_{2}/{1}.xml" element="content" label="content"/>

This calls some internal pipelines for content generation, and one of 
them generates the form:

        <map:match pattern="c_formobj/*.xml">
          <map:generate src="cocoon:/{1}.obj.form.template.xml"/>
          <map:transform type="forms" label="content1" />
          <map:transform 
src="context://resources/xsl/forms/forms-samples-styling.xsl"/>

          <map:serialize type="xml"/>         
        </map:match>

Don't ask me why I have the label="content1" stuff here, can't remember 
now .-).

The line
<map:generate src="cocoon:/{1}.obj.form.template.xml"/>
just calls a pipeline, that tests for a file with a form definition, and 
if there's no file generates a form definition from metadata, nothing 
special here...

Could you post the exception, too ? Maybe it looks familiar to me, I had 
rather strange problems setting up my environment, too... (and right now 
I am stuck in some weird binding exceptions :-) ).

:-),
tom

footh wrote:

>I think I tried something very similar but I was
>getting a null pointer exception.  Perhaps if I showed
>you some of my sitemap you could steer me in the right
>direction.
>
>All pages go through this pipeline:
>
><map:match pattern="*.html">
>  <map:call function="allPages">
>    <map:parameter name="source" value="{1}"/>
>    <map:parameter name="type" value="html"/>
>  </map:call>    
></map:match>
>
>Now, the allPages function will set up the variable
>map that I need for all my pages. Typically after
>that, I would just use sendPage to send the process to
>my "aggregation" pipeline that looks like this:
>
><map:match pattern="*.html.temp">
>  <map:aggregate element="page">
>    <map:part src="cocoon:/header"/>
>    <map:part src="cocoon:/sidebar-left"/>
>    <map:part src="cocoon:/{1}-content"/>
>    <map:part src="cocoon:/sidebar-right"/>
>    <map:part src="cocoon:/footer"/>
>  </map:aggregate>
>  <map:transform src="stylesheets/main.xsl"/>
>  <map:serialize type="html"/>
></map:match>
>
>Each "part" is a separate pipeline that generates the
>XML I need for each piece.  They are all just JX
>generators.
>
>Anyway, in the allPages function from the flow, I
>added logic to determine whether the main content was
>a form.  So instead of using sendPage to send it to
>the above pipeline, I used form.show to send it to
>this:
>
><map:match pattern="*.html.form">
>  <map:aggregate element="page">
>    <map:part src="cocoon:/header"/>
>    <map:part src="cocoon:/sidebar-left"/>
>    <map:part src="cocoon:/{1}-display-form"/>
>    <map:part src="cocoon:/sidebar-right"/>
>    <map:part src="cocoon:/footer"/>
>  </map:aggregate>
>  <map:transform src="stylesheets/main.xsl"/>
>  <map:serialize type="html"/>
></map:match>
>
>Which is the same as the previous pipeline, except the
>main content is generated with a different pipeline. 
>That pipeline looks like this:
>
><map:match pattern="*-display-form">
>  <map:generate src="forms/ftemplate-{1}.xml"/>
>  <map:transform type="forms"/>
>  <map:transform
>src="forms/stylesheets/forms-main-styling.xsl"/>
>  <map:serialize type="xml"/>
></map:match>
>
>But, this gives me a null pointer exception which is
>very difficult to track.  I assumed it was because the
>form definition file that was used when the new
>FormInstance variable was constructed gets lost
>because I'm going several pipelines deep rather than
>just directly using the form transformer.  Is this
>similar to what you are doing?  Can you give me some
>pointer as to how I might be able to fix this?
>
>
>
>
>--- Thomas Lutz <mattom@gmx.at> wrote:
>
>  
>
>>I had quite similar problems as you have, here's
>>what I did:
>>
>>-each request is handled by a javaflow function
>>-the request has some magic chars separating object
>>from view type, so i 
>>have something like person.form.edit.do
>>-so when i am in the right flow function, i prepare
>>all data, do some 
>>CForm stuff with javaflow (I am sure you'll need
>>help here, too :-) ), 
>>and the call form.show, which acts like a
>>SendPageAndWait, as you said.
>>-the trick is, i call
>>form.show("person.form.edit.html"); which is 
>>handled by another pipeline, which does the
>>aggregation of menu, header, 
>>footer, and -> content, by some other internal
>>pipelines...
>>
>>I had to change some flow and generators, but now
>>I've quite a clean 
>>pipeline setup... separating controller matchers
>>from renderer matchers...
>>
>>I hope you know what I mean, I am starting to
>>document that all soon, 
>>but for now there's no diagram of my pipeline flows
>>yet, sorry...
>>
>>:-),
>>tom
>>
>>footh wrote:
>>
>>    
>>
>>>Over the past several weeks, I've converted 90% of
>>>      
>>>
>>my
>>    
>>
>>>site from JSP to Cocoon with excellent results. 
>>>      
>>>
>>Now,
>>    
>>
>>>I'm attempting to convert my forms.  I'd like to
>>>      
>>>
>>use
>>    
>>
>>>CForms, however, I am having trouble fitting the
>>>      
>>>
>>CForm
>>    
>>
>>>structure into my current site structure.
>>>
>>>Right now, when a user requests any .html page,
>>>      
>>>
>>they
>>    
>>
>>>are sent to a primary javaflow that sets a couple
>>>important variables and then sends that data to
>>>another pipeline which aggregrates five sources: 
>>>      
>>>
>>the
>>    
>>
>>>header, footer, two sidebars and main content. 
>>>      
>>>
>>Each
>>    
>>
>>>part of the aggregation is another pipeline that
>>>generates the necessary XML for each piece.
>>>
>>>Now, I would like my forms to go through the same
>>>flow.  Of the five parts that are aggregated, the
>>>      
>>>
>>form
>>    
>>
>>>would be in the main content.  The problem is,
>>>      
>>>
>>CForms
>>    
>>
>>>appears to have it's own process that you're stuck
>>>with.  I can't seem to figure out a way to
>>>      
>>>
>>integrate
>>    
>>
>>>it into my main flow.
>>>
>>>Once you call form.show in a javaflow, the pipeline
>>>processing ends.  And I can't figure out a way to
>>>build my page via my standard flow, and then insert
>>>      
>>>
>>my
>>    
>>
>>>form as the main content.
>>>
>>>I've tried several different ideas that have all
>>>      
>>>
>>met
>>    
>>
>>>with failure.  I was hoping someone with some
>>>      
>>>
>>CForms
>>    
>>
>>>experience could point me in the right direction. 
>>>      
>>>
>>If
>>    
>>
>>>necessary, I can supply excerpts of my pipelines to
>>>show what I am trying to do.
>>>
>>>Thanks,
>>>
>>>JF
>>>
>>>__________________________________________________
>>>Do You Yahoo!?
>>>Tired of spam?  Yahoo! Mail has the best spam
>>>      
>>>
>>protection around 
>>    
>>
>>>http://mail.yahoo.com 
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>    
>>
>>>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
>>
>>
>>    
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>---------------------------------------------------------------------
>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