Getting To The Java Roots of XPages – Part 4

So in the previous part we wrote our first bit of java code, a method ( getMyInternetAddress) in a class ( AboutMe ) in a package ( ). So the question remains, how do I actually use that in my XPage applications?

So remember that link that had a big ssjs code block in it? To use the new java code instead you can just replace the ssjs with a single line that reads

and the xpage can be saved and previewed and it will do the exact same as what the long ssjs version did. The generated java for the page now looks like this

XspOutputLink result = new XspOutputLink();
setId(result, "link1");
String sourceId = "link1/@text";
String textExpr = "#{}";
ValueBinding text = evaluator.createValueBinding(result, textExpr, sourceId,String.class);
result.setValueBinding("text", text);
return result;

You will notice that I’m still using ssjs and the resulting java still uses this ValueBinding concept to run the ssjs at runtime. While there are ways to avoid ssjs totally ( which I’ll explain in upcoming parts ) this is actually a tiny little bit better then before because your class already compiled and optimized by the compiler, meaning it runs much faster then the long ssjs version.

Wouldn’t it be much better if I could get rid of the ssjs entirely? I’ll look at this in the next few parts but next we need to talk about another scary word, Beans…

Tagged with: ,
Posted in None
%d bloggers like this: