Em Sat, 12 Dec 2009 07:36:43 -0200, Ilya Obshadko <ilya.obsha...@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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to