Server

There are 2 options available to you when creating a form page: You can either use the Model Form framework or create your own custom REST resource to handle server requests.

The Model Form framework is already extensible; if a module has a model form page setup for a certain model level type and your dependent module wants to add some extra fields or write an extra model, all you have to do is use a ModelResourceListener (see the "Server-side Customization" section for more information).

The other option is to create your own custom REST resource. Making that extensible isn't difficult; Platform provides a ResourceListenerFactory which you can use to implement the same listener pattern that the Model Form framework uses.

Creating an Extensible REST Resource

The first thing you want to do is create a listener class and provide methods that can be overridden by a subclass in a dependent module. You can then use the ResourceListenerFactory to fetch all subclasses of that listener and call their overridden methods within your REST resource. Here's some example code:

public abstract class MODARestResourceListener {
public void preUpdate(Long sysId) { }
public void postUpdate(Long sysId) { }
}
 
public class MODARestResource extends BaseResource {
@POST
@Path("/update")
public JSONObject update(@FormParam("sysId") Long sysId) {
List<MODARestResourceListener> listeners = ResourceListenerFactory.get(MODARestResourceListener.class);
for(MODARestResourceListener listener : listeners) {
listener.preUpdate(sysId);
}
...
for(MODARestResourceListener listener : listeners) {
listener.postUpdate(sysId);
}
}
}

Extending a Custom REST Resource

If you want to extend a custom resource designed the way shown above, all you have to do is extend the corresponding listener class and overrides its methods:

@ResourceListener("com.onenetwork.moda.rest.MODARestResourceListener")
public class MODBRestResourceListener extends MODARestResourceListener {
public void preUpdate(Long sysId) {
...
}
public void postUpdate(Long sysId) {
...
}
}