cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Istvan Beszteri <>
Subject Re: own generator
Date Fri, 02 Aug 2002 08:32:51 GMT

I have updated the setup method. here is the code:

public void setup(SourceResolver resolver, 
		     Map objectModel,
		     String src,
		     Parameters par) throws ProcessingException,
           super.setup(resolver, objectModel, src, par);
       catch(ProcessingException exc)
       catch(SAXException exc)
       catch(IOException exc)

       request = ObjectModelHelper.getRequest(objectModel);
       paramNames = request.getParameterNames();
       uri = request.getRequestURI();

I had a sily mistake in the pipeline, too (in the generate line I wrote 
source instead of src). The corrected pipeline is:

    <map:match pattern="foo/*">
      <map:act type="request">
        <map:parameter name="parameters" value="true"/>
        <map:generate type="ist" src="{../1}"/>
      <map:serialize type="xml"/>

      <map:transform src="stylesheets/system/error2html.xsl"/>
      <map:serialize status-code="500"/>

Now I can get the src in the source field of the generator.
The parameters field of the generator still conatins 0 parameters.

On Thursday 01 August 2002 17:23, you wrote:
> Ah, I think the problem is that I overrode the setup() method from
> AbstractGenerator, but didn't look at what it
> was doing in the original - I presumed incorrectly that it did nothing. 
> You should be able to get at the source by
> adding super.setup() to the first line of the new setup() call below.  Now
> that I've looked more carefully, we could get rid of our own implementation
> of setup and use the instance variable objectModel from the superclass to
> get our parameters from within generate if we really wanted to - on the
> other hand, for demonstration purposes it's better in my view to show that
> it's available as a callback method from the container for performing setup
> tasks.
> Thank you by the way for reorganizing the output to be more xml friendly.
> I've already started work turning this example into a how-to for the
> documentation.  Would you mind if I incorporate your modifications for that
> so I don't have to come up with another example?
> Geoff

Please check that your question  has not already been answered in the
FAQ before posting.     <>

To unsubscribe, e-mail:     <>
For additional commands, e-mail:   <>

View raw message