Tuesday, June 20, 2006

 

EJAX page formatting II

"What about includes?" was one of the comments on my EJAX overview yesterday. Let's take a more detailed look at how an ordinary HTML page goes through the EJAX page formatter style sheet.

First of all, you don't need includes if what you can include can be put in the main HTML file. A company could have a main HTML template wich everything static included.

But secondly, you can put special instructions in the HTML file. The page formatter recognises these. One of them is an include directive: . So that takes care of the cases where you indeed want to include stuff.

But the purpose of this post was to explain how the replacement mechanism works. The page formatter takes an ajax response XML file and an HTML file. The ajax response file looks like this (it's actually exactly like OpenRico):

<ajax-response>
<response id="my-first-part" type="element>
<p>hello</p>
</response>
<response id="my-second-part" type="element>
<p>world</p>
</response>
</ajax-response>
Within the ajax-response container there can be multiple responses. When processing the HTML file, each element that has an id equal to an id found in a response with type element, gets replaced.

But the page formatter doesn't just simply copy the response, it just applies the response actually. As the default template in the page formatter just copies the node and next applies its child elements, the effect is copying.

But you can also override behaviour. For example the EJAX page formatter has (currently some) support for XForms. So the response, or the HTML file, can contain things like xforms:input or xforms:select1 and that is converted to HTML. The ultimate goal would be to have reasonably complete support XForms so dependencies and calculations wouldn't require so much custom JavaScript. But that requires the ability to load and manipulate XML and being able to do XPath in JavaScript.

And of course the page formatter recognises the head tag and inserts the script tags to load the required JavaScript files. And forms, and it inserts form validation handlers.

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?