KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > riotfamily > components > render > PreviewModeRenderStrategy


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1
3  * The contents of this file are subject to the Mozilla Public License Version
4  * 1.1 (the "License"); you may not use this file except in compliance with
5  * the License. You may obtain a copy of the License at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * 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.render;
25
26 import java.io.IOException JavaDoc;
27 import java.util.List JavaDoc;
28
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30 import javax.servlet.http.HttpServletResponse JavaDoc;
31
32 import org.riotfamily.components.ComponentList;
33 import org.riotfamily.components.ComponentRepository;
34 import org.riotfamily.components.ComponentVersion;
35 import org.riotfamily.components.VersionContainer;
36 import org.riotfamily.components.config.ComponentListConfiguration;
37 import org.riotfamily.components.dao.ComponentDao;
38
39 public class PreviewModeRenderStrategy extends AbstractRenderStrategy {
40
41     public PreviewModeRenderStrategy(ComponentDao dao,
42             ComponentRepository repository, ComponentListConfiguration config,
43             HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
44             throws IOException JavaDoc {
45         
46         super(dao, repository, config, request, response);
47     }
48     
49     /**
50      * Overrides the default implementation to return the preview components
51      * in case the list is marked as dirty.
52      */

53     protected List JavaDoc getComponentsToRender(ComponentList list) {
54         if (list.isDirty()) {
55             log.debug("List is dirty - rendering preview containers");
56             return list.getPreviewContainers();
57         }
58         else {
59             log.debug("List is *NOT* dirty - rendering live containers");
60             return list.getLiveContainers();
61         }
62     }
63     
64     /**
65      * Overrides the default implementation to return the component's latest
66      * version.
67      */

68     protected ComponentVersion getVersionToRender(VersionContainer container) {
69         return container.getLatestVersion();
70     }
71     
72 }
73
Popular Tags