Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling SSJS from Java?

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?

like image 579
Thomas Adrian Avatar asked Dec 09 '22 02:12

Thomas Adrian


1 Answers

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.

like image 67
Toby Samples Avatar answered Dec 14 '22 07:12

Toby Samples