Source Code Cross Referenced for PanelTag.java in  » Content-Management-System » TransferCM » com » methodhead » shim » 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 » TransferCM » com.methodhead.shim 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright (C) 2006 Methodhead Software LLC.  All rights reserved.
003:         * 
004:         * This file is part of TransferCM.
005:         * 
006:         * TransferCM is free software; you can redistribute it and/or modify it under the
007:         * terms of the GNU General Public License as published by the Free Software
008:         * Foundation; either version 2 of the License, or (at your option) any later
009:         * version.
010:         * 
011:         * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
012:         * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
013:         * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
014:         * details.
015:         * 
016:         * You should have received a copy of the GNU General Public License along with
017:         * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
018:         * Fifth Floor, Boston, MA  02110-1301  USA
019:         */
020:
021:        package com.methodhead.shim;
022:
023:        import javax.servlet.jsp.JspException;
024:        import javax.servlet.jsp.tagext.TagSupport;
025:        import java.util.Map;
026:        import java.io.IOException;
027:        import java.util.HashMap;
028:        import javax.servlet.http.HttpServletRequest;
029:        import javax.servlet.http.HttpServletResponse;
030:        import org.apache.struts.util.MessageResources;
031:        import org.apache.struts.Globals;
032:        import com.methodhead.sitecontext.SiteContext;
033:
034:        public class PanelTag extends TagSupport {
035:
036:            // constructors /////////////////////////////////////////////////////////////
037:
038:            // constants ////////////////////////////////////////////////////////////////
039:
040:            // classes //////////////////////////////////////////////////////////////////
041:
042:            // methods //////////////////////////////////////////////////////////////////
043:
044:            public int doStartTag() throws JspException {
045:
046:                try {
047:
048:                    //
049:                    // define template?
050:                    //
051:                    Map map = (Map) pageContext.getRequest().getAttribute(
052:                            ShimGlobals.PANELMAP_KEY);
053:
054:                    if (map != null) {
055:
056:                        //
057:                        // ignore the panel if it's already defined
058:                        //
059:                        if (map.containsKey(getName()))
060:                            return SKIP_BODY;
061:
062:                        //
063:                        // create a panel config and add it to the map
064:                        //
065:                        PanelConfig panelConfig = new PanelConfig();
066:                        panelConfig.setName(getName());
067:
068:                        if (getDefaultModule().equals(""))
069:                            panelConfig
070:                                    .setDefaultModule(ShimGlobals.DEFAULT_MODULE);
071:                        else
072:                            panelConfig.setDefaultModule(getDefaultModule());
073:
074:                        map.put(panelConfig.getName(), panelConfig);
075:
076:                        return SKIP_BODY;
077:                    }
078:
079:                    //
080:                    // get some things
081:                    //
082:                    String mode = (String) pageContext.getSession()
083:                            .getAttribute(ShimGlobals.MODE_KEY);
084:
085:                    Page page = (Page) pageContext.getRequest().getAttribute(
086:                            ShimGlobals.PAGE_KEY);
087:
088:                    Module module = null;
089:                    Panel panel = (Panel) page.getPanels().get(name_);
090:                    if (panel != null)
091:                        module = panel.getModule();
092:
093:                    MessageResources messageResources = (MessageResources) pageContext
094:                            .getServletContext().getAttribute(
095:                                    Globals.MESSAGES_KEY);
096:
097:                    //
098:                    // richedit mode?
099:                    //
100:                    if (pageContext.getRequest().getAttribute(
101:                            ShimGlobals.EDITPANEL_KEY) != null) {
102:
103:                        //
104:                        // display the module in edit mode if it's the one being edited
105:                        //
106:                        if (name_.equals(pageContext.getRequest().getAttribute(
107:                                ShimGlobals.EDITPANEL_KEY))) {
108:
109:                            pageContext.getOut().println(
110:                                    "<div id=\"editableDiv\">");
111:
112:                            if (module == null)
113:                                pageContext
114:                                        .getOut()
115:                                        .println(
116:                                                messageResources
117:                                                        .getMessage("shim.panelNotSet"));
118:                            else
119:                                module.display((HttpServletRequest) pageContext
120:                                        .getRequest(),
121:                                        (HttpServletResponse) pageContext
122:                                                .getResponse(), pageContext
123:                                                .getOut());
124:
125:                            pageContext.getOut().println("</div>");
126:                        } else {
127:
128:                            //
129:                            // otherwise just display the panel
130:                            //
131:                            if (module == null)
132:                                pageContext
133:                                        .getOut()
134:                                        .println(
135:                                                messageResources
136:                                                        .getMessage("shim.panelNotSet"));
137:                            else
138:                                module.display((HttpServletRequest) pageContext
139:                                        .getRequest(),
140:                                        (HttpServletResponse) pageContext
141:                                                .getResponse(), pageContext
142:                                                .getOut());
143:                        }
144:                    }
145:
146:                    //
147:                    // edit mode?
148:                    //
149:                    else if (ShimGlobals.MODE_EDIT.equals(mode)
150:                            && (pageContext.getRequest().getAttribute(
151:                                    ShimGlobals.PREVIEW_KEY) == null)) {
152:
153:                        String headerResource = null;
154:                        String footerResource = null;
155:
156:                        if (ShimUtils
157:                                .displayEditElements((HttpServletRequest) pageContext
158:                                        .getRequest())) {
159:                            //
160:                            // figure out which header to use
161:                            //
162:                            if (module == null) {
163:                                headerResource = "shim.editPage.panelHeaderPanel";
164:                                footerResource = "shim.editPage.panelFooterPanel";
165:                            } else if (module.isConfigurable()
166:                                    && !module.isEditable()) {
167:                                headerResource = "shim.editPage.panelHeaderPanelConfigure";
168:                                footerResource = "shim.editPage.panelFooterPanelConfigure";
169:                            } else if (!module.isConfigurable()
170:                                    && module.isEditable()) {
171:                                headerResource = "shim.editPage.panelHeaderPanelEdit";
172:                                footerResource = "shim.editPage.panelFooterPanelEdit";
173:                            } else if (module.isConfigurable()
174:                                    && module.isEditable()) {
175:                                headerResource = "shim.editPage.panelHeaderPanelConfigureEdit";
176:                                footerResource = "shim.editPage.panelFooterPanelConfigureEdit";
177:                            }
178:
179:                            //
180:                            // print the header if there is one
181:                            //
182:                            if (headerResource != null) {
183:
184:                                //
185:                                // add edit controls if we're in edit mode, but not previewing
186:                                //
187:                                pageContext.getOut().println(
188:                                        messageResources.getMessage(
189:                                                headerResource, ""
190:                                                        + page.getInt("id"),
191:                                                name_));
192:                            }
193:                        }
194:
195:                        //
196:                        // display the module
197:                        //
198:                        if (module == null)
199:                            pageContext.getOut().println(
200:                                    messageResources
201:                                            .getMessage("shim.panelNotSet"));
202:                        else
203:                            module.display((HttpServletRequest) pageContext
204:                                    .getRequest(),
205:                                    (HttpServletResponse) pageContext
206:                                            .getResponse(), pageContext
207:                                            .getOut());
208:
209:                        if (ShimUtils
210:                                .displayEditElements((HttpServletRequest) pageContext
211:                                        .getRequest())) {
212:                            //
213:                            // print the footer if there is one
214:                            //
215:                            if (footerResource != null) {
216:                                pageContext.getOut().println(
217:                                        messageResources.getMessage(
218:                                                footerResource, ""
219:                                                        + page.getInt("id"),
220:                                                name_));
221:                            }
222:                        }
223:                    }
224:
225:                    //
226:                    // otherwise, just display the module
227:                    //
228:                    else {
229:                        if (module == null)
230:                            pageContext.getOut().println(
231:                                    messageResources
232:                                            .getMessage("shim.panelNotSet"));
233:                        else
234:                            module.display((HttpServletRequest) pageContext
235:                                    .getRequest(),
236:                                    (HttpServletResponse) pageContext
237:                                            .getResponse(), pageContext
238:                                            .getOut());
239:                    }
240:                } catch (IOException e) {
241:                    throw new JspException(
242:                            "Unexpected IOException when displaying panel \""
243:                                    + name_ + "\": " + e.toString());
244:                }
245:
246:                return SKIP_BODY;
247:            }
248:
249:            // properties ///////////////////////////////////////////////////////////////
250:
251:            public String getName() {
252:                return name_;
253:            }
254:
255:            public void setName(String name) {
256:                name_ = name;
257:            }
258:
259:            public String getDefaultModule() {
260:                return defaultModule_;
261:            }
262:
263:            public void setDefaultModule(String defaultModule) {
264:                defaultModule_ = defaultModule;
265:            }
266:
267:            // attributes ///////////////////////////////////////////////////////////////
268:
269:            private String name_ = "";
270:
271:            private String defaultModule_ = "";
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.