The most important disadvantages of such monolithic sitemaps are loosing the overview over the sitemap flow and the little reusability.

The flowscript is for controlling page flow. So you should delegate the control immediately to it, not only after already having done some actions in the sitemap as there might be cases where this shall not happen.

In your function you can do then something like:

function updnachrichten(form) {

// get the document from the pipeline
var pipelineUtil = cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.PipelineUtil);
var document = pipelineUtil.processToDOM("DBResult-pipeline");
cocoon.disposeObject(pipelineUtil);


    // bind the document data to the form
    form.load(document);

    // show the form to the user until it is validated successfully
    form.showForm("nachrichtenliste-display-pipeline");

    // bind the form's data back to the document
    form.save(document);

    // write document back to the session for next pipeline
    cocoon.session.setAttribute("nachrichtenlisteDocument", document);

    // send to pipeline, which saves data in db
    cocoon.sendPage("nachrichten-save-pipeline");
}

Also for storing the result there should be no need to use the session. sendPage() accepts as second param an arbitrary object, which you can grab later on from the flow context. I don't know how you store the result in the db, but using the JXTemplateGenerator (to easily, transparently grab the document) and the SQLTransformer might be a solution.

At the end the sitemap becomes much less monolithic and more readable and reusable as you have little pipelines. And you separate the flow into the flow script.

Joerg

On 19.05.2004 16:14, [EMAIL PROTECTED] wrote:

Hi,
I'm using Cocoon 2.1.5-dev (snapshot 2004-04-16)
I have a sitemap like this:
----------------- snip ---------------------------------------------------------
[...]
<map:match pattern="content">
<map:act type="auth-protect">
<map:parameter name="handler" value="portalhandler"/>
<map:generate type="file" src="modules/content/inhalt{request-param:content}.xml" label="content" />
<map:transform type="session" label="transform-session"/> <map:select type="request-parameter">
<map:parameter name="attribute-name" value="content"/> [...]
<map:when test="_messages">
<!-- put in the select statement -->
<map:transform src="modules/messages/messagesSelect.xsl"/>
<map:transform type="sql">
<map:parameter name="use-connection" value="myPortalStructure"/>
<map:parameter name="show-nr-of-rows" value="true"/>
<map:parameter name="clob-encoding" value="UTF-8"/>
<map:parameter name="column-case" value="preserve"/>
<map:parameter name="userid" value="{session-context:authentication/authentication/data/userid}"/>
</map:transform>
<!-- put the row-state in the rows tag -->
<map:transform src="modules/messages/rowstate.xsl"/>
<!-- write the result to the session for use in the flowscript -->
<map:transform type="writeDOMsession">
<map:parameter name="dom-name" value="DBResult"/>
<map:parameter name="dom-root-element" value="document"/>
</map:transform>
<map:select type="request-method">
<map:when test="GET">
<map:call function="handleForm">
<map:parameter name="function" value="updnachrichten"/>
<map:parameter name="form-definition" value="forms/messagelist.xml"/>
<map:parameter name="bindingURI" value="forms/messageliste_bind.xml"/>
</map:call>
</map:when>
<map:when test="POST">
<map:call continuation="{request-param:continuation-id}"/>
</map:when>
</map:select>


</map:when>
[...]
----------------- /snip --------------------------------------------------------- and a flow script like this:
----------------- snip --------------------------------------------------------- cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");


function updnachrichten(form) {
// get the document from the session
var document = cocoon.session.getAttribute("DBResult");
// TODO: this is only, because the first time the function
// is called, the document is null.
if (null == document) {
form.showForm("nachrichtenliste-display-pipeline");
}
// bind the document data to the form
form.load(document);
// show the form to the user until it is validated successfully
form.showForm("nachrichtenliste-display-pipeline");
// bind the form's data back to the document
form.save(document);
// write document back to the session for next pipeline
cocoon.session.setAttribute("nachrichtenlisteDocument", document);
// send to pipeline, which saves data in db
cocoon.sendPage("nachrichten-save-pipeline"); }
----------------- /snip ---------------------------------------------------------


I wanted to use the result from the SQLTransformer (set in the Session with the WriteDOMSession) in my flow script, but realized, that first the flow script is executed and then the rest of the <map:when test="_messages">-part of the pipeline.
(If I make the request a second time, the result from the query of the request before is then in the session.)


Does anyone know why this is or how I can force cocoon to process my pipeline sequentially?

many thanks in advance,
Nicole


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



Reply via email to