Source Code Cross Referenced for AbstractRichtexteditorResult.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » views » jsp » ui » 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 » J2EE » webwork 2.2.6 » com.opensymphony.webwork.views.jsp.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2003 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork.views.jsp.ui;
006:
007:        import java.io.OutputStream;
008:        import java.io.StringWriter;
009:
010:        import javax.xml.parsers.DocumentBuilder;
011:        import javax.xml.parsers.DocumentBuilderFactory;
012:        import javax.xml.parsers.ParserConfigurationException;
013:        import javax.xml.transform.Transformer;
014:        import javax.xml.transform.TransformerConfigurationException;
015:        import javax.xml.transform.TransformerException;
016:        import javax.xml.transform.TransformerFactory;
017:        import javax.xml.transform.dom.DOMSource;
018:        import javax.xml.transform.stream.StreamResult;
019:
020:        import org.w3c.dom.Document;
021:        import org.w3c.dom.Element;
022:
023:        import com.opensymphony.webwork.components.AbstractRichtexteditorConnector.CreateFolderResult;
024:        import com.opensymphony.webwork.components.AbstractRichtexteditorConnector.FileUploadResult;
025:        import com.opensymphony.webwork.components.AbstractRichtexteditorConnector.Folder;
026:        import com.opensymphony.webwork.components.AbstractRichtexteditorConnector.FoldersAndFiles;
027:        import com.opensymphony.xwork.ActionInvocation;
028:        import com.opensymphony.xwork.Result;
029:
030:        /**
031:         * <!-- START SNIPPET: javadoc -->
032:         * 
033:         * Abstract result for all Rich Text Editor results. It contains common methods
034:         * that might come in handy to its subclass. 
035:         * 
036:         * Configuration of result necessary in xwork.xml (is already there by default) are
037:         * as follows:
038:         * 
039:         * <pre>
040:         *  &lt;!-- Results necessary when using 'browse server' and 'upload' feature of Richtexteditor --&gt;
041:         *  &lt;result-type name="richtexteditorGetFolders" 
042:         *                  class="com.opensymphony.webwork.views.jsp.ui.RichtexteditorGetFoldersResult" /&gt;
043:         *  &lt;result-type name="richtexteditorGetFoldersAndFiles" 
044:         *                  class="com.opensymphony.webwork.views.jsp.ui.RichtexteditorGetFoldersAndFilesResult" /&gt;
045:         *  &lt;result-type name="richtexteditorCreateFolder" 
046:         *                  class="com.opensymphony.webwork.views.jsp.ui.RichtexteditorCreateFolderResult" /&gt;
047:         *  &lt;result-type name="richtexteditorFileUpload" 
048:         *                  class="com.opensymphony.webwork.views.jsp.ui.RichtexteditorFileUploadResult" /&gt;
049:         * </pre>
050:         * 
051:         * <!-- END SNIPPET: javadoc -->
052:         * 
053:         * @author tm_jee
054:         * @version $Date: 2006-03-08 21:22:35 +0100 (Wed, 08 Mar 2006) $ $Id: AbstractRichtexteditorResult.java 2338 2006-03-08 20:22:35Z rainerh $
055:         */
056:        public abstract class AbstractRichtexteditorResult implements  Result {
057:
058:            /**
059:             * Build an xml <code>Document</code>
060:             * 
061:             * @return An XML Document
062:             * @throws ParserConfigurationException
063:             */
064:            protected Document buildDocument()
065:                    throws ParserConfigurationException {
066:                DocumentBuilderFactory factory = DocumentBuilderFactory
067:                        .newInstance();
068:                DocumentBuilder builder = factory.newDocumentBuilder();
069:                Document document = builder.newDocument();
070:
071:                return document;
072:            }
073:
074:            /**
075:             * Build a common xml structure for all xml based result. For example:
076:             * 
077:             * <pre>
078:             * &lt;?xml version="1.0" encoding="utf-8" ?&gt;
079:             * &lt;Connector command="RequestedCommandName" resourceType=" RequestedResourceType"&gt;
080:             *       &lt;CurrentFolder path="CurrentFolderPath" url="CurrentFolderUrl" /&gt;
081:             *       &lt;!-- Here goes all specific command data --&gt;
082:             * &lt;/Connector&gt;
083:             * </pre>
084:             * 
085:             * @param document
086:             * @param command
087:             * @param type
088:             * @param folderPath
089:             * @param serverPath
090:             * @return A common xml structure for all xml based result.
091:             */
092:            protected Element buildCommonResponseXml(Document document,
093:                    String command, String type, String folderPath,
094:                    String serverPath) {
095:                Element connectorElement = document.createElement("Connector");
096:                connectorElement.setAttribute("command", command);
097:                connectorElement.setAttribute("resourceType", type);
098:                document.appendChild(connectorElement);
099:
100:                Element myEl = document.createElement("CurrentFolder");
101:                myEl.setAttribute("path", folderPath);
102:                myEl.setAttribute("url", serverPath);
103:                connectorElement.appendChild(myEl);
104:
105:                return connectorElement;
106:            }
107:
108:            /**
109:             * Convert a <code>Document<code> to its string representation.
110:             * 
111:             * @param document
112:             * @return The documents String representation.
113:             * @throws TransformerConfigurationException
114:             * @throws TransformerException
115:             */
116:            protected String stringFromDocument(Document document)
117:                    throws TransformerConfigurationException,
118:                    TransformerException {
119:                //document.normalizeDocument();
120:                StringWriter writer = new StringWriter();
121:                String result = null;
122:                try {
123:                    writer = new StringWriter();
124:                    TransformerFactory factory = TransformerFactory
125:                            .newInstance();
126:                    Transformer transformer = factory.newTransformer();
127:                    transformer.transform(new DOMSource(document),
128:                            new StreamResult(writer));
129:                    result = writer.getBuffer().toString();
130:
131:                } finally {
132:                    if (writer != null)
133:                        try {
134:                            writer.close();
135:                        } catch (Exception e) {
136:                        }
137:                    writer = null;
138:                }
139:                return result;
140:            }
141:
142:            /**
143:             * Write a <code>Document</code> to an OutputStream <code>out</code>
144:             * 
145:             * @param document
146:             * @param out
147:             * @throws TransformerConfigurationException
148:             * @throws TransformerException
149:             */
150:            protected void writeDocumentToStream(Document document,
151:                    OutputStream out) throws TransformerConfigurationException,
152:                    TransformerException {
153:                //document.normalizeDocument();
154:                TransformerFactory factory = TransformerFactory.newInstance();
155:                Transformer transformer = factory.newTransformer();
156:                transformer.transform(new DOMSource(document),
157:                        new StreamResult(out));
158:            }
159:
160:            /**
161:             * Get the command send by the Rich Text Editor. It would be one of the followings. 
162:             * Only valid when rich text editor issue a server-side 'Browse' not 'Upload'.
163:             * 
164:             * <ul>
165:             *   <li>GetFolders</li>
166:             *   <li>GetFoldersAndFiles</li>
167:             *   <li>CreateFolder</li>
168:             *   <li>FileUpload</li>
169:             * </ul>
170:             * 
171:             * @param invocation
172:             * @return The command send by the Rich Text Editor.
173:             */
174:            protected String getCommand(ActionInvocation invocation) {
175:                return (String) invocation.getStack().getContext().get(
176:                        "__richtexteditorCommand");
177:            }
178:
179:            /**
180:             * Get the type send by the Rich Text Editor. It could be one of the followings:
181:             * 
182:             * <ul>
183:             *    <li>Image</li>
184:             *    <li>File</li>
185:             *    <li>Flash</li>
186:             * </ul>
187:             * 
188:             * @param invocation
189:             * @return The type send by the Rich Text Editor.
190:             */
191:            protected String getType(ActionInvocation invocation) {
192:                return (String) invocation.getStack().getContext().get(
193:                        "__richtexteditorType");
194:            }
195:
196:            /**
197:             * Get the folder path send by the Rich Text Editor.
198:             * 
199:             * @param invocation
200:             * @return The folder path send by the Rich Text Editor.
201:             */
202:            protected String getFolderPath(ActionInvocation invocation) {
203:                return (String) invocation.getStack().getContext().get(
204:                        "__richtexteditorFolderPath");
205:            }
206:
207:            /**
208:             * Get the server path calculated from AbstractRichtexteditoConnector or its 
209:             * decendant through AbstractRichtexteditorConnector#calculate#calculateServerPath(String, String String)
210:             * 
211:             * @param invocation
212:             * @return The server path calculated from AbstractRichtexteditoConnector
213:             * @see com.opensymphony.webwork.components.AbstractRichtexteditorConnector#calculateServerPath(String, String, String)
214:             */
215:            protected String getServerPath(ActionInvocation invocation) {
216:                return (String) invocation.getStack().getContext().get(
217:                        "__richtexteditorServerPath");
218:            }
219:
220:            /**
221:             * Get the <code>Folder[]</code> computed from AbstractRichtexteditorConnector or its
222:             * decendant through AbstractRichtexteditorConnector#getFolders(String, String). Only
223:             * valid if it is a 'GetFolder' command.
224:             * 
225:             * @param invocation
226:             * @return The <code>Folder[]</code> computed from AbstractRichtexteditorConnector
227:             * @see com.opensymphony.webwork.components.AbstractRichtexteditorConnector#getFolders(String, String)
228:             */
229:            protected Folder[] richtexteditorFolders(ActionInvocation invocation) {
230:                return (Folder[]) invocation.getStack().getContext().get(
231:                        "__richtexteditorGetFolders");
232:            }
233:
234:            /**
235:             * Get the <code>FoldersAndFiles</code> computed from AbstractRichtexteditorConnector or its
236:             * decendant through AbstractRichtexteditorConnector#getFoldersAndFiles(String, String). Only
237:             * valid if it is a 'GetFoldersAndFiles' command.
238:             * 
239:             * @param invocation
240:             * @return The <code>FoldersAndFiles</code> computed from AbstractRichtexteditorConnector
241:             * @see com.opensymphony.webwork.components.AbstractRichtexteditorConnector#getFoldersAndFiles(String, String)
242:             */
243:            protected FoldersAndFiles richtexteditorFoldersAndFiles(
244:                    ActionInvocation invocation) {
245:                return (FoldersAndFiles) invocation.getStack().getContext()
246:                        .get("__richtexteditorGetFoldersAndFiles");
247:            }
248:
249:            /**
250:             * Get the <code>CreateFolderResult</code> computed from AbstractRichtexteditorConnector or its
251:             * decendant through AbstractRichtexteditorConnector#createFolder(String, String, String). Only 
252:             * valid if it is a 'CreateFolder' command.
253:             * 
254:             * @param invocation
255:             * @return The <code>CreateFolderResult</code> computed from AbstractRichtexteditorConnector
256:             * @see com.opensymphony.webwork.components.AbstractRichtexteditorConnector#createFolder(String, String, String)
257:             */
258:            protected CreateFolderResult richtexteditorCreateFolderResult(
259:                    ActionInvocation invocation) {
260:                return (CreateFolderResult) invocation.getStack().getContext()
261:                        .get("__richtexteditorCreateFolder");
262:            }
263:
264:            /**
265:             * Get the <code>FileUploadResult</code> computed from AbstractRichtexteditorConnector or its
266:             * decendant through AbstractRichtexteditorConnector#fileUpload(String, String, String, String, File).
267:             * Only valid if it is a 'FileUpload' command
268:             * 
269:             * @param invocation
270:             * @return The <code>FileUploadResult</code> computed from AbstractRichtexteditorConnector
271:             * @see com.opensymphony.webwork.components.AbstractRichtexteditorConnector#fileUpload(String, String, String, String, java.io.File)
272:             */
273:            protected FileUploadResult richtexteditorFileUploadResult(
274:                    ActionInvocation invocation) {
275:                return (FileUploadResult) invocation.getStack().getContext()
276:                        .get("__richtexteditorFileUpload");
277:            }
278:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.