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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEntityView(@NonNull org.springframework.ui.ModelMap model, @NonNull org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.ui.ModeladdAllAttributes(Collection<?> attributeValues) org.springframework.ui.ModeladdAllAttributes(Map<String, ?> attributes) org.springframework.ui.ModeladdAttribute(Object attributeValue) org.springframework.ui.ModeladdAttribute(String attributeName, Object attributeValue) asMap()protected booleanbooleancontainsAttribute(String attributeName) booleangetAttribute(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.ModelMapgetModel()org.springframework.web.servlet.mvc.support.RedirectAttributes<V> org.springframework.http.ResponseEntity<V>Get the response entity that will be used as view.inthashCode()booleanbooleanbooleanorg.springframework.ui.ModelmergeAttributes(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.voidsetCustomView(Object customView) voidsetRedirectUrl(String redirectUrl) Set the redirect url, if the redirect url is notnull, this will also disable rendering.voidsetResponseEntity(org.springframework.http.ResponseEntity<?> responseEntity) Set aResponseEntitythat should be used for the view..voidsetShouldRender(boolean shouldRender) voidsetTemplate(String template) booleantoString()
-
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:
getAttributein 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 aResponseEntitythat 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:
nullif not a response entity
-
isRedirect
public boolean isRedirect()- Returns:
trueifredirectUrlis set
-
isResponseEntity
public boolean isResponseEntity()- Returns:
trueif the view returns aResponseEntity
-
isCustomView
public boolean isCustomView()- Returns:
trueif the view is neither a redirect, nor a view name; this method will also returntrueif the view is a response entity
-
shouldRender
public boolean shouldRender()- Returns:
trueif the view renders visual output
-
addAttribute
- Specified by:
addAttributein interfaceorg.springframework.ui.Model
-
addAttribute
- Specified by:
addAttributein interfaceorg.springframework.ui.Model
-
addAllAttributes
- Specified by:
addAllAttributesin interfaceorg.springframework.ui.Model
-
addAllAttributes
- Specified by:
addAllAttributesin interfaceorg.springframework.ui.Model
-
mergeAttributes
- Specified by:
mergeAttributesin interfaceorg.springframework.ui.Model
-
containsAttribute
- Specified by:
containsAttributein interfaceorg.springframework.ui.Model
-
asMap
- Specified by:
asMapin 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()
-