Search code examples
javaxpagesxpages-extlib

XPages Controller Classes


Currently I am re-engineering a bigger application. In the backend I want to use only java instead of javascript, therefore, and for many other reasons (cleaner code, separation of concerns, etc.) I am using the XPages Scaffolding project from Jesse Gallagher (thanks to him for this work).

I really like the controller classes of this project, but one question I have to this architectural approach:

enter image description here

The controller class has a one-to-one connection to an xpage (.xsp). In the BasicDocumentController class the following method protected DominoDocument getDoc() is responsible for getting the corresponding datasource (DominoDocument) but - and here is my challenge - I have more than one datasource in one xpage.

Possible approaches:

a) Overriding the getDoc() method in MyDocumentController (make only sense for one datasource)

b) Two controller classes MyDocumentControllerA MyDocumentControllerB?

c) etc.

What would be an appropriate approach to handle this requirement?

Thanks in advance for any hint!


Solution

  • In that case, you could really just ditch the BasicDocumentController and use BasicXPageController. The former is mostly there for the simple case of a form-like XPage, but there's nothing too magical about it other than having a couple pre-made method stubs that are useful for hooking up to a document data source. With using multiple documents, you could make private DominoDocument getDocA() { return (DominoDocument)ExtLibUtil.resolveVariable("docA"); } and an equivalent for the other.