org.mixer2.spring.webmvc
Class AbstractMixer2XhtmlView

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.view.AbstractView
              extended by org.springframework.web.servlet.view.AbstractUrlBasedView
                  extended by org.mixer2.spring.webmvc.AbstractMixer2XhtmlView
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.View

public abstract class AbstractMixer2XhtmlView
extends org.springframework.web.servlet.view.AbstractUrlBasedView

Abstract class to create view class for Spring MVC.

use this class with Mixer2XhtmlViewResolver

implementation sample

 public class HelloWorldView extends AbstractMixer2XhtmlView {
 
    @Autowired
    private FooBar fooBar;
 
    @Override
    protected Html renderHtml(Html html, Map<String, Object> model, HttpServletRequest request,
          HttpServletResponse response) throws TagTypeUnmatchException {
        
        @SuppressWarnings("unchecked")
        String message = (String) model.get("helloMessage");
        Div div = html.getById("message", Div.class);
        div.unsetContent();
        div.getContent().add(message);
      
        return html;
 }
 

You NEED NOT to add "@Component" annotation because Mixer2XhtmlViewResolver instantiate the view class through AutowireCapableBeanFactory.

Author:
kazuki43zoo, nabedge
See Also:
helloworld, spring mvc sample, spring mvc sample code

Field Summary
protected  String docType
           
protected  Mixer2Engine mixer2Engine
           
protected  org.springframework.core.io.ResourceLoader resourceLoader
           
 
Fields inherited from class org.springframework.web.servlet.view.AbstractView
DEFAULT_CONTENT_TYPE
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.web.servlet.View
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
 
Constructor Summary
AbstractMixer2XhtmlView()
           
 
Method Summary
 void afterPropertiesSet()
           
static AbstractMixer2XhtmlView createDefaultView()
           
 String getDocType()
           
 Mixer2Engine getMixer2Engine()
           
protected  String modifyHtmlStringHook(String htmlString)
          Override this method if you modify html as string right before http response.
protected abstract  Html renderHtml(Html html, Map<String,Object> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Need implementation.
protected  void renderMergedOutputModel(Map<String,Object> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void responseHtml(Html renderedHtml, javax.servlet.http.HttpServletResponse response)
           
 void setDocType(String docType)
           
 void setMixer2Engine(Mixer2Engine mixer2Engine)
           
 org.springframework.core.io.ResourceLoader setResourceLoader()
           
 void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
           
 
Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView
checkResource, getUrl, isUrlRequired, setUrl, toString
 
Methods inherited from class org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponse
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resourceLoader

protected org.springframework.core.io.ResourceLoader resourceLoader

docType

protected String docType

mixer2Engine

protected Mixer2Engine mixer2Engine
Constructor Detail

AbstractMixer2XhtmlView

public AbstractMixer2XhtmlView()
Method Detail

createDefaultView

public static final AbstractMixer2XhtmlView createDefaultView()

setDocType

public void setDocType(String docType)

getDocType

public String getDocType()

setMixer2Engine

public void setMixer2Engine(Mixer2Engine mixer2Engine)

getMixer2Engine

public Mixer2Engine getMixer2Engine()

setResourceLoader

public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)

setResourceLoader

public org.springframework.core.io.ResourceLoader setResourceLoader()

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class org.springframework.web.servlet.view.AbstractUrlBasedView
Throws:
Exception

renderMergedOutputModel

protected void renderMergedOutputModel(Map<String,Object> model,
                                       javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
                                throws Exception
Specified by:
renderMergedOutputModel in class org.springframework.web.servlet.view.AbstractView
Throws:
Exception

responseHtml

protected void responseHtml(Html renderedHtml,
                            javax.servlet.http.HttpServletResponse response)
                     throws IOException
Throws:
IOException

modifyHtmlStringHook

protected String modifyHtmlStringHook(String htmlString)
Override this method if you modify html as string right before http response.

Parameters:
htmlString - String object that is saveToString()ed by mixer2Engine.
Returns:

renderHtml

protected abstract Html renderHtml(Html html,
                                   Map<String,Object> model,
                                   javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response)
                            throws Exception
Need implementation.

Parameters:
html - Html instance of xhtml template that is loaded by Mixer2XhtmlViewResolver.
model -
request -
response -
Returns:
Throws:
Exception - Mixer2XhtmlViewResolver


Copyright © 2016 Project Mixer2. All rights reserved.