Calling SSJS from Java?

喜欢而已 提交于 2019-12-01 04:58:57

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/9099093/calling-ssjs-from-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!