Source Code Cross Referenced for Template.java in  » Ajax » dwr » jsx3 » xml » 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 » Ajax » dwr » jsx3.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Joe Walker
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package jsx3.xml;
017:
018:        import org.directwebremoting.ScriptBuffer;
019:        import org.directwebremoting.proxy.ScriptProxy;
020:        import org.directwebremoting.proxy.io.Context;
021:
022:        /**
023:         * Wrapper of the native browser XSLT processor.
024:         * @author Joe Walker [joe at getahead dot org]
025:         * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026:         */
027:        public class Template extends jsx3.lang.Object {
028:            /**
029:             * All reverse ajax proxies need context to work from
030:             * @param scriptProxy The place we are writing scripts to
031:             * @param context The script that got us to where we are now
032:             */
033:            public Template(Context context, String extension,
034:                    ScriptProxy scriptProxy) {
035:                super (context, extension, scriptProxy);
036:            }
037:
038:            /**
039:             * The instance initializer.
040:             * @param objXSL 
041:             */
042:            public Template(jsx3.xml.CdfDocument objXSL) {
043:                super ((Context) null, (String) null, (ScriptProxy) null);
044:                ScriptBuffer script = new ScriptBuffer();
045:                script.appendCall("new Template", objXSL);
046:                setInitScript(script);
047:            }
048:
049:            /**
050:             * 
051:             * @param strName 
052:             * @param objValue 
053:             */
054:            public void setParam(String strName, jsx3.lang.Object objValue) {
055:                ScriptBuffer script = new ScriptBuffer();
056:                script.appendCall(getContextPath() + "setParam", strName,
057:                        objValue);
058:                getScriptProxy().addScript(script);
059:            }
060:
061:            /**
062:             * 
063:             */
064:            public void reset() {
065:                ScriptBuffer script = new ScriptBuffer();
066:                script.appendCall(getContextPath() + "reset");
067:                getScriptProxy().addScript(script);
068:            }
069:
070:            /**
071:             * 
072:             * @param objParams JavaScript object array of name/value pairs. If this parameter is
073:            not empty, the transformation will use a paramaterized stylesheet to perform the transformation.
074:             */
075:            public void setParams(jsx3.lang.Object objParams) {
076:                ScriptBuffer script = new ScriptBuffer();
077:                script.appendCall(getContextPath() + "setParams", objParams);
078:                getScriptProxy().addScript(script);
079:            }
080:
081:            /**
082:             * Performs an XSLT merge. If an error occurs while performing the transform, this method sets the error
083:            property of this processor and returns null.
084:             * @param objXML 
085:             * @param bObject 
086:             * @param callback the result of the transformation
087:             */
088:            @SuppressWarnings("unchecked")
089:            public void transform(jsx3.xml.Node objXML, boolean bObject,
090:                    org.directwebremoting.proxy.Callback<String> callback) {
091:                ScriptBuffer script = new ScriptBuffer();
092:                String callbackPrefix = "";
093:
094:                if (callback != null) {
095:                    callbackPrefix = "var reply = ";
096:                }
097:
098:                script.appendCall(callbackPrefix + getContextPath()
099:                        + "transform", objXML, bObject);
100:
101:                if (callback != null) {
102:                    String key = org.directwebremoting.extend.CallbackHelper
103:                            .saveCallback(callback, String.class);
104:                    script
105:                            .appendCall("__System.activateCallback", key,
106:                                    "reply");
107:                }
108:
109:                getScriptProxy().addScript(script);
110:            }
111:
112:            /**
113:             * Performs an XSLT merge. If an error occurs while performing the transform, this method sets the error
114:            property of this processor and returns null.
115:             * @param objXML 
116:             * @return if a valid result tree is formed as a result of the transformation
117:             */
118:            @SuppressWarnings("unchecked")
119:            public jsx3.xml.CdfDocument transformToObject(jsx3.xml.Node objXML) {
120:                String extension = "transformToObject(\"" + objXML + "\").";
121:                try {
122:                    java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
123:                            .getConstructor(Context.class, String.class,
124:                                    ScriptProxy.class);
125:                    return ctor.newInstance(this , extension, getScriptProxy());
126:                } catch (Exception ex) {
127:                    throw new IllegalArgumentException("Unsupported type: "
128:                            + jsx3.xml.CdfDocument.class.getName());
129:                }
130:            }
131:
132:            /**
133:             * Performs an XSLT merge. If an error occurs while performing the transform, this method sets the error
134:            property of this processor and returns null.
135:             * @param objXML 
136:             * @param returnType The expected return type
137:             * @return if a valid result tree is formed as a result of the transformation
138:             */
139:            @SuppressWarnings("unchecked")
140:            public <T> T transformToObject(jsx3.xml.Node objXML,
141:                    Class<T> returnType) {
142:                String extension = "transformToObject(\"" + objXML + "\").";
143:                try {
144:                    java.lang.reflect.Constructor<T> ctor = returnType
145:                            .getConstructor(Context.class, String.class,
146:                                    ScriptProxy.class);
147:                    return ctor.newInstance(this , extension, getScriptProxy());
148:                } catch (Exception ex) {
149:                    throw new IllegalArgumentException(
150:                            "Unsupported return type: " + returnType.getName());
151:                }
152:            }
153:
154:            /**
155:             * Returns an error object (a plain JavaScript object) with two properties that the developer can query for:
156:
157:            code Ð an integer error code, 0 for no error.
158:            description Ð a text description of the error that occurred.
159:             */
160:            @SuppressWarnings("unchecked")
161:            public jsx3.lang.Object getError() {
162:                String extension = "getError().";
163:                try {
164:                    java.lang.reflect.Constructor<jsx3.lang.Object> ctor = jsx3.lang.Object.class
165:                            .getConstructor(Context.class, String.class,
166:                                    ScriptProxy.class);
167:                    return ctor.newInstance(this , extension, getScriptProxy());
168:                } catch (Exception ex) {
169:                    throw new IllegalArgumentException("Unsupported type: "
170:                            + jsx3.lang.Object.class.getName());
171:                }
172:            }
173:
174:            /**
175:             * Returns an error object (a plain JavaScript object) with two properties that the developer can query for:
176:
177:            code Ð an integer error code, 0 for no error.
178:            description Ð a text description of the error that occurred.
179:             * @param returnType The expected return type
180:             */
181:            @SuppressWarnings("unchecked")
182:            public <T> T getError(Class<T> returnType) {
183:                String extension = "getError().";
184:                try {
185:                    java.lang.reflect.Constructor<T> ctor = returnType
186:                            .getConstructor(Context.class, String.class,
187:                                    ScriptProxy.class);
188:                    return ctor.newInstance(this , extension, getScriptProxy());
189:                } catch (Exception ex) {
190:                    throw new IllegalArgumentException(
191:                            "Unsupported return type: " + returnType.getName());
192:                }
193:            }
194:
195:            /**
196:             * Returns true if the last operation on this XML entity caused an error.
197:             */
198:            @SuppressWarnings("unchecked")
199:            public void hasError(
200:                    org.directwebremoting.proxy.Callback<Boolean> callback) {
201:                ScriptBuffer script = new ScriptBuffer();
202:                String callbackPrefix = "";
203:
204:                if (callback != null) {
205:                    callbackPrefix = "var reply = ";
206:                }
207:
208:                script.appendCall(callbackPrefix + getContextPath()
209:                        + "hasError");
210:
211:                if (callback != null) {
212:                    String key = org.directwebremoting.extend.CallbackHelper
213:                            .saveCallback(callback, Boolean.class);
214:                    script
215:                            .appendCall("__System.activateCallback", key,
216:                                    "reply");
217:                }
218:
219:                getScriptProxy().addScript(script);
220:            }
221:
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.