The Architecture
The brief introduction to the HIJAX methodology in the previous section might have led you to believe that you have to implement most of your applications twice: once in a traditional HTML format to support non-AJAX-capable platforms and again in an AJAX environment with JavaScript libraries on the client side and XML- or JSON-generating transactions on the server side.
However, with the judicious use of techniques I described in my InformIT article Optimized Presentation of XML Content, you can get both views of the application from the same server-side transactions:
- All server transactions should generate XML output (even when they report errors), so their results will be immediately usable by the client-side AJAX code.
- For visitors not using the AJAX version of the application, the XML output should be transformed into HTML on the server using an XSLT transformation. The transformed HTML text should include links to other transactions so the non-AJAX-capable visitors can still explore most of the functionality offered by your application.
- The design and development process that you can use with HIJAX thus includes the following steps:
- In the application design phase, identify all transactions that have to be executed on the server.
- Design the output format (XML schema) returned by each transaction. The output should include enough data to be self-sufficient when presented to the non-AJAX end user.
- Code all server transactions to accept their input from URL or through the FORM POST method (these are the only methods a visitor without JavaScript can use).
- Ensure that all server-side transactions return their results (including error messages and status codes) in XML format.
At this point in the development process you can test isolated transactions, inspect the XML output they generate and verify their correctness. After the transactions have been validated, develop the client-side part of the application:
- Develop the XSLT transformations for each transaction and the CSS style sheet to support the resulting HTML markup.
- Test the HTML markup produced by individual isolated transactions.
- Test the whole application (in particular, the interaction between the transactions) in the HTML rendering.
- After the individual transactions have been thoroughly tested, develop the AJAX client-side JavaScript code and test it.