Thanks, Thiago! Although, thinking about it, I don't know if what I am doing is the best way for accomplish what I want. The original requirement for my app was to be capable of creating "user feedback messages" (like the ones Twitter has on its settings page) on the client as a response for some actions. The ideal case is to have a common way of showing these feedback messages in the following contexts:
* An Ajax request that triggers a component event, and we only need to tell the client to show "some message" (like "the entity was saved"): for accomplish this without dealing directly with a JSONObject and its script property (expected on ZoneManager at the client), I created another class (JavaScriptOnlyUpdate) that has methods like "error", "warn", "info" and "success" and a ComponentEventResultProccessor that handles that type of return value from an event handler (from Ajax Request) and creates a JSONObject with its script property properly setted and passes it to the masterEventResultProccessor (similar to what AjaxLinkComponentEventResultProcessor does). This works great and the resulting JSONObject is handled on the client by the ZoneManager so no extra code on the client is needed. I think it is a correct way of accomplish the objective. * An Ajax request that triggers a component event, we want to return some content and besides tell the client to show "some message": this is where things start to look no so pretty. The desired end result would be to return a JSONObject with its content and script properties properly setted. Since a component event is normally handled on the containing component page (for example, a success of a form within a page) the uggly solution I have is a component that has a JavaScriptOnlyUpdate object inside, is putted inside the Block I want to return as a content response, and injected on the containing page. Then, in the page event handler, I call some methods on this component to "put" the necessary messages and then on the afterRender of this component, it calls RenderSupport.addScript as needed. * A traditional (non-Ajax) component event request, like submitting a form, that wants to show a message after it loads the response page: I used the same component that the latter case, in a similar solution, but with some modifications. The component detects if there is an Ajax or Traditional request going on and if it is a traditional request, then it stores the messages on a property with persist flash. Then, in the page request (to which the client will be redirected), it can load the messages and call afterRender as needed. * A traditional (non-Ajax) page request that wants to show a message on the client: for this reason I wanted to distinguish component event requests from page requests, because in the latter, I must NOT store the messages on a persist flash property (because they will be used "right now", in the same request. The thing is I think that using this "special" component is not the right way. Maybe a right way could be to create a service that can be injected anywhere (not only on the render phase, like Environmental services) that has these methods "error", "success" and so on, to show messages, and making this service clever enough to deal with the current situation, to produce, finally, a script executed on the client that shows the messages. So, in case of an Ajax request, I should intercept the JSONObject to be finally returned and add to its script property the necessary JavaScript code to show the messages. This could be done by decorating JSONObjectEventResultProcessor. But in case of traditional requests I don't know exactly how to handle it. If it is a page render request, maybe decorating DocumentLinker service or adding another Filter to the pipeline it belongs... but if it is a component event request, I should store the messages, "passing them" to the next request so they are rendered in the page render request, and I don't know exaclty how to do this... maybe something to do with ApplicationStateManager? Am I missing something? Am I trying to crack a nut with a sledgehammer? Am I on the right way in the last paragraphs? Regards. -- View this message in context: http://n2.nabble.com/Distinguish-action-requests-from-page-render-requests-tp4586507p4588101.html Sent from the Tapestry Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org