Mostly Grails tips from Code Panda

Resolving Grails XML references in ActionScript / Flex

Grails uses XPath in its XML converter, which requires additional processing in the Flex / ActionScript world. This post introduces a very simple solution that converts XML references into non-reference nodes.

This is a quick and dirty solution to a question posted by _HATES in the comments. Thanks for reading my blog.

The problem:

When you use Content Negotiation and the result has two references to the same item, Grails will render the second reference in an xml like the following:

ActionScript e4x lacks native support for the XPath format ( although there are external libraries like XPath-as3 that will do this for you).

For a recent project, I had to write my own resolver ( due to problems in SWF loading that affect ActionScript libraries ). Since this is something that might come up when you’re using Flex as a client for Grails, I thought I would share the funciton: