Source Code Cross Referenced for EditModeRenderStrategy.java in  » Content-Management-System » riotfamily » org » riotfamily » components » controller » render » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » riotfamily » org.riotfamily.components.controller.render 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ***** BEGIN LICENSE BLOCK *****
002:         * Version: MPL 1.1
003:         * The contents of this file are subject to the Mozilla Public License Version
004:         * 1.1 (the "License"); you may not use this file except in compliance with
005:         * the License. You may obtain a copy of the License at
006:         * http://www.mozilla.org/MPL/
007:         *
008:         * Software distributed under the License is distributed on an "AS IS" basis,
009:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
010:         * for the specific language governing rights and limitations under the
011:         * License.
012:         *
013:         * The Original Code is Riot.
014:         *
015:         * The Initial Developer of the Original Code is
016:         * Neteye GmbH.
017:         * Portions created by the Initial Developer are Copyright (C) 2006
018:         * the Initial Developer. All Rights Reserved.
019:         *
020:         * Contributor(s):
021:         *   Felix Gnass [fgnass at neteye dot de]
022:         *
023:         * ***** END LICENSE BLOCK ***** */
024:        package org.riotfamily.components.controller.render;
025:
026:        import java.io.IOException;
027:        import java.util.ArrayList;
028:        import java.util.List;
029:
030:        import javax.servlet.http.HttpServletRequest;
031:        import javax.servlet.http.HttpServletResponse;
032:
033:        import org.apache.commons.logging.Log;
034:        import org.apache.commons.logging.LogFactory;
035:        import org.riotfamily.common.markup.DocumentWriter;
036:        import org.riotfamily.common.markup.Html;
037:        import org.riotfamily.common.markup.TagWriter;
038:        import org.riotfamily.common.web.util.ServletUtils;
039:        import org.riotfamily.components.config.ComponentListConfiguration;
040:        import org.riotfamily.components.config.ComponentRepository;
041:        import org.riotfamily.components.context.PageRequestUtils;
042:        import org.riotfamily.components.dao.ComponentDao;
043:        import org.riotfamily.components.model.ComponentList;
044:        import org.riotfamily.components.model.ComponentVersion;
045:        import org.riotfamily.components.model.Location;
046:        import org.riotfamily.components.model.VersionContainer;
047:
048:        public class EditModeRenderStrategy extends PreviewModeRenderStrategy {
049:
050:            private static final Log log = LogFactory
051:                    .getLog(EditModeRenderStrategy.class);
052:
053:            private RenderStrategy parentStrategy;
054:
055:            public EditModeRenderStrategy(ComponentDao dao,
056:                    ComponentRepository repository,
057:                    ComponentListConfiguration config) {
058:
059:                super (dao, repository, config);
060:                parentStrategy = new InheritingRenderStrategy(dao, repository,
061:                        config);
062:            }
063:
064:            /**
065:             * Overrides the default implementation to render a DIV tag around the
066:             * actual list. The DIV has attributes that are required for the
067:             * Riot toolbar JavaScript.
068:             */
069:            protected void renderComponentList(ComponentList list,
070:                    HttpServletRequest request, HttpServletResponse response)
071:                    throws Exception {
072:
073:                DocumentWriter wrapper = new DocumentWriter(response
074:                        .getWriter());
075:
076:                boolean renderOuterDiv = PageRequestUtils
077:                        .createAndStoreContext(request,
078:                                list.getId().toString(), 120000);
079:
080:                if (renderOuterDiv) {
081:                    wrapper.start(Html.DIV).attribute(Html.COMMON_CLASS,
082:                            "riot-controller").attribute("riot:contextKey",
083:                            list.getId().toString()).attribute(
084:                            "riot:controllerId",
085:                            ServletUtils.getPathWithinApplication(request));
086:                }
087:
088:                String className = "riot-list riot-component-list";
089:                if (getParentContainer(request) == null) {
090:                    className += " riot-toplevel-list";
091:                }
092:                if (list.isDirty()) {
093:                    className += " riot-dirty";
094:                }
095:
096:                wrapper.start(Html.DIV).attribute(Html.COMMON_CLASS, className)
097:                        .attribute("riot:listId", list.getId().toString());
098:
099:                if (config.getMinComponents() != null) {
100:                    wrapper.attribute("riot:minComponents", config
101:                            .getMinComponents().intValue());
102:                }
103:                if (config.getMaxComponents() != null) {
104:                    wrapper.attribute("riot:maxComponents", config
105:                            .getMaxComponents().intValue());
106:                }
107:
108:                wrapper.body();
109:                super .renderComponentList(list, request, response);
110:                wrapper.closeAll();
111:            }
112:
113:            /**
114:             * Overrides the default implementation to create a new list if no existing
115:             * list is found.
116:             *
117:             * @see #createNewList(Location)
118:             */
119:            protected ComponentList getComponentList(Location location,
120:                    HttpServletRequest request) {
121:
122:                ComponentList list = super .getComponentList(location, request);
123:                if (list == null) {
124:                    list = createNewList(location, request);
125:                }
126:                return list;
127:            }
128:
129:            /**
130:             * Creates a new ComponentList with an initial component set as defined by
131:             * the controller.
132:             * @param request 
133:             */
134:            protected ComponentList createNewList(Location location,
135:                    HttpServletRequest request) {
136:
137:                ComponentList list = new ComponentList();
138:                list.setLocation(new Location(location));
139:                list.setParent(getParentContainer(request));
140:                String[] initialTypes = config.getInitialComponentTypes();
141:                if (initialTypes != null) {
142:                    List containers = new ArrayList();
143:                    for (int i = 0; i < initialTypes.length; i++) {
144:                        VersionContainer container = new VersionContainer();
145:                        ComponentVersion live = new ComponentVersion(
146:                                initialTypes[i]);
147:                        live.setContainer(container);
148:                        container.setList(list);
149:                        container.setLiveVersion(live);
150:                        containers.add(container);
151:                    }
152:                    list.setLiveContainers(containers);
153:                }
154:                dao.saveComponentList(list);
155:                log.debug("New ComponentList created: " + list);
156:                return list;
157:            }
158:
159:            /**
160:             * Overrides the default implementation to render a DIV tag around the
161:             * actual component. The DIV has attributes that are required for the
162:             * Riot toolbar JavaScript.
163:             * @throws IOException
164:             */
165:            protected void renderContainer(VersionContainer container,
166:                    String positionClassName, HttpServletRequest request,
167:                    HttpServletResponse response) throws Exception {
168:
169:                ComponentVersion version = getVersionToRender(container);
170:                String type = version.getType();
171:                String formUrl = repository.getFormUrl(type, container.getId());
172:
173:                String className = "riot-list-component riot-component "
174:                        + "riot-component-" + type;
175:
176:                if (formUrl != null) {
177:                    className += " riot-form";
178:                }
179:
180:                TagWriter wrapper = new TagWriter(response.getWriter());
181:                wrapper.start(Html.DIV).attribute(Html.COMMON_CLASS, className)
182:                        .attribute("riot:containerId",
183:                                container.getId().toString()).attribute(
184:                                "riot:componentType", type).attribute(
185:                                "riot:form", formUrl).body();
186:
187:                renderComponentVersion(version, positionClassName, request,
188:                        response);
189:                wrapper.end();
190:            }
191:
192:            protected RenderStrategy getStrategyForParentList() {
193:                return parentStrategy;
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.