cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobia Conforto <tobia.confo...@linux.it>
Subject Re: Calling an InputModule from flowscript
Date Fri, 19 Oct 2007 14:58:58 GMT
Joerg Heinicke wrote:
> Tobia Conforto wrote:
> > But I cannot pass null to my own input module in place of the third
> > parameter (Map objectModel) because I use that objectModel in my
> > class
>
> Another workaround is to create a map in your flowscript with the
> necessary data.

Yes, I had arrived at the same conclusion:

  function foo(attr) {
    // call an input module that needs access to the request object
    var tmp = new java.util.HashMap();
    tmp.put('request', cocoon.request);
    return fooInputModule.getAttribute(attr, null, tmp);
  }


> > the sample fails to call cocoon.releaseComponent() on the
> > InputModule selector, after calling getComponent() on it.
>
> the using code should not be aware of the component's implementation
> details - and that's why it should always release the component.

Here's how I did it, for the archives.  By the way, I'm saving the input
module into a global flowscript variable, because it's supposed to be
request-independent.  The fake objectModel map, on the other hand, is
created each time in the foo() function.

  // in the global scope: get the input module I will call in foo()
  var inputModuleSelector = cocoon.getComponent(InputModule.ROLE + "Selector");
  try {
    var fooInputModule = inputModuleSelector.select("foo");
  } finally {
    cocoon.releaseComponent(inputModuleSelector);
    inputModuleSelector = null;
  }


Tobia

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


Mime
View raw message