You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andreas Andreou <an...@di.uoa.gr> on 2005/08/16 20:00:12 UTC

IMarkupWriter in Tapestry 4

In a component's renderComponent method,
is it possible to get (or create) an instance of an IMarkupWriter having 
the same
properties as the one passed to the renderComponent?
I want to render the component's body into a String and do some 
post-processing
before writing it back to the output ( so, I cannot use the 
NestedMarkupWriter
returned by getNestedWriter() ).

I can create a new one using:
new MarkupWriterImpl(content|Type, writer, filter)|
and I can get the contentType of the current writer,
but there's no getter that'll return
the filter already attached to an IMarkupWriter






---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: IMarkupWriter in Tapestry 4

Posted by Andreas Andreou <an...@di.uoa.gr>.
That's true.
I misread the javadocs.

Howard Lewis Ship wrote:

>Invoking getBuffer() will close any open *tags* and prevent further
>output from being rendered by the writer.  Only invoking close() will
>cause anything to be printed to the parent markup writer.
>
>On 8/16/05, Andreas Andreou <an...@di.uoa.gr> wrote:
>  
>
>>Jesse Kuhnert wrote:
>>
>>    
>>
>>>Assuming you are using a hivemodule.xml contribution...add the following:
>>>
>>><contribution configuration-id="tapestry.markup.MarkupFilters">
>>>       This contribution associates text/xml content types with
>>>tapestry so that an
>>>       IMarkupWriter instance can be created.
>>>       <content type="text/xml"
>>>           filter="instance:org.apache.tapestry.markup.UTFMarkupFilter"/>
>>>   </contribution>
>>>
>>>And then do something sort of similar to this:
>>>
>>>//Web response should be "injected" infrastructure:response ..
>>>PrintWriter output = webResponse.getPrintWriter(new ContentType("text/xml"));
>>>MarkupWriterSource mw = cycle.getInfrastructure().getMarkupWriterSource();
>>>IMarkupWriter w = mw.newMarkupWriter(output, new ContentType("text/xml"));
>>>
>>>
>>>      
>>>
>>Thanks!
>>
>>    
>>
>>>Why can't you use the nested markup writer? You can always call
>>>writer.printRaw(nestedWriter.getBuffer()) to get a complete and valid
>>>stream...
>>>
>>>
>>>      
>>>
>>I haven't tried this, but it has always been my understanding that once
>>you start a nested writer
>>it will eventually output its data to the parent writer. And I think
>>that calling getBuffer closes
>>the nestedWriter and so the content will be printed on the parent writer
>>anyway, which is what
>>I want to avoid.
>>
>>    
>>
>>>jesse
>>>On 8/16/05, Andreas Andreou <an...@di.uoa.gr> wrote:
>>>
>>>
>>>      
>>>
>>>>In a component's renderComponent method,
>>>>is it possible to get (or create) an instance of an IMarkupWriter having
>>>>the same
>>>>properties as the one passed to the renderComponent?
>>>>I want to render the component's body into a String and do some
>>>>post-processing
>>>>before writing it back to the output ( so, I cannot use the
>>>>NestedMarkupWriter
>>>>returned by getNestedWriter() ).
>>>>
>>>>I can create a new one using:
>>>>new MarkupWriterImpl(content|Type, writer, filter)|
>>>>and I can get the contentType of the current writer,
>>>>but there's no getter that'll return
>>>>the filter already attached to an IMarkupWriter
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: IMarkupWriter in Tapestry 4

Posted by Howard Lewis Ship <hl...@gmail.com>.
Invoking getBuffer() will close any open *tags* and prevent further
output from being rendered by the writer.  Only invoking close() will
cause anything to be printed to the parent markup writer.

On 8/16/05, Andreas Andreou <an...@di.uoa.gr> wrote:
> Jesse Kuhnert wrote:
> 
> >Assuming you are using a hivemodule.xml contribution...add the following:
> >
> ><contribution configuration-id="tapestry.markup.MarkupFilters">
> >        This contribution associates text/xml content types with
> >tapestry so that an
> >        IMarkupWriter instance can be created.
> >        <content type="text/xml"
> >            filter="instance:org.apache.tapestry.markup.UTFMarkupFilter"/>
> >    </contribution>
> >
> >And then do something sort of similar to this:
> >
> >//Web response should be "injected" infrastructure:response ..
> >PrintWriter output = webResponse.getPrintWriter(new ContentType("text/xml"));
> >MarkupWriterSource mw = cycle.getInfrastructure().getMarkupWriterSource();
> >IMarkupWriter w = mw.newMarkupWriter(output, new ContentType("text/xml"));
> >
> >
> Thanks!
> 
> >
> >Why can't you use the nested markup writer? You can always call
> >writer.printRaw(nestedWriter.getBuffer()) to get a complete and valid
> >stream...
> >
> >
> I haven't tried this, but it has always been my understanding that once
> you start a nested writer
> it will eventually output its data to the parent writer. And I think
> that calling getBuffer closes
> the nestedWriter and so the content will be printed on the parent writer
> anyway, which is what
> I want to avoid.
> 
> >jesse
> >On 8/16/05, Andreas Andreou <an...@di.uoa.gr> wrote:
> >
> >
> >>In a component's renderComponent method,
> >>is it possible to get (or create) an instance of an IMarkupWriter having
> >>the same
> >>properties as the one passed to the renderComponent?
> >>I want to render the component's body into a String and do some
> >>post-processing
> >>before writing it back to the output ( so, I cannot use the
> >>NestedMarkupWriter
> >>returned by getNestedWriter() ).
> >>
> >>I can create a new one using:
> >>new MarkupWriterImpl(content|Type, writer, filter)|
> >>and I can get the contentType of the current writer,
> >>but there's no getter that'll return
> >>the filter already attached to an IMarkupWriter
> >>
> >>
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: IMarkupWriter in Tapestry 4

Posted by Andreas Andreou <an...@di.uoa.gr>.
Jesse Kuhnert wrote:

>Assuming you are using a hivemodule.xml contribution...add the following:
>
><contribution configuration-id="tapestry.markup.MarkupFilters"> 
>        This contribution associates text/xml content types with
>tapestry so that an
>        IMarkupWriter instance can be created.
>        <content type="text/xml"
>            filter="instance:org.apache.tapestry.markup.UTFMarkupFilter"/>
>    </contribution>
>
>And then do something sort of similar to this:
>
>//Web response should be "injected" infrastructure:response ..
>PrintWriter output = webResponse.getPrintWriter(new ContentType("text/xml"));
>MarkupWriterSource mw = cycle.getInfrastructure().getMarkupWriterSource();
>IMarkupWriter w = mw.newMarkupWriter(output, new ContentType("text/xml"));
>  
>
Thanks!

>
>Why can't you use the nested markup writer? You can always call
>writer.printRaw(nestedWriter.getBuffer()) to get a complete and valid
>stream...
>  
>
I haven't tried this, but it has always been my understanding that once 
you start a nested writer
it will eventually output its data to the parent writer. And I think 
that calling getBuffer closes
the nestedWriter and so the content will be printed on the parent writer 
anyway, which is what
I want to avoid.

>jesse
>On 8/16/05, Andreas Andreou <an...@di.uoa.gr> wrote:
>  
>
>>In a component's renderComponent method,
>>is it possible to get (or create) an instance of an IMarkupWriter having
>>the same
>>properties as the one passed to the renderComponent?
>>I want to render the component's body into a String and do some
>>post-processing
>>before writing it back to the output ( so, I cannot use the
>>NestedMarkupWriter
>>returned by getNestedWriter() ).
>>
>>I can create a new one using:
>>new MarkupWriterImpl(content|Type, writer, filter)|
>>and I can get the contentType of the current writer,
>>but there's no getter that'll return
>>the filter already attached to an IMarkupWriter
>>
>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: IMarkupWriter in Tapestry 4

