wiki:MolgenisServletDecorator

If you want to completely customize your user interface, a nice trick is to use a  decorator for the generated MolgenisServlet.

Start off by creating your decorator class at an appropriate location, for example:

/handwritten/java/decorators/!MolgenisServletDecorator.java

Now re-map your MolgenisServlet to this class. Go to WebContent/WEB-INF/web.xml, and edit as follows:

<servlet>
   <servlet-name>MolgenisServlet</servlet-name>
   <servlet-class>decorators.MolgenisServletDecorator</servlet-class>
</servlet>

Now you can use this class to override any functions that are present in MolgenisServlet. For example:

public class MolgenisServletDecorator extends MolgenisServlet
{
	public UserInterface createUserInterface( Login userLogin )
	{
		UserInterface app = new UserInterface( userLogin);
		app.setLabel("Decorator powerrr!");
		app.setVersion("3.3.3");
		
		EmailService service = new SimpleEmailService();
		service.setSmtpProtocol("smtp");
		service.setSmtpHostname("localhost");
		service.setSmtpPort(25);
		service.setSmtpUser("");
		service.setSmtpPassword("");	
		app.setEmailService(service);
		
		new app.ui.Molgenis_headerPlugin(app);
		new app.ui.MainMenu(app);
		return app;
	}
}

You can use this same method to override any of the other services, e.g., on how to server REST services.

Discussion

We need proper documentation on the MolgenisServlet.

We also need to partition the MolgenisServlet into its seperate components for REST, SOAP, UI and so on to make it easier to vary.