Source Code Cross Referenced for PageAlertRenderer.java in  » IDE-Netbeans » visualweb.api.designer » com » sun » rave » web » ui » renderer » 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 » IDE Netbeans » visualweb.api.designer » com.sun.rave.web.ui.renderer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package com.sun.rave.web.ui.renderer;
042:
043:        import java.io.IOException;
044:
045:        import javax.faces.component.UIComponent;
046:        import javax.faces.context.FacesContext;
047:        import javax.faces.context.ResponseWriter;
048:        import com.sun.rave.web.ui.component.PageAlert;
049:        import com.sun.rave.web.ui.component.PageSeparator;
050:        import com.sun.rave.web.ui.theme.Theme;
051:        import com.sun.rave.web.ui.theme.ThemeStyles;
052:        import com.sun.rave.web.ui.util.RenderingUtilities;
053:        import com.sun.rave.web.ui.util.ThemeUtilities;
054:
055:        /**
056:         * <p>Renders a full page alert.</p>
057:         */
058:        public class PageAlertRenderer extends AbstractRenderer {
059:
060:            /**
061:             * Content Page Title Button facet
062:             */
063:            public static final String PAGETITLE_BUTTON_FACET = "pageButtons"; //NOI18N
064:
065:            /** Creates a new instance of MastheadRenderer */
066:            public PageAlertRenderer() {
067:            }
068:
069:            /**
070:             * Render the full page alert.
071:             * 
072:             * @param context The current FacesContext
073:             * @param component The ImageComponent object to use
074:             * @param writer The current ResponseWriter
075:             *
076:             * @exception IOException if an input/output error occurss
077:             */
078:            protected void renderEnd(FacesContext context,
079:                    UIComponent component, ResponseWriter writer)
080:                    throws IOException {
081:                if (context == null || component == null || writer == null) {
082:                    throw new NullPointerException();
083:                }
084:
085:                PageAlert pagealert = (PageAlert) component;
086:
087:                writer.startElement("div", component); //NO18N
088:
089:                addCoreAttributes(context, component, writer, null);
090:
091:                renderAlert(context, component, writer);
092:                renderSeparator(context, component, writer);
093:                renderButtons(context, component, writer);
094:
095:                writer.endElement("div"); //NOI18N
096:            }
097:
098:            /**
099:             * Renders alert summary message
100:             * 
101:             * @param context The current FacesContext
102:             * @param component The Alert object to use
103:             * @param theme The Theme to use
104:             * @param writer The current ResponseWriter
105:             *
106:             * @exception IOException if an input/output error occurs
107:             */
108:            protected void renderAlertSummary(FacesContext context,
109:                    UIComponent component, Theme theme, ResponseWriter writer)
110:                    throws IOException {
111:
112:                PageAlert pagealert = (PageAlert) component;
113:                String summary = pagealert.getSummary();
114:                // If a summary message is not specified, nothing to render.
115:                if (summary == null || summary.trim().length() == 0)
116:                    return;
117:
118:                writer.startElement("div", pagealert); //NOI18N
119:                // Set the containing div style based on the theme
120:                String style = theme
121:                        .getStyleClass(ThemeStyles.ALERT_HEADER_DIV);
122:                RenderingUtilities.renderStyleClass(context, writer, component,
123:                        style);
124:                writer.startElement("span", pagealert); //NOI18N
125:                style = theme.getStyleClass(ThemeStyles.ALERT_HEADER_TXT);
126:                writer.writeAttribute("class", style, null); //NOI18N
127:
128:                // Check if it the message be HTML escaped (true by default).
129:                if (!pagealert.isEscape()) {
130:                    writer.write(summary);
131:                } else {
132:                    writer.writeText(summary, "summary");
133:                }
134:                // Close the span, div
135:                writer.endElement("span"); //NOI18N	
136:                writer.endElement("div"); //NOI18N
137:
138:                writer.writeText("\n", null); //NOI18N     
139:            }
140:
141:            /**
142:             * Renders detsil summary message
143:             * 
144:             * @param context The current FacesContext
145:             * @param component The Alert object to use
146:             * @param theme The Theme to use
147:             * @param writer The current ResponseWriter
148:             *
149:             * @exception IOException if an input/output error occurs
150:             */
151:            protected void renderAlertDetail(FacesContext context,
152:                    UIComponent component, Theme theme, ResponseWriter writer)
153:                    throws IOException {
154:
155:                PageAlert pagealert = (PageAlert) component;
156:                String detail = pagealert.getDetail();
157:                // If a detail message is not specified, nothing to render.
158:                if (detail == null || detail.trim().length() == 0)
159:                    return;
160:
161:                writer.startElement("div", pagealert); //NOI18N
162:                // Set the containing div style based on the theme
163:                String style = theme
164:                        .getStyleClass(ThemeStyles.ALERT_MESSAGE_DIV);
165:                writer.writeAttribute("class", style, null); //NOI18N
166:                writer.startElement("span", pagealert); //NOI18N
167:                style = theme.getStyleClass(ThemeStyles.ALERT_MESSAGE_TEXT);
168:                writer.writeAttribute("class", style, null); //NOI18N
169:
170:                // Check if it the message be HTML escaped (true by default).
171:                if (!pagealert.isEscape()) {
172:                    writer.write(detail);
173:                } else {
174:                    writer.writeText(detail, "detail");
175:                }
176:                // Close the span, div
177:                writer.endElement("span"); //NOI18N	
178:                writer.endElement("div"); //NOI18N
179:
180:                writer.writeText("\n", null); //NOI18N     
181:            }
182:
183:            /**
184:             * Renders PageAlert Icon
185:             * 
186:             * @param context The current FacesContext
187:             * @param component The Alert object to use
188:             * @param theme The Theme to use
189:             * @param writer The current ResponseWriter
190:             *
191:             * @exception IOException if an input/output error occurs
192:             */
193:            protected void renderAlertIcon(FacesContext context,
194:                    UIComponent component, Theme theme, ResponseWriter writer)
195:                    throws IOException {
196:
197:                PageAlert pagealert = (PageAlert) component;
198:
199:                writer.startElement("table", component); //NOI18N
200:                writer.writeAttribute("title", "", null); //NOI18N
201:                writer.writeAttribute("border", "0", null); //NOI18N
202:                writer.writeAttribute("cellpadding", "0", null); //NOI18N
203:                writer.writeAttribute("cellspacing", "0", null); //NOI18N
204:                writer.writeAttribute("width", "100%", null); //NOI18N
205:                writer.startElement("tbody", component); //NOI18N
206:                writer.startElement("tr", component); //NOI18N
207:                writer.writeAttribute("valign", "bottom", null); //NOI18N
208:                writer.startElement("td", component); //NOI18N
209:                writer.writeAttribute("valign", "bottom", null); //NOI18N
210:                writer.startElement("div", component); //NOI18N
211:
212:                UIComponent titleFacet = pagealert
213:                        .getFacet(pagealert.PAGEALERT_TITLE_FACET);
214:                if (titleFacet == null) {
215:                    String style;
216:                    style = theme.getStyleClass(ThemeStyles.TITLE_TEXT_DIV);
217:                    writer.writeAttribute("class", style, null); //NOI18N           
218:
219:                    writer.startElement("h1", component); //NOI18N
220:                    style = theme.getStyleClass(ThemeStyles.TITLE_TEXT);
221:                    writer.writeAttribute("class", style, null); //NOI18N                 
222:
223:                    // Get the image specified via the type attribute or the image facet.
224:                    UIComponent image = pagealert.getPageAlertImage();
225:                    RenderingUtilities.renderComponent(image, context);
226:
227:                    writer.write(pagealert.getSafeTitle());
228:                    writer.endElement("h1");
229:                } else {
230:                    // Render the title facet
231:                    RenderingUtilities.renderComponent(titleFacet, context);
232:                }
233:
234:                writer.endElement("div"); //NOI18N
235:                writer.endElement("td"); //NOI18N
236:                writer.endElement("tr"); //NOI18N
237:                writer.endElement("tbody"); //NOI18N
238:                writer.endElement("table"); //NOI18N
239:
240:            }
241:
242:            /**
243:             * Renders alert - summary message, detail message and any input 
244:             * components contained in the facet.
245:             * 
246:             * @param context The current FacesContext
247:             * @param component The Alert object to use
248:             * @param writer The current ResponseWriter
249:             *
250:             * @exception IOException if an input/output error occurs
251:             */
252:            protected void renderAlert(FacesContext context,
253:                    UIComponent component, ResponseWriter writer)
254:                    throws IOException {
255:
256:                PageAlert pagealert = (PageAlert) component;
257:                // Get the theme
258:                Theme theme = ThemeUtilities.getTheme(context);
259:                // Render the Alert summary and detail message
260:                renderAlertIcon(context, component, theme, writer);
261:                renderAlertSummary(context, component, theme, writer);
262:                renderAlertDetail(context, component, theme, writer);
263:
264:                // Render any input component specified in a facet.
265:                UIComponent inputComponent = pagealert.getPageAlertInput();
266:
267:                if (inputComponent != null) {
268:                    writer.startElement("div", pagealert); //NOI18N
269:                    // Set the containing div style based on the theme
270:                    String style = theme
271:                            .getStyleClass(ThemeStyles.ALERT_FORM_DIV);
272:                    RenderingUtilities.renderStyleClass(context, writer,
273:                            component, style);
274:                    RenderingUtilities.renderComponent(inputComponent, context);
275:                    writer.endElement("div"); //NOI18N
276:                    writer.writeText("\n", null); //NOI18N     
277:                }
278:            }
279:
280:            private void renderSeparator(FacesContext context,
281:                    UIComponent component, ResponseWriter writer)
282:                    throws IOException {
283:
284:                PageAlert pageAlert = (PageAlert) component;
285:                UIComponent separator = pageAlert.getPageAlertSeparator();
286:                RenderingUtilities.renderComponent(separator, context);
287:            }
288:
289:            private void renderButtons(FacesContext context,
290:                    UIComponent component, ResponseWriter writer)
291:                    throws IOException {
292:
293:                PageAlert pagealert = (PageAlert) component;
294:                UIComponent buttonFacet = pagealert.getPageAlertButtons();
295:
296:                if (buttonFacet == null) {
297:                    return;
298:                }
299:
300:                // Get the theme
301:                Theme theme = ThemeUtilities.getTheme(context);
302:
303:                writer.startElement("table", pagealert);
304:                writer.writeAttribute("border", "0", null); // NOI18N
305:                writer.writeAttribute("width", "100%", null); // NOI18N
306:                writer.writeAttribute("cellpadding", "0", null); // NOI18N
307:                writer.writeAttribute("cellspacing", "0", null); // NOI18N
308:
309:                writer.startElement("tr", pagealert); // NOI18N
310:                String style = theme
311:                        .getStyleClass(ThemeStyles.TITLE_BUTTON_BOTTOM_DIV);
312:
313:                writer.startElement("td", pagealert); // NOI18N
314:                writer.writeAttribute("align", "right", null); // NOI18N
315:                writer.writeAttribute("nowrap", "nowrap", null); // NOI18N
316:                writer.writeAttribute("valign", "bottom", null); // NOI18N
317:
318:                writer.startElement("div", pagealert); // NOI18N
319:                writer.writeAttribute("class", style, null); // NOI18N
320:
321:                RenderingUtilities.renderComponent(buttonFacet, context);
322:
323:                writer.endElement("div"); // NOI18N
324:                writer.endElement("td"); // NOI18N
325:
326:                writer.endElement("tr"); // NOI18N
327:                writer.endElement("table"); // NOI18N
328:            }
329:
330:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.