I am attempting to call some java code from an XPage and was attempting to do this via SSJS. Just trying to get even a basic hello world example working. Ideally the return from the java code could be stuffed into a variable.
Goal: (Xpage contents)
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:label value="#{javascript:helloWorld.anyoneThere}" id="label1"></xp:label>
</xp:view>
would print 'Yo!' when the page loads. Instead I get a Runtime Error that helloWorld is not found.
Created a package
package testBean;
public class helloWorld {
public String anyoneThere(){
return "Yo!";
}
}
Then I modified the faces-config file
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
<managed-bean>
<managed-bean-name>helloWorld</managed-bean-name>
<managed-bean-class>testBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
</faces-config>
Not sure what I need to do to initialize / call the java function. Some examples I've seen are hooking into views or are on events but the intended code for what I'm doing would more likely be run in the beforePageLoad section.