cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <>
Subject Re: flowscript bizData "AOP"
Date Mon, 19 Apr 2004 10:07:50 GMT
On Sat, Apr 17, 2004 at 11:28:00AM -0700, Christopher Oliver wrote:
> 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, 
> cocoon.consumer)}">
> </jx:macro>
> 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.
Another thought:

Let me bring you an example (concerning SoC and software clarity) that Stefano
brought up today:

<flow language="javascript">
  <script src="sortOrder.js"/>

<match pattern="table.html">
  <call function="getSortOrder"/>

<match pattern="table-view">
  <generate src="table.xml"/>
  <transform src="table2html.xsl">
    <parameter name="sortOrder" value="{flow-attribute:sortOrder}"/>


function getSortOrder() {
           {"sortOrder": cocoon.request.attibute.sortOrder}

now assume you have your flowscript variable homePath set in the top level script:

var homePath ="/myDirectory/myApplication";

you need this value to be seen by both generated views (JXTG) and stylesheets -
they both may create links to application screens. 

JXTG first. using your solution you insert homePath into user's session and
access it via ${cocoon.session.homePath}

Stylesheets: you have to pass a parameter to the stylesheet so you do : 

<match pattern="table-view">
  <generate src="table.xml"/>
  <transform src="table2html.xsl">
    <parameter name="homePath" value="{session:homePath}"/>

Cannot express it other like: this does not feel right. The use of session
looks like a workaround for me and for someone who would read my application
code it would look unclear.

There is another solution: use global sitemap variables. I also do not like it
at all. 
  - you have to put some of your code into sitemap (I'd prefer to keep all the
    variables in flowscript)
  - you have to pass this value to the function/continuation call and set it
    every time they are invoked - ugly!

I would really love something like you mentioned - another context at cocoon
root like ${cocoon.applicationWideVariables.homePath}


         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |

View raw message