Class EntityView
java.lang.Object
com.foreach.across.modules.entity.views.EntityView
- All Implemented Interfaces:
org.springframework.ui.Model
Represents both the view and the backing model for a generated entity output page.
The
Model
implementation is extended with some type-safe methods for passing data
between EntityViewProcessor
instances if so used.
Supports different types of resulting view:
getRedirectUrl()
for a redirectgetTemplate()
for a view namegetResponseEntity()
for a response entitygetCustomView()
for a customView
- Author:
- Arne Vandamme
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionEntityView
(@NonNull org.springframework.ui.ModelMap model, @NonNull org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.ui.Model
addAllAttributes
(Collection<?> attributeValues) org.springframework.ui.Model
addAllAttributes
(Map<String, ?> attributes) org.springframework.ui.Model
addAttribute
(Object attributeValue) org.springframework.ui.Model
addAttribute
(String attributeName, Object attributeValue) asMap()
protected boolean
boolean
containsAttribute
(String attributeName) boolean
getAttribute
(String attributeName) <V,
Y extends V>
YgetAttribute
(String attributeName, Class<V> expectedType) Get an attribute from the model and coerce it to the expected type.org.springframework.ui.ModelMap
getModel()
org.springframework.web.servlet.mvc.support.RedirectAttributes
<V> org.springframework.http.ResponseEntity<V>
Get the response entity that will be used as view.int
hashCode()
boolean
boolean
boolean
org.springframework.ui.Model
mergeAttributes
(Map<String, ?> attributes) removeAttribute
(String attributeName) <V,
Y extends V>
YremoveAttribute
(String attributeName, Class<V> expectedType) Remove the attribute with the given name from the model and coerce the attribute value returned to the expected type.void
setCustomView
(Object customView) void
setRedirectUrl
(String redirectUrl) Set the redirect url, if the redirect url is notnull
, this will also disable rendering.void
setResponseEntity
(org.springframework.http.ResponseEntity<?> responseEntity) Set aResponseEntity
that should be used for the view..void
setShouldRender
(boolean shouldRender) void
setTemplate
(String template) boolean
toString()
-
Field Details
-
CREATE_VIEW_NAME
- See Also:
-
UPDATE_VIEW_NAME
- See Also:
-
DELETE_VIEW_NAME
- See Also:
-
LIST_VIEW_NAME
- See Also:
-
GENERIC_VIEW_NAME
- See Also:
-
SUMMARY_VIEW_NAME
- See Also:
-
DETAIL_VIEW_NAME
- See Also:
-
-
Constructor Details
-
EntityView
public EntityView(@NonNull @NonNull org.springframework.ui.ModelMap model, @NonNull @NonNull org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
-
-
Method Details
-
getTemplate
-
setTemplate
-
getAttribute
Get an attribute from the model and coerce it to the expected type.- Type Parameters:
V
- type the attribute value should haveY
- return type specification for generics- Parameters:
attributeName
- name of the attributeexpectedType
- type the attribute value should have- Returns:
- value or
null
-
getAttribute
- Specified by:
getAttribute
in interfaceorg.springframework.ui.Model
-
removeAttribute
Remove the attribute with the given name from the model and coerce the attribute value returned to the expected type. Note that the type coercing will only occur after the attribute has been removed!- Type Parameters:
V
- type the attribute value should haveY
- return type specification for generics- Parameters:
attributeName
- name of the attributeexpectedType
- type the attribute value should have- Returns:
- value or
null
-
removeAttribute
-
setRedirectUrl
Set the redirect url, if the redirect url is notnull
, this will also disable rendering.- Parameters:
redirectUrl
- to use
-
setResponseEntity
public void setResponseEntity(org.springframework.http.ResponseEntity<?> responseEntity) Set aResponseEntity
that should be used for the view.. Short-hand forsetCustomView(Object)
.- Parameters:
responseEntity
- to return
-
getResponseEntity
public <V> org.springframework.http.ResponseEntity<V> getResponseEntity()Get the response entity that will be used as view.- Returns:
null
if not a response entity
-
isRedirect
public boolean isRedirect()- Returns:
true
ifredirectUrl
is set
-
isResponseEntity
public boolean isResponseEntity()- Returns:
true
if the view returns aResponseEntity
-
isCustomView
public boolean isCustomView()- Returns:
true
if the view is neither a redirect, nor a view name; this method will also returntrue
if the view is a response entity
-
shouldRender
public boolean shouldRender()- Returns:
true
if the view renders visual output
-
addAttribute
- Specified by:
addAttribute
in interfaceorg.springframework.ui.Model
-
addAttribute
- Specified by:
addAttribute
in interfaceorg.springframework.ui.Model
-
addAllAttributes
- Specified by:
addAllAttributes
in interfaceorg.springframework.ui.Model
-
addAllAttributes
- Specified by:
addAllAttributes
in interfaceorg.springframework.ui.Model
-
mergeAttributes
- Specified by:
mergeAttributes
in interfaceorg.springframework.ui.Model
-
containsAttribute
- Specified by:
containsAttribute
in interfaceorg.springframework.ui.Model
-
asMap
- Specified by:
asMap
in interfaceorg.springframework.ui.Model
-
toString
-
getModel
public org.springframework.ui.ModelMap getModel() -
getRedirectAttributes
public org.springframework.web.servlet.mvc.support.RedirectAttributes getRedirectAttributes() -
getRedirectUrl
-
getCustomView
-
setCustomView
-
setShouldRender
public void setShouldRender(boolean shouldRender) -
equals
-
canEqual
-
hashCode
public int hashCode()
-