You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joe Latty <jo...@tias.com.au> on 2003/10/15 09:53:42 UTC

Flow script result as a generate

The javascript function is called from a pipeline match

<map:match pattern="test">
   <map:call function="main" />
   <map:serialize/>
</map:match>

The function looks something like this

function main() {
    var output = new Packages.java.io.ByteArrayOutputStream();
    cocoon.processPipelineTo('blah/matcher, {}, output);

    var doc = output.toString(); 

    // doc is now an xml string - this is all working fine
    // I want to do some error checking and a possible soap call at this point

    if (success)
        // the output (doc) would become the result, which would be using the function call like a generator, to be serialized    
    else    
        cocoon.sendPage('failure', {});

}

a) I hope I have made sense
b) Any ideas?

Joe

RE: Flow script result as a generate

Posted by Reinhard Poetz <re...@apache.org>.
From: Ugo Cei

> Reinhard Poetz wrote:
> > If you use the JXTemplateGenerator at your view pipeline 
> (successPage) 
> > you can serialize the XML returned by the soapComponent.
> 
> Do you mean that by simply using <jx:out value="soapXML"/> I get the 
> contents of the DOM in place of the <jx:out> element?

AFAIK beans and DOM-trees are automatically serialized (use
#{myBean/myDom} to include its content).

Reinhard


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


Re: Flow script result as a generate

Posted by Ugo Cei <u....@cbim.it>.
Reinhard Poetz wrote:
> If you use the JXTemplateGenerator at your view pipeline (successPage)
> you can serialize the XML returned by the soapComponent.

Do you mean that by simply using <jx:out value="soapXML"/> I get the 
contents of the DOM in place of the <jx:out> element?

	Ugo

-- 
Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail: u.cei@cbim.it


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


RE: Flow script result as a generate

Posted by Reinhard Poetz <re...@apache.org>.
From: Joe Latty

> The javascript function is called from a pipeline match
>
> <map:match pattern="test">
>   <map:call function="main" />
>   <map:serialize/>
> </map:match>
> 
> The function looks something like this
>
> function main() {
>     var output = new Packages.java.io.ByteArrayOutputStream();
>     cocoon.processPipelineTo('blah/matcher, {}, output);
> 
>     var doc = output.toString(); 
>
>    // doc is now an xml string - this is all working fine
>    // I want to do some error checking and a possible 
>       soap call at this point
>
>    if (success)
>        // the output (doc) would become the result, which would be
using the >           function call like a generator, to be serialized

>    else    
>        cocoon.sendPage('failure', {});
>
> }
> 
> a) I hope I have made sense

I understand what you want to do but this is *not* the way the Cocoon
control flow works. Please have a look at e.g. the calculator example.

The <map:call function="main" /> element is a kind of 'redirect'. The
sitemap passes the control to the flow layer. At the flow layer you
decide where to go next and passes the control back using
cocoon.sendPage(AndWait).
(--> so the <map:serialize/> doesn't make sense!)

> b) Any ideas?

I would write a specialized component that makes the soap calls:

function main() {

      var soapComp = cocoon.getComponent( "soapComponent" );
      var success = soapComp.call( "blah/matcher" );
      if( success ) {
	      cocoon.sendPage( "successPage", { soapXML :
soapComp.getDom() } );
      }
      else {
	      cocoon.sendPage( "failure", {} );           
      }
}

If you use the JXTemplateGenerator at your view pipeline (successPage)
you can serialize the XML returned by the soapComponent.

HTH
Reinhard



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