cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Oliver <>
Subject Re: flowscript bizData "AOP"
Date Sat, 17 Apr 2004 18:28:00 GMT
I think you can use a combination of session attributes and jx macros to 
get the effect you want, e.g.

// Flow script

function toSAX(str, consumer) {

cocoon.session.setAttribute("stringToSAX",  toSAX);

function myPage() {
    sendPage("page.html", {...});

// template

<jx:macro name="output-xml">
<jx:parameter name="value">
<jx:set var="ignored" value="${cocoon.session.stringToSAX(value, 

Since both Flow script (cocoon.load()) and JXTemplateGenerator 
(<jx:import/>) support  including other files you can factor such code 
into supporting "library" files and include them in your application code.


Leszek Gawron wrote:

>I have a lot of flowscript top level variables (application context, currently
>logged in user context, application statistics). I would like to provide them
>to ALL application views. Right now sendPage implements a PUSH politics (I
>have to specify explicitly what I would like to make available to the view).
>Including top level variables manually in every sendPage is messy and error
>Is there any way to implement something like AOP for variables? I mean every
>bizData gets appended a set of common variables? This would make flow closer
>to a PULL model Controller exposes everything it got - in the boundaries of
>sanity of course - the view gets only what it wants. Exposing everything might
>not be a good idea but some controlled set might help a lot.
>moreover one would like to provide JXTemplateGenerator with additional
>functionality as in
>jx template generator has a number and date formatter but if application
>defines additional features in flowscript the easiest way would be to add it
>to every bizData.
>I guess you could even avoid the sax buffer and stream it directly in 
>the template:
>// flowscript fragment
>var message = ...;
>sendPage("page.html", {message: message, streamer: {toSAX: toSAX}});
>// jx template fragment
><jx:template xmlns:jx="">
><jx:set var="ignored" value="${streamer.toSAX(message.content, 
>	lg

View raw message