Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jakarta-tapestry Wiki" for change notification.
The following page has been changed by JesseKuhnert: http://wiki.apache.org/jakarta-tapestry/41RenderCycleDesign ------------------------------------------------------------------------------ That's the core of the response model. There are lots of other ways to do it and nuances depending on the problem being solved (ie dealing with javascript, doing pre/during/after response javascript effects/etc..). + === The CORE Problem === + The largest problem with all of this is the fact that components directly control the IMarkupWriter instance being used to render the response. There are no extension points or other known ways to control which components responses go back to the client and which don't. Adding in new renderComponent() logic that handles JSON responses for instance creates even more problems, because in those instances the IMarkupWriter interface isn't even remotely close to resembling the structure of a JSON response. + + == The Solution == + In order to start getting a better handle on controlling the response, as well as managing the fact that one response might require calling renderComponent(IMarkupWriter, IRequestCycle) and another might require renderComponent(IJSONWriter, IRequestCycle) I have introduced a new object called ResponseBuilder. + + This is what the ResponseBuilder interface looks like, which is remarkably similar to ResponseRenderer: + {{{ + public interface ResponseBuilder { + + void renderResponse(IRequestCycle cycle); + } + }}} + + The difference is that the ResponseBuilders that are available are configured from a hivemind configuration point using a Factory to choose the type of builder that is used in a response depending on the header and parameters receieved in a request. For instance, we now currently have a DefaultResponseBuilder and a JSONResponseBuilder. The factory uses a configured list of ResponseContributor entries which are responsible for reading in request meta information and determining which type of response should be given. + + The end result might be an object looking like this for default responses: + + {{{ + public class DefaultResponseBuilder implements ResponseBuilder { + + protected IMarkupWriter _writer; + + public DefaultResponseBuilder(IMarkupWriter writer) { ... } + + public void renderResponse(IRequestCycle cycle) { + IPage page = cycle.getPage(); + page.renderResponse(this, cycle); + } + } + }}} + + That in and of itself isn't very new a concept to put past, as it's more or less already happening that way. The new JSONResponseBuilder does however start to change things. + + {{{ + public class JSONResponseBuilder implements ResponseBuilder { + + protected IJSONWriter _writer; + + public JSONResponseBuilder(IJSONWriter writer) { ... } + + public void renderResponse(IRequestCycle cycle) { + IPage page = cycle.getPage(); + page.prepareForRender(); + page.renderResponse(this, cycle); + } + } + }}} + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
