Native Function Interface


It is also possible to call static functions natively implemented in Java by declaring them in your WebDSL model and then implementing them in Java.

In WebDSL:

    native function sayHello(to : String) : String;

Implementations in Java are put in the “nativejava/” directory of you application. The class name must be the capitalized function name and the native function takes one extra parameter of type utils.PageServlet for context information. Supporting jar files go into “lib/”.

So in this case, put in nativejava/

    package nativejava;

    import utils.AbstractPageServlet;

    public class SayHello {
      public static String sayHello(AbstractPageServlet page, String to)
        return "Hello " + to;