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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
authorizeRequest
(EntityViewRequest entityViewRequest) Verify theEntityViewRequest
is valid for this factory.createView
(EntityViewRequest entityViewRequest) Create theEntityView
for the given request.protected com.foreach.across.modules.web.ui.ViewElementBuilderContext
createViewElementBuilderContext
(EntityViewRequest entityViewRequest) Create a customViewElementBuilderContext
for the view request.void
initializeCommandObject
(EntityViewRequest entityViewRequest, EntityViewCommand command, org.springframework.web.bind.WebDataBinder dataBinder) Initialize theEntityViewCommand
for the given request.void
prepareEntityViewContext
(ConfigurableEntityViewContext entityViewContext) Apply possible factory modifications to theConfigurableEntityViewContext
.void
setProcessorRegistry
(TransactionalEntityViewProcessorRegistry processorRegistry) protected boolean
shouldDispatchInTransaction
(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, setAttributes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.AttributeAccessor
computeAttribute
Methods 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:EntityViewFactory
Apply possible factory modifications to theConfigurableEntityViewContext
. Call this method before creating anEntityViewRequest
that uses the context. This method is called first, beforeEntityViewFactory.authorizeRequest(EntityViewRequest)
in the default view rendering.- Specified by:
prepareEntityViewContext
in interfaceEntityViewFactory
- Parameters:
entityViewContext
- to modify
-
authorizeRequest
Description copied from interface:EntityViewFactory
Verify theEntityViewRequest
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 afterEntityViewFactory.prepareEntityViewContext(ConfigurableEntityViewContext)
but before initializing the command object.- Specified by:
authorizeRequest
in interfaceEntityViewFactory
- Parameters:
entityViewRequest
- request to validate
-
initializeCommandObject
public void initializeCommandObject(EntityViewRequest entityViewRequest, EntityViewCommand command, org.springframework.web.bind.WebDataBinder dataBinder) Description copied from interface:EntityViewFactory
Initialize theEntityViewCommand
for the given request. Optionally configure theWebDataBinder
that will be used to bind the command object. Called afterEntityViewFactory.authorizeRequest(EntityViewRequest)
but before data binding.- Specified by:
initializeCommandObject
in interfaceEntityViewFactory
- Parameters:
entityViewRequest
- requestcommand
- objectdataBinder
- to bind the web request to the command
-
createView
Description copied from interface:EntityViewFactory
Create theEntityView
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.- Specified by:
createView
in interfaceEntityViewFactory
- Parameters:
entityViewRequest
- request- Returns:
- view created
-
createViewElementBuilderContext
protected com.foreach.across.modules.web.ui.ViewElementBuilderContext createViewElementBuilderContext(EntityViewRequest entityViewRequest) Create a customViewElementBuilderContext
for 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 modifyingHttpMethod
s. Requires a transaction template to be set on theprocessorRegistry
to be set as well before a transaction will be used.- Parameters:
entityViewRequest
- to check- Returns:
- true if transaction should be used
-
getProcessorRegistry
- Specified by:
getProcessorRegistry
in interfaceDispatchingEntityViewFactory
- Returns:
- the configurable registry of view processors
-
setProcessorRegistry
-