01: /* ***** BEGIN LICENSE BLOCK *****
02: * Version: MPL 1.1
03: * The contents of this file are subject to the Mozilla Public License Version
04: * 1.1 (the "License"); you may not use this file except in compliance with
05: * the License. You may obtain a copy of the License at
06: * http://www.mozilla.org/MPL/
07: *
08: * Software distributed under the License is distributed on an "AS IS" basis,
09: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10: * for the specific language governing rights and limitations under the
11: * License.
12: *
13: * The Original Code is Riot.
14: *
15: * The Initial Developer of the Original Code is
16: * Neteye GmbH.
17: * Portions created by the Initial Developer are Copyright (C) 2006
18: * the Initial Developer. All Rights Reserved.
19: *
20: * Contributor(s):
21: * Felix Gnass [fgnass at neteye dot de]
22: *
23: * ***** END LICENSE BLOCK ***** */
24: package org.riotfamily.components.controller.render;
25:
26: import java.util.Locale;
27:
28: import javax.servlet.http.HttpServletRequest;
29: import javax.servlet.http.HttpServletResponse;
30:
31: import org.riotfamily.common.markup.Html;
32: import org.riotfamily.common.markup.TagWriter;
33: import org.riotfamily.components.EditModeUtils;
34: import org.riotfamily.components.config.ComponentListConfiguration;
35: import org.riotfamily.components.config.ComponentRepository;
36: import org.riotfamily.components.dao.ComponentDao;
37: import org.riotfamily.components.model.ComponentList;
38: import org.riotfamily.components.model.Location;
39: import org.springframework.context.MessageSource;
40: import org.springframework.web.servlet.support.RequestContextUtils;
41:
42: public class InheritingRenderStrategy extends PreviewModeRenderStrategy {
43:
44: private MessageSource messageSource;
45:
46: public InheritingRenderStrategy(ComponentDao dao,
47: ComponentRepository repository,
48: ComponentListConfiguration config) {
49:
50: super (dao, repository, config);
51: this .messageSource = repository.getMessageSource();
52: }
53:
54: protected void renderComponentList(ComponentList list,
55: HttpServletRequest request, HttpServletResponse response)
56: throws Exception {
57:
58: boolean live = EditModeUtils.isEditMode(request);
59: EditModeUtils.setLiveMode(request, true);
60: super .renderComponentList(list, request, response);
61: EditModeUtils.setLiveMode(request, live);
62: }
63:
64: protected void onListNotFound(Location location,
65: HttpServletRequest request, HttpServletResponse response)
66: throws Exception {
67:
68: Locale locale = RequestContextUtils.getLocale(request);
69: TagWriter tag = new TagWriter(response.getWriter());
70: tag.start(Html.DIV).attribute(Html.COMMON_CLASS,
71: "riot-no-inheritance").body(
72: messageSource.getMessage(
73: "components.inheritance.noParentList", null,
74: "No parent list available", locale)).end();
75: }
76:
77: protected void onEmptyComponentList(HttpServletRequest request,
78: HttpServletResponse response) throws Exception {
79:
80: Locale locale = RequestContextUtils.getLocale(request);
81: TagWriter tag = new TagWriter(response.getWriter());
82: tag
83: .start(Html.DIV)
84: .attribute(Html.COMMON_CLASS, "riot-no-inheritance")
85: .body(
86: messageSource
87: .getMessage(
88: "components.inheritance.emptyParentList",
89: null,
90: "The parent list does not contain any components",
91: locale)).end();
92: }
93:
94: }
|