Source Code Cross Referenced for PopupSupport.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » tags » html » 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 » Library » Apache beehive 1.0.2 src » org.apache.beehive.netui.tags.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         *
017:         * $Header:$
018:         */
019:        package org.apache.beehive.netui.tags.html;
020:
021:        import org.apache.beehive.netui.util.internal.InternalStringBuilder;
022:
023:        import org.apache.beehive.netui.pageflow.internal.InternalConstants;
024:        import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
025:        import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
026:        import org.apache.beehive.netui.tags.internal.ReturnActionViewRenderer;
027:        import org.apache.beehive.netui.tags.javascript.CoreScriptFeature;
028:        import org.apache.beehive.netui.tags.javascript.IScriptReporter;
029:        import org.apache.beehive.netui.tags.javascript.ScriptRequestState;
030:        import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
031:
032:        import javax.servlet.ServletRequest;
033:        import javax.servlet.jsp.JspException;
034:        import java.util.HashMap;
035:        import java.util.Map;
036:        import java.util.Iterator;
037:
038:        class PopupSupport {
039:            private static final String VIEW_RENDERER_CLASS_NAME = ReturnActionViewRenderer.class
040:                    .getName();
041:            private static final String ON_POPUP_DONE_FUNC = "Netui_OnPopupDone";
042:            private static final String POPUP_FUNC = "Netui_Popup";
043:            private static final String POPUP_WINDOW = "Netui_Window";
044:
045:            private String _name = "";
046:            private HashMap _features;
047:            private boolean _replace = false;
048:            private String _onPopupDone;
049:            private String _popupFunc;
050:            private String _formName;
051:
052:            public void setName(String name) {
053:                _name = name;
054:            }
055:
056:            public void setToolbar(boolean toolbar) {
057:                putFeature("toolbar", toolbar);
058:            }
059:
060:            public void setLocation(boolean location) {
061:                putFeature("location", location);
062:            }
063:
064:            public void setDirectories(boolean directories) {
065:                putFeature("directories", directories);
066:            }
067:
068:            public void setStatus(boolean status) {
069:                putFeature("status", status);
070:            }
071:
072:            public void setMenubar(boolean menubar) {
073:                putFeature("menubar", menubar);
074:            }
075:
076:            public void setScrollbars(boolean scrollbars) {
077:                putFeature("scrollbars", scrollbars);
078:            }
079:
080:            public void setResizable(boolean resizable) {
081:                putFeature("resizable", resizable);
082:            }
083:
084:            public void setWidth(int width) {
085:                putFeature("width", new Integer(width));
086:            }
087:
088:            public void setHeight(int height) {
089:                putFeature("height", new Integer(height));
090:            }
091:
092:            public void setLeft(int left) {
093:                putFeature("left", new Integer(left));
094:            }
095:
096:            public void setTop(int top) {
097:                putFeature("top", new Integer(top));
098:            }
099:
100:            public void setReplace(boolean replace) {
101:                _replace = replace;
102:            }
103:
104:            public void setOnPopupDone(String onPopupDone) {
105:                _onPopupDone = onPopupDone;
106:            }
107:
108:            public void setPopupFunc(String popupFunc) {
109:                _popupFunc = popupFunc;
110:            }
111:
112:            /**
113:             * Sets whether the JavaScript function that opens the popup window should add data
114:             * from the form fields to the request. The form name is used in the JavaScript
115:             * function of onClick to identify the form object correctly. The JavaScript
116:             * will only be set up to pass the names and values for the form fields on the
117:             * request if the form name is set. 
118:             *
119:             * @param formName the name attribute of the form to pass field data from.
120:             *                 This must be the real/generated form name and not the
121:             *                 netui:form tagId attribute.
122:             */
123:            public void setFormName(String formName) {
124:                _formName = formName;
125:            }
126:
127:            public String getOnClick(ServletRequest req, String url) {
128:                // Build up the string that's passed to javascript open() to specify window features.
129:                InternalStringBuilder features = new InternalStringBuilder();
130:
131:                if (_features != null) {
132:                    boolean firstOne = true;
133:                    for (Iterator i = _features.entrySet().iterator(); i
134:                            .hasNext();) {
135:                        Map.Entry entry = (Map.Entry) i.next();
136:                        if (!firstOne) {
137:                            features.append(',');
138:                        }
139:                        features.append(entry.getKey());
140:                        features.append('=');
141:                        features.append(entry.getValue());
142:                        firstOne = false;
143:                    }
144:                }
145:
146:                String onClick = null;
147:                String popupWindow = getScopedFunctionName(req, POPUP_WINDOW);
148:
149:                String popupFunc = (_popupFunc != null ? _popupFunc
150:                        : POPUP_FUNC);
151:                if (_formName != null && _formName.length() > 0) {
152:                    Object[] args = new Object[] { popupFunc, url, _name,
153:                            features.toString(), Boolean.valueOf(_replace),
154:                            popupWindow, _formName };
155:                    onClick = ScriptRequestState.getString(
156:                            "popupSupportUpdateFormOnClick", args);
157:                } else {
158:                    Object[] args = new Object[] { popupFunc, url, _name,
159:                            features.toString(), Boolean.valueOf(_replace),
160:                            popupWindow };
161:                    onClick = ScriptRequestState.getString(
162:                            "popupSupportOnClick", args);
163:                }
164:
165:                return onClick;
166:            }
167:
168:            public void addParams(IUrlParams urlParams, ServletRequest request)
169:                    throws JspException {
170:                urlParams.addParameter(
171:                        InternalConstants.RETURN_ACTION_VIEW_RENDERER_PARAM,
172:                        VIEW_RENDERER_CLASS_NAME, null);
173:                String onPopupDone = (_onPopupDone != null ? _onPopupDone
174:                        : ON_POPUP_DONE_FUNC);
175:                urlParams.addParameter(ReturnActionViewRenderer
176:                        .getCallbackParamName(), onPopupDone, null);
177:
178:                ScopedRequest scopedRequest = ScopedServletUtils
179:                        .unwrapRequest(request);
180:                if (scopedRequest != null) {
181:                    urlParams.addParameter(ScopedServletUtils.SCOPE_ID_PARAM,
182:                            scopedRequest.getScopeKey().toString(), null);
183:                }
184:            }
185:
186:            public void writeScript(ServletRequest req, ScriptRequestState srs,
187:                    IScriptReporter scriptReporter,
188:                    AbstractRenderAppender results) {
189:                // Write the generic function for popping a window.
190:                srs.writeFeature(scriptReporter, results,
191:                        CoreScriptFeature.POPUP_OPEN, true, false,
192:                        new Object[] { POPUP_FUNC });
193:
194:                // Write the callback that's triggered when the popup window is closing.
195:                srs.writeFeature(scriptReporter, results,
196:                        CoreScriptFeature.POPUP_DONE, true, false,
197:                        new Object[] { ON_POPUP_DONE_FUNC });
198:
199:                // Write the initialization of the popup window variable.
200:                String popupWindow = getScopedFunctionName(req, POPUP_WINDOW);
201:                srs.writeFeature(scriptReporter, results,
202:                        "popupSupportWindowVariable",
203:                        new Object[] { popupWindow });
204:            }
205:
206:            private static String getScopedFunctionName(ServletRequest req,
207:                    String funcName) {
208:                ScopedRequest scopedRequest = ScopedServletUtils
209:                        .unwrapRequest(req);
210:                return (scopedRequest != null ? funcName + '_'
211:                        + scopedRequest.getScopeKey() : funcName);
212:            }
213:
214:            private void putFeature(String featureName, boolean val) {
215:                putFeature(featureName, val ? new Integer(1) : new Integer(0));
216:            }
217:
218:            private void putFeature(String featureName, Object val) {
219:                if (_features == null) {
220:                    _features = new HashMap();
221:                }
222:                _features.put(featureName, val);
223:            }
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.