Package org.shredzone.commons.view.impl
Class ViewContextImpl
- java.lang.Object
-
- org.shredzone.commons.view.impl.ViewContextImpl
-
- All Implemented Interfaces:
ViewContext
@Component("viewContext") @Scope("request") @ParametersAreNonnullByDefault public class ViewContextImpl extends Object implements ViewContextDefault implementation ofViewContext.This bean is request scoped.
- Author:
- Richard "Shred" Körber
-
-
Constructor Summary
Constructors Constructor Description ViewContextImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetParameter(String name)Gets a parameter from the request URL's search part.Map<String,String>getPathParts()Gets a map of all path parts.StringgetQualifier()Gets a View qualifier.StringgetRequestServerUrl()Returns the server URL the request was sent to.StringgetRequestServletName()Returns the name of the servlet that processed the request.<T> TgetValueOfType(Class<T> type)Gets a value that matches the requested type.<T> voidputTypedArgument(Class<T> type, T value)Adds a typed argument to this context.voidsetPathParts(Map<String,String> pathParts)Sets the path parts from resolving the view URL.voidsetQualifier(String qualifier)Sets a View qualifier.protected voidsetup()Sets up this bean's contents.
-
-
-
Constructor Detail
-
ViewContextImpl
public ViewContextImpl()
-
-
Method Detail
-
setup
@PostConstruct protected void setup()
Sets up this bean's contents.
-
getRequestServerUrl
public String getRequestServerUrl()
Description copied from interface:ViewContextReturns the server URL the request was sent to. The URL contains the protocol, the domain and (optionally) the port.- Specified by:
getRequestServerUrlin interfaceViewContext- Returns:
- the server URL (e.g. "http://www.shredzone.de")
-
getRequestServletName
public String getRequestServletName()
Description copied from interface:ViewContextReturns the name of the servlet that processed the request.- Specified by:
getRequestServletNamein interfaceViewContext- Returns:
- the servlet name (e.g. "/cilla")
-
getParameter
public String getParameter(String name)
Description copied from interface:ViewContextGets a parameter from the request URL's search part.- Specified by:
getParameterin interfaceViewContext- Parameters:
name- the parameter name- Returns:
- parameter value, or
nullif there is no such parameter
-
putTypedArgument
public <T> void putTypedArgument(Class<T> type, T value)
Description copied from interface:ViewContextAdds a typed argument to this context. Typed arguments are available to the view handler's parameter list.- Specified by:
putTypedArgumentin interfaceViewContext- Parameters:
type- Type this argument is to be registered with (may be the value's type or a supertype)value- the value to register, may benull
-
getValueOfType
public <T> T getValueOfType(Class<T> type) throws ViewContextException
Description copied from interface:ViewContextGets a value that matches the requested type.- Specified by:
getValueOfTypein interfaceViewContext- Type Parameters:
T- the requested type- Parameters:
type- type to get a value for- Returns:
- a value for that type, may be
nullif the type's value was set tonull. - Throws:
ViewContextException- if there was no data satisfying that type
-
setPathParts
public void setPathParts(Map<String,String> pathParts)
Description copied from interface:ViewContextSets the path parts from resolving the view URL. Should only be invoked from theViewService.- Specified by:
setPathPartsin interfaceViewContext- Parameters:
pathParts- Map of path parts
-
getPathParts
public Map<String,String> getPathParts()
Description copied from interface:ViewContextGets a map of all path parts. This map is immutable.- Specified by:
getPathPartsin interfaceViewContext- Returns:
- Map of path parts
-
setQualifier
public void setQualifier(String qualifier)
Description copied from interface:ViewContextSets a View qualifier.- Specified by:
setQualifierin interfaceViewContext- Parameters:
qualifier- qualifier to be used, ornullfor the standard qualifier
-
getQualifier
public String getQualifier()
Description copied from interface:ViewContextGets a View qualifier.- Specified by:
getQualifierin interfaceViewContext- Returns:
- qualifier to be used, or
nullfor the standard qualifier
-
-