cocoon-users mailing list archives

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

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

public void setup(SourceResolver resolver, 
		     Map objectModel,
		     String src,
		     Parameters par) throws ProcessingException,
		                            SAXException,
                                            IOException
   {
       try
       {
           super.setup(resolver, objectModel, src, par);
       }
       catch(ProcessingException exc)
       {
	   throw(exc);
       }
       catch(SAXException exc)
       {
	   throw(exc);
       }
       catch(IOException exc)
       {
	   throw(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:pipeline>
    <map:match pattern="foo/*">
      <map:act type="request">
        <map:parameter name="parameters" value="true"/>
        <map:generate type="ist" src="{../1}"/>
      </map:act>
      <map:serialize type="xml"/>
    </map:match>

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

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



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.     <http://xml.apache.org/cocoon/faq/index.html>

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


Mime
View raw message