Thiago H. de Paula Figueiredo wrote:
> Em Fri, 15 May 2009 12:36:34 -0300, Andy Buckley
> <andy.buck...@durham.ac.uk> escreveu:
> 
>> Any replies to this (see below, or my previous mail in this thread)?
>>
>> Specifically, can I use Tapestry components to  link "bookmarkably" to
>> page events as a way of displaying the page in alternative formats
>> (inc. different MIME types)? And if this is an abuse of the events
>> system, what alternative approach do you recommend for (extensible)
>> alternative page formats?
> 
> Component events, IMHO, are abused to do what you wrote. On the other
> hand, you can use page events (onActivate) to do this. Don't forget that
> you can return a StreamResponse in onActivate() or any other event
> handler method. ;) The URL would be something like
> /page/parametername1/value1/parametername2/value2/format/pdf. Another
> approach would be another page for another response format.

Thanks for the advice. I'd rather avoid using separate pages, as
mentioned, but including the format handling in the activation context
is certainly possible. It prompts another question, though: how do I
return the "normal" page rendering as a StreamResponse in onActivate?
Here's the outline of my new onActivate() method:

public StreamResponse onActivate(EventContext context) {

  [interpret context]
  ...

  // Handle special format returns
  String fmt = getQueryParam("format");
  if (fmt.equals("plain")) {
    return asPlain();
  }

  // Normal rendering
  return null; //< this is wrong!
}

That "return null" is obviously wrong: I was hoping that it would fall
back to the default page rendering via the template but it just causes a
NullPointerException. How can I return the default rendering in this way?

Thanks!
Andy

-- 
Dr Andy Buckley
Institute for Particle Physics Phenomenology
Durham University
0191 3343798 | 0191 3732613 | www.insectnation.org

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

Reply via email to