A Command pattern for Ajax?
In the canonical example, the Gand of Four Command pattern is used by a toolkit developer to enable future users to specify actions within the toolkit. Not knowing how the toolkit will be used, the developer codes to an interface, leaving the implementation details abstract.
The average enterprise Web application involves a similar scenario, where one person or group provides the tools to another. Although the typical Web application probably doesn't need to provide such complete autonomy between teams, other factors at work in a JSF-Ajax call suggest the use of the Command pattern; namely the layered architecture, the intermediary of HTTP, and JSF's component model.
Now, let's say you're working on a Web application where you need to do the following:
- Handle commands arriving as Ajax requests without isolating the logic in a component.
- Make it easy to add new commands.
- Delegate the business logic to the business layer.
We'll start by taking a look at how you would set up the server side of the request, based on the AjaxCommand strategy. After that we'll look at the front-end design, and I'll conclude by comparing the original Command pattern with the AjaxCommand variation.
0 comments:
Post a Comment