2.14.2.2.6. Groovy Templates

In a Groovy template, the mechanism to create an URL is the same as the way of APIs above, however a splash of integration has been done to make creation of NodeURL simpler. A closure is bound under the nodeurl name and is available for invocation anytime. It will simply create a NodeURL object and return it:



UserNode node = ...;
NodeURL url = nodeurl();
url.setNode(node);
String s = url.toString();

The nodeurl closure is bound to Groovy template in WebuiBindingContext.



// Closure nodeurl()
put("nodeurl", new Closure(this)
{
  @Override
  public Object call(Object[] args)
  {
    return context.createURL(NodeURL.TYPE);
  }
});
Copyright ©2012. All rights reserved. eXo Platform SAS