Runtime Expressions in XML

ZEN, Caché

Hi.

 

I'm facing a problem when I try to use the Runtime Expression below inside the XData Contents:

<html>#($$$Text("Testing!"))#</html>

It compiles correctly, but when I open the page on the browser I get the message "Expression Error" instead of "Testing!".

 

How could I use the $$$Text macro with Runtime Expressions? Is there a way to make this?

 

Thanks!

  • 0
  • 0
  • 218
  • 3
  • 2

Answers

Actually, XData content it is a just XML, in it is stored exactly as you wrote it in IDE. But it is possible to compile any XData to any other format as you need, at this portal you can find two articles about how to do it, first and second. In your case it could be much easier, like some method which in compile mode gets all XData content and place it to &html<>, which then compile again as usual, and what you need after it is just call this generated method, to show this html. 

I couldn't see a way to use this approach in my case.

Should I override the %CreatePage ( %ZEN.Component.page) method?

Thank you, Dmitry.

You cannot use macros in Zen runtime expression this documentation chapter covers runtime expressions:

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

If this question is actually about localizing text in Zen, please take a look at this documentation chapter:

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

Localize your text in %OnGetJSResources() and load it on the client-side via zenText(id).

Thanks you Stefan.

I've already read that documentation but I've not noticed the text talking about macros.

I would like a way to use localization directly in XData, without any JS code. Nevertheless, I'm going to this zenText or JS $$$Text approach.

The <html> component does not handle localization for you out of the box, as you can inject arbitrary HTML into it.

Most of the other components do localize their captions and titles automatically if you set the DOMAIN parameter in your Zen page. A button component automatically creates a dictionary entry for its caption property, e.g.:

<button caption="Save"/>