You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ilya Obshadko <il...@gmail.com> on 2009/12/11 19:57:28 UTC

RSS feed output using Tapestry

Could someone point out how to create RSS feed using Tapestry page?

I tried the following (using
http://wiki.java.net/bin/view/Javawsxml/Romelibrary):

- output feed contents to property and then use t:outputraw to display it
- output feed contents directly using beforeRender ( MarkupWriter writer )
rendering method

Both ways it ends up with error: "Page Rss did not generate any markup when
rendered. This could be because its template file could not be located, or
because a render phase method in the page prevented rendering."

What am I doing wrong?

Thanks in advance.

-- 
Ilya Obshadko

Re: RSS feed output using Tapestry

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 12 Dec 2009 00:38:02 -0200, Howard Lewis Ship <hl...@gmail.com>  
escreveu:

> I've also created pages that directly output RSS, which was nice ...
> to be able to use T5 templating to generate the RSS content was a
> snap!

RSS or Atom? :)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: RSS feed output using Tapestry

Posted by Howard Lewis Ship <hl...@gmail.com>.
I've also created pages that directly output RSS, which was nice ...
to be able to use T5 templating to generate the RSS content was a
snap!

On Fri, Dec 11, 2009 at 11:49 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Fri, 11 Dec 2009 16:57:28 -0200, Ilya Obshadko <il...@gmail.com>
> escreveu:
>
>> Could someone point out how to create RSS feed using Tapestry page?
>
> Create a page and return a StreamResponse (in this case, a
> TextStreamResponse) containing the RSS output on its onActivate() method.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, software architect and developer, Ars Machina Tecnologia da
> Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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


Re: RSS feed output using Tapestry

Posted by Ilya Obshadko <il...@gmail.com>.
> Reading your original message again, you said that you used writeRaw(). It
> doesn't work because Tapestry expects to have a root element. Using a single
> MarkupWriter.writeRaw() call doesn't generate a root element. MarkupWriter
> doesn't parse what writeRaw() writes, so it just knows when the root element
> was created when you invoke element() the first time. In this case, you
> can't use MarkupWriter to output Rome's output.
>
> You could, however, generate the RSS feed using MarkupWriter only, one
> element() call per element, without using Rome.


Yes, I got it. Absence of the root element was actually the cause of the
problem.

I've already read about onActivate () and TextStreamResponse, but tried to
>> avoid it.
>>
>
> Why? Taking a quick look at the Rome package, I've found the SyndFeedOutput
> class. It has a method, outputString(), that writes the XML output to a
> String. Your code will look like this:
>
> Object onActivate() {
>        SeedFeed feed = ...;
>        // populate feed
>        SyndFeedOutput sfo = new SyndFeedOutput();
>        String output = sfo.outputString();
>        return new TextStreamResponse(output, "text/xml");
> }
>
> It can't get easier than this. :)


That's a solution I've ended up with :)


> Using template to form RSS output is unfortunately not an option in my
>> case.
>>
>
> Why not? Just curious. :)
>
>
The RSS feed is complicated quite a lot, it must support various feeds from
various sections of the site, so I'm trying to encapsulate the logic only in
page handler, rather than in both handler and template.

-- 
Ilya Obshadko

Re: RSS feed output using Tapestry

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 12 Dec 2009 07:36:43 -0200, Ilya Obshadko  
<il...@gmail.com> escreveu:

> That is, no way to do that using MarkupWriter? Could you explain why?

I've wrote a quick test and yes, you can use MarkupWriter to generate a  
page. I previously thought that it wasn't possible. I've learned something  
today. Nice. :)

My page:

public class Test {

	@BeginRender
	public void render(MarkupWriter writer) {
		
		writer.element("html");
		writer.element("head");
		writer.element("body");
		writer.write("Hello, Tapestry world!");
		writer.end();
		writer.end();
		writer.end();
		
	}
	
}

Reading your original message again, you said that you used writeRaw(). It  
doesn't work because Tapestry expects to have a root element. Using a  
single MarkupWriter.writeRaw() call doesn't generate a root element.  
MarkupWriter doesn't parse what writeRaw() writes, so it just knows when  
the root element was created when you invoke element() the first time. In  
this case, you can't use MarkupWriter to output Rome's output.

You could, however, generate the RSS feed using MarkupWriter only, one  
element() call per element, without using Rome.

> I've already read about onActivate () and TextStreamResponse, but tried  
> to avoid it.

Why? Taking a quick look at the Rome package, I've found the  
SyndFeedOutput class. It has a method, outputString(), that writes the XML  
output to a String. Your code will look like this:

Object onActivate() {
	SeedFeed feed = ...;
	// populate feed
	SyndFeedOutput sfo = new SyndFeedOutput();
	String output = sfo.outputString();
	return new TextStreamResponse(output, "text/xml");
}

It can't get easier than this. :)

> Using template to form RSS output is unfortunately not an option in my  
> case.

Why not? Just curious. :)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: RSS feed output using Tapestry

Posted by Ilya Obshadko <il...@gmail.com>.
That is, no way to do that using MarkupWriter? Could you explain why?

I've already read about onActivate () and TextStreamResponse, but tried to
avoid it.
Using template to form RSS output is unfortunately not an option in my case.

On Fri, Dec 11, 2009 at 10:49 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> Em Fri, 11 Dec 2009 16:57:28 -0200, Ilya Obshadko <il...@gmail.com>
> escreveu:
>
>
>  Could someone point out how to create RSS feed using Tapestry page?
>>
>
> Create a page and return a StreamResponse (in this case, a
> TextStreamResponse) containing the RSS output on its onActivate() method.
>
>
-- 
Ilya Obshadko

Re: RSS feed output using Tapestry

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 11 Dec 2009 16:57:28 -0200, Ilya Obshadko  
<il...@gmail.com> escreveu:

> Could someone point out how to create RSS feed using Tapestry page?

Create a page and return a StreamResponse (in this case, a  
TextStreamResponse) containing the RSS output on its onActivate() method.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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