You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Askild Aaberg Olsen <as...@xangeli.com> on 2004/05/06 15:44:34 UTC

Woody/CForms: Extending bound XML through pipeline

I have a document bound to a form, and whenewer a specific event occurs, I
would like to:
 * pass the bound document to a pipeline
 * transform it
 * redisplay the form again with the transformed document.

This is my current approach to the on-action in the model:

<wd:on-action>
	<javascript>
		form.save(document);
			...somthing that runs the document through the
pipeline...
		form.load(document);
	</javascript>
</wd:on-action>

This approach seems to work, e.g. the document is correctly redisplayed in
the form, but I lack the part running the document through the pipeline.

Any clues or hints, or am I way off here conceptually?

I'm using Cocoon 2.1.4 with flow.js V2.

Askild


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


Re: Woody/CForms: Extending bound XML through pipeline

Posted by Askild Aaberg Olsen <as...@xangeli.com>.
> Bruno Dumon wrote:
> > I have a document bound to a form, and whenewer a specific event 
> > occurs, I would like to:
> >  * pass the bound document to a pipeline
> >  * transform it
> >  * redisplay the form again with the transformed document.
> > 
> > This is my current approach to the on-action in the model:
> > 
> > <wd:on-action>
> > 	<javascript>
> > 		form.save(document);
> > 			...somthing that runs the document through the
> > pipeline...
> > 		form.load(document);
> > 	</javascript>
> > </wd:on-action>
> > 
> > This approach seems to work, e.g. the document is correctly 
> > redisplayed in the form, but I lack the part running the document 
> > through the pipeline.
> > 
> > Any clues or hints, or am I way off here conceptually?
> 
> Regardless of what you're trying to do makes sense (what do 
> you want to do with the document in the pipeline?), some hints:
> 
> org.apache.cocoon.components.flow.util.PipelineUtil.processToDOM(...)
> will help you to execute a pipeline and capture the result in 
> a DOM tree.
> 
> To make the current document available to that pipeline, you 
> can pass it as 'viewData' (second argument of processToDOM 
> method), and use the xmodule source (see scratchpad) in 
> combination with the flow-attribute input module to let the 
> pipeline's generator read from that document.

Thank you Bruno, you made my day!

Now the on-action looks like this:

<wd:on-action>
	<javascript>
		form.save(document);
		var pipelineUtil =
cocoon.createObject(Packages.org.apache.cocoon.components.flow.util.Pipeline
Util);
		document = pipelineUtil.processToDOM("some.cocoon.pipeline",
{"document" : document});
		form.load(document);
		cocoon.disposeObject(pipelineUtil);
	</javascript>
</wd:on-action>

Anything I missed? Should I use try/finally, like in the flowscript?

I used the JXTemplateGenerator to retrieve the document in the pipeline,
with the same approach as cocoon.SendPage(). This seems to work fine.


Background (for the curios):

I have a quite large XML/SQL-model, and I generate an annotated XSD schema
(for MS SQLXML) to retrieve the data for publishing, but also the CForms
model/template/binding for registration of data. Then I use flowscript to
"bind" different forms together to make applications of these.

The repeater-widget seems to be most suitable when you enter new data, but
it gets a little more awkward when you want to refer to some already
existing data. I therefore have some search-widgets together with the
repeater, and the searchresult is presented in a selection-list.

When the user then adds an item from the list, the on-action in question is
triggered.

Based on the selected-item (which is bound to a include-element in the
document), the requested fragmentis included in the document by the
pipeline, and is ready for further processing by the form.

Maybe this doesn't make sense to anyone but myself...


Anyway, thank you again Bruno, and a big "thankyou" to everyone that has
made Cocoon the marvellous system it is!

Askild
-


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


Re: Woody/CForms: Extending bound XML through pipeline

Posted by Bruno Dumon <br...@outerthought.org>.
On Thu, 2004-05-06 at 15:44, Askild Aaberg Olsen wrote:
> I have a document bound to a form, and whenewer a specific event occurs, I
> would like to:
>  * pass the bound document to a pipeline
>  * transform it
>  * redisplay the form again with the transformed document.
> 
> This is my current approach to the on-action in the model:
> 
> <wd:on-action>
> 	<javascript>
> 		form.save(document);
> 			...somthing that runs the document through the
> pipeline...
> 		form.load(document);
> 	</javascript>
> </wd:on-action>
> 
> This approach seems to work, e.g. the document is correctly redisplayed in
> the form, but I lack the part running the document through the pipeline.
> 
> Any clues or hints, or am I way off here conceptually?

Regardless of what you're trying to do makes sense (what do you want to
do with the document in the pipeline?), some hints:

org.apache.cocoon.components.flow.util.PipelineUtil.processToDOM(...)
will help you to execute a pipeline and capture the result in a DOM
tree.

To make the current document available to that pipeline, you can pass it
as 'viewData' (second argument of processToDOM method), and use the
xmodule source (see scratchpad) in combination with the flow-attribute
input module to let the pipeline's generator read from that document.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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