May 2, 2016, 5:01 AM
178 Posts

converting SSJS to Java Classes

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 9.0.1
  • Role: Developer
  • Tags: managed bean,javascript,java
  • Replies: 2

for an application I am wondering if I will convert large SSJS libraries to Java Classes to use them as managed beans in order to gain some performance but also hopefully some cleaner code.


are there any best practices when converting the code?

May 3, 2016, 6:22 AM
33 Posts
Use MVC where possible

I have found that moving my code to an MVC style architecture cleans up the code immensely.  Granted, it does lead to a lot of boiler plate stuff, but separating things out this way helped me write clear code that was easy to revisit.  I found the series on "Rethinking Xpages" by Pipalia to be a very good grounding in the basics for managed beans with MVC.  I also got a lot of good things from John Dalsgaard's MVC Bean presentations and demo database: particularly the method that he adds to a bean to get a handle on the current bean instance from the class.

May 4, 2016, 2:20 PM
589 Posts



You're big win will likely be cleaner code vs better performance.  To me the best practice is to seperate your business logic from your front end / UI logic.  So I use "pageControllers" to talk to the page and I create classes to work with my business objects (Companies, Contacts, etc) that are more standalone and don't care about the actual "XPage".  That's the best practice in my opinion and a simplified MVC.

By using pageControllers I now create very few "Managed Beans" in the faces-config file.  It's rather nice really.