net

Extensibility Points

Web framework exposes some extensibility points in form of interfaces and their default implementations, which can be overridden to customize behavior. Some of them

Interface FormPersister

This interface is used to abstract out the persistence and lookup of the form objects. The state descriptor, generated by persist is sent to the client and stored on the client side. On every user interaction the state descriptor is posted to the server along with form data. To restore the form object, lookup is called with the sent state descriptor. After event is processed, the form is persisted again and a new state descriptor is sent back to the client and so on.

Possible implementation for this interface are:

  • Form state on the client (default implementation). State descriptor is the serialized form itself.
  • Form state in the session. State descriptor could be a unique id to resolve the form in the memory. Form object disposal needs to be implemented
  • Form state in the database. State descriptor could be a unique id to read the form from the database. Disposal of the stored form objects needs to be implemented

Additional functionality to be implemented could be:

  • Encrypting/decrypting serialized form object for the client side form persister
  • Encrypting/decrypting state descriptor for server side store mode (or use UUIDs)
  • Implement XSRF (Cross-Site-Request-Forgery) protection by modifying state descriptor (or of the special instance variable in case of client side form persister)

Interface MethodInvoker

Implement specific processing around event handler invocation. For example:

  • Open Hibernate session and expose it e.g. on the current thread. Close session after the call is finished
  • Custom exception processing and handling
  • Custom population of the method parameters

Interface ParameterProvider

This interface abstracts out the obtaining of request parameters. The default implementation is normally sufficient.

Interface ViewRenderer

The implementation is dependent on the underlying view engine in the particular technology (e.g. JSP, GSP, WebForms, Razor etc.)

  • implements lookup of the main and partial views for the specified form
  • renders resolved views to strings, applying the specified model object