Actually its was pretty easy (like most things I try to do with tapestry) as soon as I understand the concept. Simply getting the current ComponentEventResultProcessor from the Environment, wrap it in case of exceptions and let it process the return-value. It is really as easy as this, EXCEPT you use the processor AND return a value after that. This way I managed it to have 2 json-objects in the response which made tapestry.js really mad =D
{"redirectURL":"/TapTestReal/about"}{"content":"And another counter: 11"} public class Counter { @InjectComponent private Zone countzone; @Inject private ComponentResources componentResources; @Environmental private ComponentEventResultProcessor componentEventResultProcessor; @Property @Persist private int count; private Object fireValueChanged() throws IOException { ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(componentEventResultProcessor); componentResources.triggerEvent("valueChanged", new Object[]{new Integer(count)}, callback); if (!callback.isAborted()) { return countzone.getBody(); } return null; } public Object onUp() throws IOException { count++; return fireValueChanged(); } public Object onDown() throws IOException { count--; return fireValueChanged(); } public Object onReset() throws IOException { count = 0; return fireValueChanged(); } public String getZoneId(){ return countzone.getClientId(); //with this I can use this component multiple times on a single page even with ajax enabled } } I cutted some pieces of code which implement features not used in this context, hopefully it still compiles. That component can be used on a page like: Object onValueChangedFromEggCounter(int value){ if(value > 10) return ToMuchEggs.class; return null; } and everything works like expected (if counter reaches 11 you are redirected to another page). - Mario 2009/8/10 Howard Lewis Ship <hls...@gmail.com> > To be specific, when during an Ajax request the component even returns > a page class or page instance, Tapestry builds and returns a Link as > part of the JSON response, the the client-side loads that Link's URL > into the browser address, performing a redirect. > > There are two implementations of ComponentEventResultProcessor, one > for @Traditional and one for @Ajax ... just bear that in mind if you > want to read the existing code, or extend the current behavior. They > are both based on a mapped configuration from return type to a > handler. > > On Sun, Aug 9, 2009 at 5:34 PM, Thiago H. de Paula > Figueiredo<thiag...@gmail.com> wrote: > > Em Sat, 08 Aug 2009 15:26:45 -0300, Mario Rabe < > mario.r...@googlemail.com> > > escreveu: > > > >> Hi, > > > > Hi! > > > >> how can I do a redirect from a XHR-request? Here an example to make > clear > >> what I want to do: > > > > If it was a Tapestry-provided event, you could just return a page > instance, > > a page class, an URL or a page name in an event handler method. > > Looking at the Form component sources, it uses this callback instance in > its > > VALIDATE_FORM event: > > > > ComponentResultProcessorWrapper callback = new > > ComponentResultProcessorWrapper(componentEventResultProcessor); > > > > componentEventResultProcessor comes from an environmental service: > > > > @Environmental > > private ComponentEventResultProcessor componentEventResultProcessor; > > > > Try using the above callback and please post the results. :) > > > > -- > > Thiago H. de Paula Figueiredo > > Independent Java consultant, developer, and instructor > > http://www.arsmachina.com.br/thiago > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > > For additional commands, e-mail: users-h...@tapestry.apache.org > > > > > > > > -- > Howard M. Lewis Ship > > Creator of Apache Tapestry > Director of Open Source Technology at Formos > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >