Class DefaultEntityViewFactory
java.lang.Object
com.foreach.across.core.support.AttributeSupport
com.foreach.across.modules.entity.views.DefaultEntityViewFactory
- All Implemented Interfaces:
com.foreach.across.core.support.ReadableAttributes,com.foreach.across.core.support.WritableAttributes,DispatchingEntityViewFactory,EntityViewFactory,org.springframework.core.AttributeAccessor
public class DefaultEntityViewFactory
extends com.foreach.across.core.support.AttributeSupport
implements DispatchingEntityViewFactory
Base implementation for a
EntityViewFactory that supports ViewElement rendering,
and dispatches its logic to EntityViewProcessor instances that have more fine-grained hooks for interacting with the view rendering.
Supports a TransactionalEntityViewProcessorRegistry. All EntityViewProcessor.doControl(EntityViewRequest, EntityView, EntityViewCommand)
calls will be dispatched in a single transaction if they occur with a state altering HttpMethod like HttpMethod.POST.- Since:
- 2.0.0
- Author:
- Arne Vandamme
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidauthorizeRequest(EntityViewRequest entityViewRequest) Verify theEntityViewRequestis valid for this factory.createView(EntityViewRequest entityViewRequest) Create theEntityViewfor the given request.protected com.foreach.across.modules.web.ui.ViewElementBuilderContextcreateViewElementBuilderContext(EntityViewRequest entityViewRequest) Create a customViewElementBuilderContextfor the view request.voidinitializeCommandObject(EntityViewRequest entityViewRequest, EntityViewCommand command, org.springframework.web.bind.WebDataBinder dataBinder) Initialize theEntityViewCommandfor the given request.voidprepareEntityViewContext(ConfigurableEntityViewContext entityViewContext) Apply possible factory modifications to theConfigurableEntityViewContext.voidsetProcessorRegistry(TransactionalEntityViewProcessorRegistry processorRegistry) protected booleanshouldDispatchInTransaction(EntityViewRequest entityViewRequest) Should theEntityViewProcessor.doControl(EntityViewRequest, EntityView, EntityViewCommand)be executed in a wrapping transaction?Methods inherited from class com.foreach.across.core.support.AttributeSupport
attributeMap, attributeNames, getAttribute, getAttribute, getAttribute, hasAttribute, hasAttribute, removeAttribute, removeAttribute, setAttribute, setAttribute, setAttributesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.AttributeAccessor
computeAttributeMethods inherited from interface com.foreach.across.core.support.ReadableAttributes
attributeMap, attributeNames, getAttribute, getAttribute, getAttribute, hasAttribute, hasAttribute
-
Field Details
-
ATTRIBUTE_CONTAINER_BUILDER
- See Also:
-
ATTRIBUTE_CONTAINER_ELEMENT
- See Also:
-
-
Constructor Details
-
DefaultEntityViewFactory
public DefaultEntityViewFactory()
-
-
Method Details
-
prepareEntityViewContext
Description copied from interface:EntityViewFactoryApply possible factory modifications to theConfigurableEntityViewContext. Call this method before creating anEntityViewRequestthat uses the context. This method is called first, beforeEntityViewFactory.authorizeRequest(EntityViewRequest)in the default view rendering.- Specified by:
prepareEntityViewContextin interfaceEntityViewFactory- Parameters:
entityViewContext- to modify
-
authorizeRequest
Description copied from interface:EntityViewFactoryVerify theEntityViewRequestis 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 afterEntityViewFactory.prepareEntityViewContext(ConfigurableEntityViewContext)but before initializing the command object.- Specified by:
authorizeRequestin interfaceEntityViewFactory- Parameters:
entityViewRequest- request to validate
-
initializeCommandObject
public void initializeCommandObject(EntityViewRequest entityViewRequest, EntityViewCommand command, org.springframework.web.bind.WebDataBinder dataBinder) Description copied from interface:EntityViewFactoryInitialize theEntityViewCommandfor the given request. Optionally configure theWebDataBinderthat will be used to bind the command object. Called afterEntityViewFactory.authorizeRequest(EntityViewRequest)but before data binding.- Specified by:
initializeCommandObjectin interfaceEntityViewFactory- Parameters:
entityViewRequest- requestcommand- objectdataBinder- to bind the web request to the command
-
createView
Description copied from interface:EntityViewFactoryCreate theEntityViewfor 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.- Specified by:
createViewin interfaceEntityViewFactory- Parameters:
entityViewRequest- request- Returns:
- view created
-
createViewElementBuilderContext
protected com.foreach.across.modules.web.ui.ViewElementBuilderContext createViewElementBuilderContext(EntityViewRequest entityViewRequest) Create a customViewElementBuilderContextfor the view request. -
shouldDispatchInTransaction
Should theEntityViewProcessor.doControl(EntityViewRequest, EntityView, EntityViewCommand)be executed in a wrapping transaction? By default this is the case for all state modifyingHttpMethods. Requires a transaction template to be set on theprocessorRegistryto be set as well before a transaction will be used.- Parameters:
entityViewRequest- to check- Returns:
- true if transaction should be used
-
getProcessorRegistry
- Specified by:
getProcessorRegistryin interfaceDispatchingEntityViewFactory- Returns:
- the configurable registry of view processors
-
setProcessorRegistry
-