Friday, July 27, 2007

ZK, EL and XML Escaping

If you've worked with ZK for a bit, you will know that it uses an EL style of expression to set values and perform actions anywhere in the page. Which means you should be able to do something like:

<radio label="Sale" onCheck="${priceLabel.value='fruit'}"/>

However, this is not correct, in fact EL expressions will not be evaluated at all for the above line. The correct way to do it is as follows:

<radio label="Sale" onCheck="priceLabel.value=&quot;fruit&quot;"/>

Why? The developers guide explains it: "you could use EL expressions in any part of ZUML pages, except the names of attributes,
elements and processing instructions"

As the above is a processing instruction, you need to drop the EL syntax, which is a little strange as the syntax remains the same and is apparently still processed by BeanShell. Oh well. As for the escaping, that's just well-formed XML.

No comments: