从Java调用SSJS? [英] Calling SSJS from Java?
问题描述
我创建了一个xPages应用程序,该应用程序使用位于服务器端javascript库中的许多服务器端javascript代码功能.
I have created an xPages application which uses a lot of server side javascript code functions located in a server side javascript library.
现在,我有一些Java代码位于java设计元素中,我想使用它们来调用javascript函数.
Now I have some java code located in the java design element which I would like to use to call the javascript functions.
我确实知道从Java调用javascript是不合逻辑的,但是我想所有服务器端javascript都已编译为Java,因此我认为可能可以获取已编译Java类的句柄.生成.
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.
有什么想法吗?
推荐答案
您可以创建值绑定,
ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{javascript:getData()}");
System.out.println(vb.getValue(FacesContext.getCurrentInstance()).toString());
这将从您的SSJS库中调用 getData()
方法.
This would call the getData()
method from your SSJS library.
这篇关于从Java调用SSJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!