Package org.strecks.navigate.spring

Source Code of org.strecks.navigate.spring.SpringRenderingViewAdapter

/*
* Copyright 2005-2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package org.strecks.navigate.spring;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.View;
import org.strecks.context.ActionContext;
import org.strecks.exceptions.ApplicationRuntimeException;
import org.strecks.util.Assert;
import org.strecks.view.RenderingViewAdapter;

/**
* Implementation of <code>RenderingViewAdapter</code> which renders a Spring <code>View</code>
* using the method
* <code>void render(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception;</code>
* @author Phil Zoio
*/
public class SpringRenderingViewAdapter implements RenderingViewAdapter
{

  private View view;

  private Map model;

  public SpringRenderingViewAdapter(View view, Map model)
  {
    super();
    Assert.notNull(view);
    this.model = model;
    this.view = view;
  }

  public void render(ActionContext actionContext)
  {
    try
    {
      HttpServletRequest request = actionContext.getRequest();
      HttpServletResponse response = actionContext.getResponse();
      view.render(model, request, response);
    }
    catch (Exception e)
    {
      throw new ApplicationRuntimeException("Exception thrown during rendering of view "
          + view.getClass().getName(), e);
    }
  }

  Map getModel()
  {
    return model;
  }

  View getView()
  {
    return view;
  }

}
TOP

Related Classes of org.strecks.navigate.spring.SpringRenderingViewAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.