Interface EntityViewFactory

All Superinterfaces:
com.foreach.across.core.support.ReadableAttributes
All Known Subinterfaces:
DispatchingEntityViewFactory
All Known Implementing Classes:
DefaultEntityViewFactory

public interface EntityViewFactory extends com.foreach.across.core.support.ReadableAttributes
Central API for building custom entity views using the generic controllers. For correct assembly of a view, the methods of the EntityViewFactory are expected to be called in specific order:
  1. prepareEntityViewContext(ConfigurableEntityViewContext)
  2. authorizeRequest(EntityViewRequest)
  3. initializeCommandObject(EntityViewRequest, EntityViewCommand, WebDataBinder)
  4. createView(EntityViewRequest)
Since:
2.0.0
Author:
Arne Vandamme
See Also:
  • Method Details

    • prepareEntityViewContext

      void prepareEntityViewContext(ConfigurableEntityViewContext entityViewContext)
      Apply possible factory modifications to the ConfigurableEntityViewContext. Call this method before creating an EntityViewRequest that uses the context.

      This method is called first, before authorizeRequest(EntityViewRequest) in the default view rendering.

      Parameters:
      entityViewContext - to modify
    • authorizeRequest

      void authorizeRequest(EntityViewRequest entityViewRequest)
      Verify the EntityViewRequest is valid for this factory. This usually means things like performing security checks and checking all individual properties are valid.

      Any invalid requests are expected to throw the most relevant exceptions.

      Called after prepareEntityViewContext(ConfigurableEntityViewContext) but before initializing the command object.

      Parameters:
      entityViewRequest - request to validate
    • initializeCommandObject

      void initializeCommandObject(EntityViewRequest entityViewRequest, EntityViewCommand command, org.springframework.web.bind.WebDataBinder dataBinder)
      Initialize the EntityViewCommand for the given request. Optionally configure the WebDataBinder that will be used to bind the command object.

      Called after authorizeRequest(EntityViewRequest) but before data binding.

      Parameters:
      entityViewRequest - request
      command - object
      dataBinder - to bind the web request to the command
    • createView

      EntityView createView(EntityViewRequest entityViewRequest)
      Create the EntityView for the given request. This will execute the controller logic and will build all view elements required.

      This method requires a valid request and a fully initialized/bound command object.

      Parameters:
      entityViewRequest - request
      Returns:
      view created