Source Code Cross Referenced for PanelPopupRenderer.java in  » J2EE » ICEfaces-1.6.1 » com » icesoft » faces » component » panelpopup » 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 » ICEfaces 1.6.1 » com.icesoft.faces.component.panelpopup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003:         *
004:         * "The contents of this file are subject to the Mozilla Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License at
007:         * http://www.mozilla.org/MPL/
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011:         * License for the specific language governing rights and limitations under
012:         * the License.
013:         *
014:         * The Original Code is ICEfaces 1.5 open source software code, released
015:         * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016:         * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017:         * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018:         *
019:         * Contributor(s): _____________________.
020:         *
021:         * Alternatively, the contents of this file may be used under the terms of
022:         * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023:         * License), in which case the provisions of the LGPL License are
024:         * applicable instead of those above. If you wish to allow use of your
025:         * version of this file only under the terms of the LGPL License and not to
026:         * allow others to use your version of this file under the MPL, indicate
027:         * your decision by deleting the provisions above and replace them with
028:         * the notice and other provisions required by the LGPL License. If you do
029:         * not delete the provisions above, a recipient may use your version of
030:         * this file under either the MPL or the LGPL License."
031:         *
032:         */
033:
034:        package com.icesoft.faces.component.panelpopup;
035:
036:        import com.icesoft.faces.component.ext.renderkit.GroupRenderer;
037:        import com.icesoft.faces.component.ext.taglib.Util;
038:        import com.icesoft.faces.component.util.CustomComponentUtils;
039:        import com.icesoft.faces.context.DOMContext;
040:        import com.icesoft.faces.context.effects.CurrentStyle;
041:        import com.icesoft.faces.context.effects.JavascriptContext;
042:        import com.icesoft.faces.renderkit.dom_html_basic.HTML;
043:        import com.icesoft.faces.renderkit.dom_html_basic.PassThruAttributeRenderer;
044:        import com.icesoft.faces.util.CoreUtils;
045:
046:        import org.apache.commons.logging.Log;
047:        import org.apache.commons.logging.LogFactory;
048:        import org.w3c.dom.Element;
049:        import org.w3c.dom.Node;
050:        import org.w3c.dom.NodeList;
051:
052:        import javax.faces.component.UIComponent;
053:        import javax.faces.context.FacesContext;
054:        import java.io.IOException;
055:
056:        /**
057:         * <p>PanelPopupRenderer is an extension of ICEfaces D2D GroupRenderer
058:         * responsible for rendering the PanelPopup component.</p>
059:         */
060:        public class PanelPopupRenderer extends GroupRenderer {
061:            private static Log log = LogFactory
062:                    .getLog(PanelPopupRenderer.class);
063:
064:            /* (non-Javadoc)
065:             * @see com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer#getRendersChildren()
066:             */
067:            public boolean getRendersChildren() {
068:                return true;
069:            }
070:
071:            /* (non-Javadoc)
072:             * @see com.icesoft.faces.component.ext.renderkit.GroupRenderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
073:             */
074:            public void encodeBegin(FacesContext facesContext,
075:                    UIComponent uiComponent) throws IOException {
076:                validateParameters(facesContext, uiComponent, PanelPopup.class);
077:
078:                String styleClass = (String) uiComponent.getAttributes().get(
079:                        "styleClass");
080:                String headerClass = (String) uiComponent.getAttributes().get(
081:                        "headerClass");
082:                String bodyClass = (String) uiComponent.getAttributes().get(
083:                        "bodyClass");
084:                Boolean resizable = null; // resizable functionality has not been implemented yet.
085:                Boolean modal = (Boolean) uiComponent.getAttributes().get(
086:                        "modal");
087:                if (log.isTraceEnabled()) {
088:                    log.trace("Value of modal is [" + modal + "]");
089:                }
090:                Boolean visible = (Boolean) uiComponent.getAttributes().get(
091:                        "visible");
092:
093:                String dndType = getDndType(uiComponent);
094:
095:                DOMContext domContext = DOMContext.attachDOMContext(
096:                        facesContext, uiComponent);
097:
098:                // initialize DOMContext
099:                PanelPopup panelPopup = (PanelPopup) uiComponent;
100:
101:                String clientId = uiComponent.getClientId(facesContext);
102:
103:                if (!domContext.isInitialized()) {
104:                    Element rootDiv = domContext
105:                            .createRootElement(HTML.DIV_ELEM);
106:                    setRootElementId(facesContext, rootDiv, uiComponent);
107:                    rootDiv.setAttribute(HTML.NAME_ATTR, clientId);
108:                    Element table = domContext.createElement(HTML.TABLE_ELEM);
109:                    table.setAttribute(HTML.CELLPADDING_ATTR, "0");
110:                    table.setAttribute(HTML.CELLSPACING_ATTR, "0");
111:                    table.setAttribute(HTML.WIDTH_ATTR, "100%");
112:
113:                    rootDiv.appendChild(table);
114:                    if (modal != null && modal.booleanValue()) {
115:                        dndType = null;
116:                    }
117:                    // extracted from GroupRenderer encodeBegin
118:                    if (dndType != null) {
119:                        // Drag an drop needs some hidden fields
120:                        Element statusField = createHiddenField(domContext,
121:                                facesContext, uiComponent, STATUS);
122:                        rootDiv.appendChild(statusField);
123:                        Element targetID = createHiddenField(domContext,
124:                                facesContext, uiComponent, DROP);
125:                        rootDiv.appendChild(targetID);
126:                    }
127:                    // Write Modal Javascript so that on refresh it will still be modal.
128:                    String script = modalJavascript(modal, visible,
129:                            facesContext, clientId);
130:                    if (script != null) {
131:                        Element scriptEle = domContext
132:                                .createElement(HTML.SCRIPT_ELEM);
133:                        scriptEle.setAttribute(HTML.SCRIPT_LANGUAGE_ATTR,
134:                                HTML.SCRIPT_LANGUAGE_JAVASCRIPT);
135:                        script = "window.onLoad(function(){" + script + "});";
136:                        Node node = domContext.createTextNode(script);
137:                        scriptEle.appendChild(node);
138:                        rootDiv.appendChild(scriptEle);
139:                    }
140:                }
141:
142:                Element root = (Element) domContext.getRootNode();
143:                String style = ((PanelPopup) uiComponent).getStyle();
144:                if (style != null && style.length() > 0)
145:                    root.setAttribute(HTML.STYLE_ATTR, style);
146:                else
147:                    root.removeAttribute(HTML.STYLE_ATTR);
148:                try {
149:                    root.setAttribute(HTML.CLASS_ATTR, styleClass);
150:                    String script = modalJavascript(modal, visible,
151:                            facesContext, clientId);
152:                    if (script != null) {
153:                        JavascriptContext.addJavascriptCall(facesContext,
154:                                script);
155:                    }
156:                } catch (Exception e) {
157:                    log.error("Error rendering Modal Panel Popup ", e);
158:                }
159:                // get tables , our table is the first and only one
160:                NodeList tables = root.getElementsByTagName(HTML.TABLE_ELEM);
161:                // assumption we want the first table in tables. there should only be one
162:                Element table = (Element) tables.item(0);
163:                // clean out child nodes and build a fresh selectinputdate
164:                DOMContext.removeChildrenByTagName(table, HTML.TR_ELEM);
165:
166:                PassThruAttributeRenderer.renderAttributes(facesContext,
167:                        uiComponent, null);
168:                String handleId = null;
169:                if (panelPopup.getHeader() != null) {
170:                    Element headerTr = domContext.createElement(HTML.TR_ELEM);
171:                    Element headerTd = domContext.createElement(HTML.TD_ELEM);
172:                    headerTd.setAttribute(HTML.CLASS_ATTR, headerClass);
173:                    handleId = uiComponent.getClientId(facesContext) + "Handle";
174:                    headerTd.setAttribute(HTML.ID_ATTR, handleId);
175:                    headerTr.appendChild(headerTd);
176:                    // add header facet to header tr and add to table
177:                    table.appendChild(headerTr);
178:                    // set the cursor parent to the new table row Element
179:                    // to the new table row Element
180:                    domContext.setCursorParent(headerTd);
181:
182:                    UIComponent header = panelPopup.getHeader();
183:
184:                    domContext.streamWrite(facesContext, uiComponent,
185:                            domContext.getRootNode(), headerTd);
186:
187:                    CustomComponentUtils.renderChild(facesContext, header);
188:                }
189:
190:                if (panelPopup.getBody() != null) {
191:
192:                    Element bodyTr = domContext.createElement(HTML.TR_ELEM);
193:                    Element bodyTd = domContext.createElement(HTML.TD_ELEM);
194:
195:                    bodyTd.setAttribute(HTML.CLASS_ATTR, bodyClass);
196:                    bodyTr.appendChild(bodyTd);
197:                    // add body facet to body tr then add to table
198:                    table.appendChild(bodyTr);
199:                    // set the cursor parent to the new table row Element
200:                    // this will cause the renderChild method to append the child nodes
201:                    // to the new table row Element
202:                    domContext.setCursorParent(bodyTd);
203:
204:                    UIComponent body = panelPopup.getBody();
205:
206:                    domContext.streamWrite(facesContext, uiComponent,
207:                            domContext.getRootNode(), bodyTd);
208:
209:                    CustomComponentUtils.renderChild(facesContext, body);
210:                }
211:                // if the popup is resizable render a resize handle
212:                if (resizable != null && resizable.booleanValue()) {
213:                    Element footerTr = domContext.createElement(HTML.TR_ELEM);
214:                    footerTr.setAttribute(HTML.HEIGHT_ATTR, "15px");
215:                    footerTr.setAttribute(HTML.STYLE_ATTR,
216:                            "text-align: right; float: right;");
217:                    Element footerTd = domContext.createElement(HTML.TD_ELEM);
218:                    footerTd.setAttribute(HTML.STYLE_CLASS_ATTR,
219:                            "panelPopupFooter");
220:                    Element img = domContext.createElement(HTML.IMG_ELEM);
221:                    img.setAttribute(HTML.SRC_ATTR, CoreUtils
222:                            .resolveResourceURL(facesContext,
223:                                    "/xmlhttp/css/xp/css-images/resize.gif"));
224:                    img.setAttribute(HTML.STYLE_ATTR, "cursor: se-resize");
225:                    footerTd.appendChild(img);
226:                    footerTr.appendChild(footerTd);
227:                    table.appendChild(footerTr);
228:                }
229:
230:                domContext.stepOver();
231:                domContext.streamWrite(facesContext, uiComponent);
232:                CurrentStyle.apply(facesContext, uiComponent);
233:                // Rebroadcast Javascript to survive refresh
234:                if (dndType != null) {
235:                    addJavascriptCalls(uiComponent, "DRAG", handleId,
236:                            facesContext);
237:                }
238:            }
239:
240:            private String modalJavascript(Boolean modal, Boolean visible,
241:                    FacesContext facesContext, String clientId) {
242:                String call = null;
243:                if (modal != null) {
244:                    if (modal.booleanValue() && visible.booleanValue()) {
245:                        call = "Ice.modal.start('" + clientId + "');";
246:                        if (log.isTraceEnabled()) {
247:                            log.trace("Starting Modal Function");
248:                        }
249:                    } else {
250:                        call = "Ice.modal.stop('" + clientId + "');";
251:                        if (log.isTraceEnabled()) {
252:                            log.trace("Stopping modal function");
253:                        }
254:                    }
255:                }
256:                return call;
257:            }
258:
259:            /* (non-Javadoc)
260:             * @see com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
261:             */
262:            public void encodeChildren(FacesContext facesContext,
263:                    UIComponent uiComponent) throws IOException {
264:            }
265:
266:            /* (non-Javadoc)
267:             * @see com.icesoft.faces.component.ext.renderkit.GroupRenderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
268:             */
269:            public void encodeEnd(FacesContext facesContext,
270:                    UIComponent uiComponent) throws IOException {
271:                if (log.isTraceEnabled()) {
272:                    log.trace("Encode End Called");
273:                }
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.