4

I have created an xPages application which uses a lot of server side javascript code functions located in a server side javascript library.

Now I have some java code located in the java design element which I would like to use to call the javascript functions.

I do understand that it is not logical to call javascript from java, but I guess that all server side javascript is compiled to java, so I was thinking that it might be possible to get a handle to the compiled java class that was generated.

any ideas?

Thomas Adrian
  • 3,543
  • 6
  • 32
  • 62

1 Answers1

14

You can create a value binding,

ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{javascript:getData()}");
System.out.println(vb.getValue(FacesContext.getCurrentInstance()).toString());

This would call the getData() method from your SSJS library.

Declan Lynch
  • 3,345
  • 17
  • 36
Toby Samples
  • 2,168
  • 14
  • 15