Package org.shredzone.commons.view.impl
Class ViewServiceImpl
- java.lang.Object
- 
- org.shredzone.commons.view.impl.ViewServiceImpl
 
- 
- All Implemented Interfaces:
- ViewService
 
 @Component @ParametersAreNonnullByDefault public class ViewServiceImpl extends Object implements ViewService Default implementation ofViewService.- Author:
- Richard "Shred" Körber
 
- 
- 
Constructor SummaryConstructors Constructor Description ViewServiceImpl()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description StringbuildPath(PathContext data, String view, PathType type)Builds an URL path to a view that is able to render the provided data.protected org.springframework.expression.EvaluationContextcreateEvaluationContext(PathContext context)Creates anEvaluationContextto be used for evaluation in this view service.StringgetTemplatePath(String template)Gets the path to a template resource with the given name.ViewContextgetViewContext()Gets theViewContextof the current request.voidhandleRequest(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Handles a HTTP request.StringinvokeView(String path)Analyzes the given path, and invokes a view handler for processing the request.protected voidsetup()
 
- 
- 
- 
Constructor Detail- 
ViewServiceImplpublic ViewServiceImpl() 
 
- 
 - 
Method Detail- 
setup@PostConstruct protected void setup() 
 - 
handleRequestpublic void handleRequest(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws ViewException Description copied from interface:ViewServiceHandles a HTTP request. This method is usually invoked from a servlet.- Specified by:
- handleRequestin interface- ViewService
- Parameters:
- req-- HttpServletRequest
- resp-- HttpServletResponse
- Throws:
- ViewException- if the request could not be handled
 
 - 
getViewContextpublic ViewContext getViewContext() Description copied from interface:ViewServiceGets theViewContextof the current request.- Specified by:
- getViewContextin interface- ViewService
- Returns:
- ViewContext
 
 - 
invokeViewpublic String invokeView(String path) throws ViewException Description copied from interface:ViewServiceAnalyzes the given path, and invokes a view handler for processing the request.- Specified by:
- invokeViewin interface- ViewService
- Parameters:
- path- the requested path
- Returns:
- String returned by the view handler, usually the name of a JSP template to
         forward the request to. May be nullif the handler already took care for the response itself.
- Throws:
- PageNotFoundException- if no view was matching the given path
- ViewException- if the view handler could not be invoked or could not handle the request
 
 - 
buildPathpublic String buildPath(PathContext data, String view, PathType type) Description copied from interface:ViewServiceBuilds an URL path to a view that is able to render the provided data.- Specified by:
- buildPathin interface- ViewService
- Parameters:
- data-- PathContextcontaining all the data for the path
- view- name of the view to build a path to
- type-- PathTypeto be built
- Returns:
- the URL path that was built, or nullif no view was found to be able to render the provided data
 
 - 
getTemplatePathpublic String getTemplatePath(String template) Description copied from interface:ViewServiceGets the path to a template resource with the given name. It is not checked if the template actually exists.- Specified by:
- getTemplatePathin interface- ViewService
- Parameters:
- template- Template name
- Returns:
- Template path
 
 - 
createEvaluationContext@Nonnull protected org.springframework.expression.EvaluationContext createEvaluationContext(PathContext context) Creates anEvaluationContextto be used for evaluation in this view service. The default implementation creates aViewPathEvaluationContext.- Parameters:
- context-- PathContextto be used as root object
- Returns:
- EvaluationContextto be used for evaluation
 
 
- 
 
-