PageRenderTime 5ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/spring-mvc/org/springframework/web/servlet/view/jangod/JangodView.java

http://jangod.googlecode.com/
Java | 53 lines | 31 code | 7 blank | 15 comment | 3 complexity | 4628d2dc346cbf3fef58fa8911941840 MD5 | raw file
 1/**********************************************************************
 2Copyright (c) 2010 Asfun Net.
 3
 4Licensed under the Apache License, Version 2.0 (the "License");
 5you may not use this file except in compliance with the License.
 6You may obtain a copy of the License at
 7
 8http://www.apache.org/licenses/LICENSE-2.0
 9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15**********************************************************************/
16package org.springframework.web.servlet.view.jangod;
17
18import java.io.File;
19import java.util.Map;
20
21import javax.servlet.http.HttpServletRequest;
22import javax.servlet.http.HttpServletResponse;
23
24import org.springframework.web.servlet.ThemeResolver;
25import org.springframework.web.servlet.support.RequestContextUtils;
26import org.springframework.web.servlet.view.AbstractTemplateView;
27
28public class JangodView extends AbstractTemplateView{
29	
30	protected JangodConfig jangodConfig;
31	
32	@SuppressWarnings("unchecked")
33	@Override
34	protected void renderMergedTemplateModel(Map model, HttpServletRequest req,
35			HttpServletResponse resp) throws Exception {
36		if ( ! jangodConfig.isUseTheme() ) {
37			jangodConfig.getEngine().process(getUrl(), model, resp.getWriter());
38			return;
39		} else {
40			ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(req);
41			String theme = themeResolver.resolveThemeName(req);
42			if ( logger.isDebugEnabled() ) {
43				logger.debug("Current theme is " + theme);
44			}
45			jangodConfig.getEngine().process( theme + File.separator + getUrl(),
46					model, resp.getWriter());
47		} 
48	}
49	
50	public void setJangodConfig(JangodConfig jangodConfig) {
51		this.jangodConfig = jangodConfig;
52	}
53}