Posted by Jesse Kuhnert <jk...@gmail.com>.
oh nevermind..right..there's probably not a valid filter on the nested writer...
On 8/16/05, Jesse Kuhnert <jk...@gmail.com> wrote:
> Assuming you are using a hivemodule.xml contribution...add the following:
> 
> <contribution configuration-id="tapestry.markup.MarkupFilters">
>         This contribution associates text/xml content types with
> tapestry so that an
>         IMarkupWriter instance can be created.
>         <content type="text/xml"
>             filter="instance:org.apache.tapestry.markup.UTFMarkupFilter"/>
>     </contribution>
> 
> And then do something sort of similar to this:
> 
> //Web response should be "injected" infrastructure:response ..
> PrintWriter output = webResponse.getPrintWriter(new ContentType("text/xml"));
> MarkupWriterSource mw = cycle.getInfrastructure().getMarkupWriterSource();
> IMarkupWriter w = mw.newMarkupWriter(output, new ContentType("text/xml"));
> 
> 
> Why can't you use the nested markup writer? You can always call
> writer.printRaw(nestedWriter.getBuffer()) to get a complete and valid
> stream...
> 
> jesse
> On 8/16/05, Andreas Andreou <an...@di.uoa.gr> wrote:
> > In a component's renderComponent method,
> > is it possible to get (or create) an instance of an IMarkupWriter having
> > the same
> > properties as the one passed to the renderComponent?
> > I want to render the component's body into a String and do some
> > post-processing
> > before writing it back to the output ( so, I cannot use the
> > NestedMarkupWriter
> > returned by getNestedWriter() ).
> >
> > I can create a new one using:
> > new MarkupWriterImpl(content|Type, writer, filter)|
> > and I can get the contentType of the current writer,
> > but there's no getter that'll return
> > the filter already attached to an IMarkupWriter
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: IMarkupWriter in Tapestry 4

Posted by Jesse Kuhnert <jk...@gmail.com>.
Assuming you are using a hivemodule.xml contribution...add the following:

<contribution configuration-id="tapestry.markup.MarkupFilters"> 
        This contribution associates text/xml content types with
tapestry so that an
        IMarkupWriter instance can be created.
        <content type="text/xml"
            filter="instance:org.apache.tapestry.markup.UTFMarkupFilter"/>
    </contribution>

And then do something sort of similar to this:

//Web response should be "injected" infrastructure:response ..
PrintWriter output = webResponse.getPrintWriter(new ContentType("text/xml"));
MarkupWriterSource mw = cycle.getInfrastructure().getMarkupWriterSource();
IMarkupWriter w = mw.newMarkupWriter(output, new ContentType("text/xml"));


Why can't you use the nested markup writer? You can always call
writer.printRaw(nestedWriter.getBuffer()) to get a complete and valid
stream...

jesse
On 8/16/05, Andreas Andreou <an...@di.uoa.gr> wrote:
> In a component's renderComponent method,
> is it possible to get (or create) an instance of an IMarkupWriter having
> the same
> properties as the one passed to the renderComponent?
> I want to render the component's body into a String and do some
> post-processing
> before writing it back to the output ( so, I cannot use the
> NestedMarkupWriter
> returned by getNestedWriter() ).
> 
> I can create a new one using:
> new MarkupWriterImpl(content|Type, writer, filter)|
> and I can get the contentType of the current writer,
> but there's no getter that'll return
> the filter already attached to an IMarkupWriter
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: IMarkupWriter in Tapestry 4

Posted by Andreas Andreou <an...@di.uoa.gr>.
Hmmm... I think I found it.
Maybe I can use:

IMarkupWriter newWrited = cycle.getInfrastructure().getMarkupWriterSource().
    newMarkupWriter( PrintWriter, ContentType);

and allow the framework to create a writer for me!


Andreas Andreou wrote:

> In a component's renderComponent method,
> is it possible to get (or create) an instance of an IMarkupWriter 
> having the same
> properties as the one passed to the renderComponent?
> I want to render the component's body into a String and do some 
> post-processing
> before writing it back to the output ( so, I cannot use the 
> NestedMarkupWriter
> returned by getNestedWriter() ).
>
> I can create a new one using:
> new MarkupWriterImpl(content|Type, writer, filter)|
> and I can get the contentType of the current writer,
> but there's no getter that'll return
> the filter already attached to an IMarkupWriter
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org