/** * Check that the Velocity template used for this view exists and is valid. * <p>Can be overridden to customize the behavior, for example in case of * multiple templates to be rendered into a single view. */ @Override public boolean checkResource(Locale locale) throws Exception { try { // Check that we can get the template, even if we might subsequently get it again. this.template = getTemplate(getUrl()); return true; } catch (ResourceNotFoundException ex) { if (logger.isDebugEnabled()) { logger.debug("No Velocity view found for URL: " + getUrl()); } return false; } catch (Exception ex) { throw new NestedIOException( "Could not load Velocity template for URL [" + getUrl() + "]", ex); } }
/** * Check that the Velocity template used for this view exists and is valid. * <p>Can be overridden to customize the behavior, for example in case of * multiple templates to be rendered into a single view. */ @Override public boolean checkResource(Locale locale) throws Exception { try { // Check that we can get the template, even if we might subsequently get it again. this.template = getTemplate(getUrl()); return true; } catch (ResourceNotFoundException ex) { if (logger.isDebugEnabled()) { logger.debug("No Velocity view found for URL: " + getUrl()); } return false; } catch (Exception ex) { throw new NestedIOException( "Could not load Velocity template for URL [" + getUrl() + "]", ex); } }
/** * Check that the Velocity template used for this view exists and is valid. * <p>Can be overridden to customize the behavior, for example in case of * multiple templates to be rendered into a single view. */ @Override public boolean checkResource(Locale locale) throws Exception { try { // Check that we can get the template, even if we might subsequently get it again. this.template = getTemplate(getUrl()); return true; } catch (ResourceNotFoundException ex) { if (logger.isDebugEnabled()) { logger.debug("No Velocity view found for URL: " + getUrl()); } return false; } catch (Exception ex) { throw new NestedIOException( "Could not load Velocity template for URL [" + getUrl() + "]", ex); } }
/** * Render the Velocity view to the given response, using the given Velocity * context which contains the complete template model to use. * <p>The default implementation renders the template specified by the "url" * bean property, retrieved via {@code getTemplate}. It delegates to the * {@code mergeTemplate} method to merge the template instance with the * given Velocity context. * <p>Can be overridden to customize the behavior, for example to render * multiple templates into a single view. * @param context the Velocity context to use for rendering * @param response servlet response (use this to get the OutputStream or Writer) * @throws Exception if thrown by Velocity * @see #setUrl * @see #getTemplate() * @see #mergeTemplate */ protected void doRender(Context context, HttpServletResponse response) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Rendering Velocity template [" + getUrl() + "] in VelocityView '" + getBeanName() + "'"); } mergeTemplate(getTemplate(), context, response); }
/** * Retrieve the Velocity template to be rendered by this view. * <p>By default, the template specified by the "url" bean property will be * retrieved: either returning a cached template instance or loading a fresh * instance (according to the "cacheTemplate" bean property) * @return the Velocity template to render * @throws Exception if thrown by Velocity * @see #setUrl * @see #setCacheTemplate * @see #getTemplate(String) */ protected Template getTemplate() throws Exception { // We already hold a reference to the template, but we might want to load it // if not caching. Velocity itself caches templates, so our ability to // cache templates in this class is a minor optimization only. if (isCacheTemplate() && this.template != null) { return this.template; } else { return getTemplate(getUrl()); } }
/** * Render the Velocity view to the given response, using the given Velocity * context which contains the complete template model to use. * <p>The default implementation renders the template specified by the "url" * bean property, retrieved via {@code getTemplate}. It delegates to the * {@code mergeTemplate} method to merge the template instance with the * given Velocity context. * <p>Can be overridden to customize the behavior, for example to render * multiple templates into a single view. * @param context the Velocity context to use for rendering * @param response servlet response (use this to get the OutputStream or Writer) * @throws Exception if thrown by Velocity * @see #setUrl * @see #getTemplate() * @see #mergeTemplate */ protected void doRender(Context context, HttpServletResponse response) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Rendering Velocity template [" + getUrl() + "] in VelocityView '" + getBeanName() + "'"); } mergeTemplate(getTemplate(), context, response); }
/** * Retrieve the Velocity template to be rendered by this view. * <p>By default, the template specified by the "url" bean property will be * retrieved: either returning a cached template instance or loading a fresh * instance (according to the "cacheTemplate" bean property) * @return the Velocity template to render * @throws Exception if thrown by Velocity * @see #setUrl * @see #setCacheTemplate * @see #getTemplate(String) */ protected Template getTemplate() throws Exception { // We already hold a reference to the template, but we might want to load it // if not caching. Velocity itself caches templates, so our ability to // cache templates in this class is a minor optimization only. if (isCacheTemplate() && this.template != null) { return this.template; } else { return getTemplate(getUrl()); } }
/** * Render the Velocity view to the given response, using the given Velocity * context which contains the complete template model to use. * <p>The default implementation renders the template specified by the "url" * bean property, retrieved via {@code getTemplate}. It delegates to the * {@code mergeTemplate} method to merge the template instance with the * given Velocity context. * <p>Can be overridden to customize the behavior, for example to render * multiple templates into a single view. * @param context the Velocity context to use for rendering * @param response servlet response (use this to get the OutputStream or Writer) * @throws Exception if thrown by Velocity * @see #setUrl * @see #getTemplate() * @see #mergeTemplate */ protected void doRender(Context context, HttpServletResponse response) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Rendering Velocity template [" + getUrl() + "] in VelocityView '" + getBeanName() + "'"); } mergeTemplate(getTemplate(), context, response); }
/** * Retrieve the Velocity template to be rendered by this view. * <p>By default, the template specified by the "url" bean property will be * retrieved: either returning a cached template instance or loading a fresh * instance (according to the "cacheTemplate" bean property) * @return the Velocity template to render * @throws Exception if thrown by Velocity * @see #setUrl * @see #setCacheTemplate * @see #getTemplate(String) */ protected Template getTemplate() throws Exception { // We already hold a reference to the template, but we might want to load it // if not caching. Velocity itself caches templates, so our ability to // cache templates in this class is a minor optimization only. if (isCacheTemplate() && this.template != null) { return this.template; } else { return getTemplate(getUrl()); } }