Source Code Cross Referenced for TableActionsRenderer.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 com.sun.rave.web.ui.component.Table;
044:        import com.sun.rave.web.ui.component.TableActions;
045:        import com.sun.rave.web.ui.component.TableRowGroup;
046:        import com.sun.rave.web.ui.theme.Theme;
047:        import com.sun.rave.web.ui.theme.ThemeStyles;
048:        import com.sun.rave.web.ui.util.LogUtil;
049:        import com.sun.rave.web.ui.util.RenderingUtilities;
050:        import com.sun.rave.web.ui.util.ThemeUtilities;
051:
052:        import java.io.IOException;
053:
054:        import javax.faces.component.UIComponent;
055:        import javax.faces.context.FacesContext;
056:        import javax.faces.context.ResponseWriter;
057:        import javax.faces.render.Renderer;
058:
059:        /**
060:         * This class renders TableActions components.
061:         * <p>
062:         * Note: To see the messages logged by this class, set the following global
063:         * defaults in your JDK's "jre/lib/logging.properties" file.
064:         * </p><p><pre>
065:         * java.util.logging.ConsoleHandler.level = FINE
066:         * com.sun.rave.web.ui.renderer.TableActionsRenderer.level = FINE
067:         * </pre></p>
068:         */
069:        public class TableActionsRenderer extends Renderer {
070:            /**
071:             * The set of String pass-through attributes to be rendered.
072:             * <p>
073:             * Note: The WIDTH, HEIGHT, and BGCOLOR attributes are all deprecated (in
074:             * the HTML 4.0 spec) in favor of style sheets. In addition, the DIR and 
075:             * LANG attributes are not cuurently supported.
076:             * </p>
077:             */
078:            private static final String stringAttributes[] = { "abbr", //NOI18N
079:                    "align", //NOI18N
080:                    "axis", //NOI18N
081:                    "bgColor", //NOI18N
082:                    "char", //NOI18N
083:                    "charOff", //NOI18N
084:                    "dir", //NOI18N
085:                    "headers", //NOI18N
086:                    "height", //NOI18N
087:                    "lang", //NOI18N
088:                    "onClick", //NOI18N
089:                    "onDblClick", //NOI18N
090:                    "onKeyDown", //NOI18N
091:                    "onKeyPress", //NOI18N
092:                    "onKeyUp", //NOI18N
093:                    "onMouseDown", //NOI18N
094:                    "onMouseUp", //NOI18N
095:                    "onMouseMove", //NOI18N
096:                    "onMouseOut", //NOI18N
097:                    "onMouseOver", //NOI18N
098:                    "style", //NOI18N
099:                    "valign", //NOI18N
100:                    "width" }; //NOI18N
101:
102:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103:            // Renderer methods
104:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105:
106:            /**
107:             * Render the beginning of the specified UIComponent to the output stream or 
108:             * writer associated with the response we are creating.
109:             *
110:             * @param context FacesContext for the current request.
111:             * @param component UIComponent to be rendered.
112:             *
113:             * @exception IOException if an input/output error occurs.
114:             * @exception NullPointerException if context or component is null.
115:             */
116:            public void encodeBegin(FacesContext context, UIComponent component)
117:                    throws IOException {
118:                if (context == null || component == null) {
119:                    log("encodeBegin", //NOI18N
120:                            "Cannot render, FacesContext or UIComponent is null"); //NOI18N
121:                    throw new NullPointerException();
122:                }
123:                if (!component.isRendered()) {
124:                    log("encodeBegin",
125:                            "Component not rendered, nothing to display"); //NOI18N
126:                    return;
127:                }
128:
129:                TableActions action = (TableActions) component;
130:                ResponseWriter writer = context.getResponseWriter();
131:                renderEnclosingTagStart(context, action, writer);
132:            }
133:
134:            /**
135:             * Render the children of the specified UIComponent to the output stream or
136:             * writer associated with the response we are creating.
137:             *
138:             * @param context FacesContext for the current request.
139:             * @param component UIComponent to be decoded.
140:             *
141:             * @exception IOException if an input/output error occurs.
142:             * @exception NullPointerException if context or component is null.
143:             */
144:            public void encodeChildren(FacesContext context,
145:                    UIComponent component) throws IOException {
146:                if (context == null || component == null) {
147:                    log("encodeChildren", //NOI18N
148:                            "Cannot render, FacesContext or UIComponent is null"); //NOI18N
149:                    throw new NullPointerException();
150:                }
151:                if (!component.isRendered()) {
152:                    log("encodeChildren",
153:                            "Component not rendered, nothing to display"); //NOI18N
154:                    return;
155:                }
156:
157:                TableActions action = (TableActions) component;
158:                ResponseWriter writer = context.getResponseWriter();
159:
160:                // Render actions.
161:                if (action.isActionsBottom()) {
162:                    renderActionsBottom(context, action, writer);
163:                } else {
164:                    renderActionsTop(context, action, writer);
165:                }
166:            }
167:
168:            /**
169:             * Render the ending of the specified UIComponent to the output stream or 
170:             * writer associated with the response we are creating.
171:             *
172:             * @param context FacesContext for the current request.
173:             * @param component UIComponent to be rendered.
174:             *
175:             * @exception IOException if an input/output error occurs.
176:             * @exception NullPointerException if context or component is null.
177:             */
178:            public void encodeEnd(FacesContext context, UIComponent component)
179:                    throws IOException {
180:                if (context == null || component == null) {
181:                    log("encodeEnd", //NOI18N
182:                            "Cannot render, FacesContext or UIComponent is null"); //NOI18N
183:                    throw new NullPointerException();
184:                }
185:                if (!component.isRendered()) {
186:                    log("encodeEnd",
187:                            "Component not rendered, nothing to display"); //NOI18N
188:                    return;
189:                }
190:
191:                TableActions action = (TableActions) component;
192:                ResponseWriter writer = context.getResponseWriter();
193:                renderEnclosingTagEnd(context, action, writer);
194:            }
195:
196:            /**
197:             * Return a flag indicating whether this Renderer is responsible
198:             * for rendering the children the component it is asked to render.
199:             * The default implementation returns false.
200:             */
201:            public boolean getRendersChildren() {
202:                return true;
203:            }
204:
205:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
206:            // Action methods
207:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208:
209:            /**
210:             * Render the top actions for TableActions components.
211:             *
212:             * @param context FacesContext for the current request.
213:             * @param component TableActions to be rendered.
214:             * @param writer ResponseWriter to which the component should be rendered.
215:             *
216:             * @exception IOException if an input/output error occurs.
217:             */
218:            protected void renderActionsTop(FacesContext context,
219:                    TableActions component, ResponseWriter writer)
220:                    throws IOException {
221:                Table table = (component != null) ? component
222:                        .getTableAncestor() : null;
223:                if (table == null) {
224:                    log("renderActionsTop",
225:                            "Cannot render actions bar, Table is null"); //NOI18N
226:                    return;
227:                }
228:
229:                // We must determine if all TableRowGroup components are empty. Controls
230:                // are only hidden when all row groups are empty. Likewise, pagination
231:                // controls are only hidden when all groups fit on a single page.
232:                int totalRows = table.getRowCount();
233:                boolean emptyTable = (totalRows == 0);
234:                boolean singleRow = (totalRows == 1);
235:                boolean singlePage = (totalRows < table.getRows());
236:
237:                // Get facets.
238:                UIComponent actions = table.getFacet(Table.ACTIONS_TOP_FACET);
239:                UIComponent filter = table.getFacet(Table.FILTER_FACET);
240:                UIComponent sort = table.getFacet(Table.SORT_PANEL_FACET);
241:                UIComponent prefs = table
242:                        .getFacet(Table.PREFERENCES_PANEL_FACET);
243:
244:                // Flags indicating which facets to render.
245:                boolean renderActions = actions != null && actions.isRendered();
246:                boolean renderFilter = filter != null && filter.isRendered();
247:                boolean renderSort = sort != null && sort.isRendered();
248:                boolean renderPrefs = prefs != null && prefs.isRendered();
249:
250:                // Hide sorting and pagination controls for an empty table or when there
251:                // is only a single row.
252:                boolean renderSelectMultipleButton = !emptyTable
253:                        && table.isSelectMultipleButton();
254:                boolean renderDeselectMultipleButton = !emptyTable
255:                        && table.isDeselectMultipleButton();
256:                boolean renderDeselectSingleButton = !emptyTable
257:                        && table.isDeselectSingleButton();
258:                boolean renderClearTableSortButton = !emptyTable && !singleRow
259:                        && table.isClearSortButton();
260:                boolean renderTableSortPanelToggleButton = !emptyTable
261:                        && !singleRow
262:                        && (table.isSortPanelToggleButton() || renderSort);
263:                boolean renderPaginateButton = !emptyTable && !singlePage
264:                        && table.isPaginateButton();
265:
266:                // Return if nothing is rendered.
267:                if (!(renderActions || renderFilter || renderPrefs
268:                        || renderSelectMultipleButton
269:                        || renderDeselectMultipleButton
270:                        || renderDeselectSingleButton
271:                        || renderClearTableSortButton
272:                        || renderTableSortPanelToggleButton || renderPaginateButton)) {
273:                    log("renderActionsTop", //NOI18N
274:                            "Actions bar not rendered, nothing to display"); //NOI18N
275:                    return;
276:                }
277:
278:                // Render select multiple button.
279:                if (renderSelectMultipleButton) {
280:                    writer.writeText("\n", null); //NOI18N
281:                    RenderingUtilities.renderComponent(component
282:                            .getSelectMultipleButton(), context);
283:                }
284:
285:                // Render deselect multiple button.
286:                if (renderDeselectMultipleButton) {
287:                    writer.writeText("\n", null); //NOI18N
288:                    RenderingUtilities.renderComponent(component
289:                            .getDeselectMultipleButton(), context);
290:                }
291:
292:                // Render deselect single button.
293:                if (renderDeselectSingleButton) {
294:                    writer.writeText("\n", null); //NOI18N
295:                    RenderingUtilities.renderComponent(component
296:                            .getDeselectSingleButton(), context);
297:                }
298:
299:                // Render actions facet.
300:                if (renderActions) {
301:                    // Render action separator.
302:                    if (renderSelectMultipleButton
303:                            || renderDeselectMultipleButton
304:                            || renderDeselectSingleButton) {
305:                        writer.writeText("\n", null); //NOI18N
306:                        RenderingUtilities.renderComponent(component
307:                                .getActionsSeparatorIcon(), context);
308:                    }
309:                    writer.writeText("\n", null); //NOI18N
310:                    RenderingUtilities.renderComponent(actions, context);
311:                }
312:
313:                // Render filter facet.
314:                if (renderFilter) {
315:                    // Render filter separator.
316:                    if (renderActions || renderSelectMultipleButton
317:                            || renderDeselectMultipleButton
318:                            || renderDeselectSingleButton) {
319:                        writer.writeText("\n", null); //NOI18N
320:                        RenderingUtilities.renderComponent(component
321:                                .getFilterSeparatorIcon(), context);
322:                    }
323:
324:                    writer.writeText("\n", null); //NOI18N
325:                    RenderingUtilities.renderComponent(component
326:                            .getFilterLabel(), context);
327:                    writer.writeText("\n", null); //NOI18N
328:                    RenderingUtilities.renderComponent(filter, context);
329:                }
330:
331:                // Render view action separator.
332:                if ((renderActions || renderFilter
333:                        || renderSelectMultipleButton
334:                        || renderDeselectMultipleButton || renderDeselectSingleButton)
335:                        && (renderPrefs || renderClearTableSortButton || renderTableSortPanelToggleButton)) {
336:                    writer.writeText("\n", null); //NOI18N
337:                    RenderingUtilities.renderComponent(component
338:                            .getViewActionsSeparatorIcon(), context);
339:                }
340:
341:                // Render table sort panel toggle button.
342:                if (renderTableSortPanelToggleButton) {
343:                    writer.writeText("\n", null); //NOI18N
344:                    UIComponent child = component.getSortPanelToggleButton();
345:                    RenderingUtilities.renderComponent(child, context);
346:                }
347:
348:                // Render clear sort button.
349:                if (renderClearTableSortButton) {
350:                    writer.writeText("\n", null); //NOI18N
351:                    RenderingUtilities.renderComponent(component
352:                            .getClearSortButton(), context);
353:                }
354:
355:                // Render table preferences panel toggle button.
356:                if (renderPrefs) {
357:                    writer.writeText("\n", null); //NOI18N
358:                    RenderingUtilities.renderComponent(component
359:                            .getPreferencesPanelToggleButton(), context);
360:                }
361:
362:                // Render paginate button.
363:                if (renderPaginateButton) {
364:                    // Render separator.
365:                    if (renderActions || renderFilter || renderPrefs
366:                            || renderSelectMultipleButton
367:                            || renderDeselectMultipleButton
368:                            || renderDeselectSingleButton
369:                            || renderClearTableSortButton
370:                            || renderTableSortPanelToggleButton) {
371:                        writer.writeText("\n", null); //NOI18N
372:                        RenderingUtilities.renderComponent(component
373:                                .getPaginateSeparatorIcon(), context);
374:                    }
375:                    writer.writeText("\n", null); //NOI18N
376:                    RenderingUtilities.renderComponent(component
377:                            .getPaginateButton(), context);
378:                }
379:            }
380:
381:            /**
382:             * Render the bottom actions for TableActions components.
383:             *
384:             * @param context FacesContext for the current request.
385:             * @param component TableActions to be rendered.
386:             * @param writer ResponseWriter to which the component should be rendered.
387:             *
388:             * @exception IOException if an input/output error occurs.
389:             */
390:            protected void renderActionsBottom(FacesContext context,
391:                    TableActions component, ResponseWriter writer)
392:                    throws IOException {
393:                Table table = (component != null) ? component
394:                        .getTableAncestor() : null;
395:                if (table == null) {
396:                    log("renderActionsBottom", //NOI18N
397:                            "Cannot render actions bar, Table is null"); //NOI18N
398:                    return;
399:                }
400:
401:                // We must determine if all TableRowGroup components are empty. Controls
402:                // are only hidden when all row groups are empty. Likewise, pagination
403:                // controls are only hidden when all groups fit on a single page.
404:                int totalRows = table.getRowCount();
405:                boolean emptyTable = (totalRows == 0);
406:                boolean singleRow = (totalRows == 1);
407:                boolean singlePage = (totalRows < table.getRows());
408:
409:                // Get facets.
410:                UIComponent actions = table
411:                        .getFacet(Table.ACTIONS_BOTTOM_FACET);
412:
413:                // Get flag indicating which facets to render.
414:                boolean renderActions = !emptyTable && !singleRow
415:                        && actions != null && actions.isRendered();
416:
417:                // Hide pagination controls when all rows fit on a page.
418:                boolean renderPaginationControls = !emptyTable && !singlePage
419:                        && table.isPaginationControls();
420:
421:                // Hide paginate button for a single row.
422:                boolean renderPaginateButton = !emptyTable && !singlePage
423:                        && table.isPaginateButton();
424:
425:                // Render table actions facet.
426:                if (renderActions) {
427:                    writer.writeText("\n", null); //NOI18N
428:                    RenderingUtilities.renderComponent(actions, context);
429:                }
430:
431:                // Render actions separator.
432:                if (renderPaginationControls || renderPaginateButton) {
433:                    // Render actions separator.
434:                    if (renderActions) {
435:                        writer.writeText("\n", null); //NOI18N
436:                        RenderingUtilities.renderComponent(component
437:                                .getActionsSeparatorIcon(), context);
438:                    }
439:                }
440:
441:                // Render pagination controls.
442:                if (renderPaginationControls) {
443:                    // Get TableRowGroup component.
444:                    TableRowGroup group = table.getTableRowGroupChild();
445:                    boolean paginated = (group != null) ? group.isPaginated()
446:                            : false;
447:
448:                    // Do not display controls while in scroll mode.
449:                    if (paginated) {
450:                        renderPagination(context, component, writer);
451:                    }
452:                }
453:
454:                // Render paginate button.
455:                if (renderPaginateButton) {
456:                    writer.writeText("\n", null); //NOI18N
457:                    RenderingUtilities.renderComponent(component
458:                            .getPaginateButton(), context);
459:                }
460:            }
461:
462:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
463:            // Enclosing tag methods
464:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465:
466:            /**
467:             * Render enclosing tag for TableActions components.
468:             *
469:             * @param context FacesContext for the current request.
470:             * @param component TableActions to be rendered.
471:             * @param writer ResponseWriter to which the component should be rendered.
472:             *
473:             * @exception IOException if an input/output error occurs.
474:             */
475:            protected void renderEnclosingTagStart(FacesContext context,
476:                    TableActions component, ResponseWriter writer)
477:                    throws IOException {
478:                if (component == null) {
479:                    log("renderEnclosingTagStart", //NOI18N
480:                            "Cannot render enclosing tag, TableActions is null"); //NOI18N
481:                    return;
482:                }
483:
484:                writer.writeText("\n", null); //NOI18N
485:                writer.startElement("td", component); //NOI18N
486:                writer.writeAttribute("id", component.getClientId(context),
487:                        null); //NOI18N
488:
489:                // Render style class.
490:                String extraHtml = RenderingUtilities.renderStyleClass(context,
491:                        writer, component, getStyleClass(component), component
492:                                .getExtraHtml());
493:
494:                // Render colspan.
495:                if (component.getColSpan() > -1
496:                        && (extraHtml == null || extraHtml.indexOf("colspan=") == -1)) { //NOI18N
497:                    writer.writeAttribute("colspan", //NOI18N
498:                            Integer.toString(component.getColSpan()), null); //NOI18N
499:                }
500:
501:                // Render rowspan.
502:                if (component.getRowSpan() > -1
503:                        && (extraHtml == null || extraHtml.indexOf("rowspan=") == -1)) { //NOI18N
504:                    writer.writeAttribute("rowspan", //NOI18N
505:                            Integer.toString(component.getRowSpan()), null); //NOI18N
506:                }
507:
508:                // Render nowrap.
509:                if (component.isNoWrap()
510:                        && (extraHtml == null || extraHtml.indexOf("nowrap=") == -1)) { //NOI18N
511:                    writer.writeAttribute("nowrap", "nowrap", null); //NOI18N
512:                }
513:
514:                // Render tooltip.
515:                if (component.getToolTip() != null
516:                        && (extraHtml == null || extraHtml.indexOf("title=") == -1)) { //NOI18N
517:                    writer.writeAttribute("title", component.getToolTip(),
518:                            "toolTip"); //NOI18N
519:                }
520:
521:                // Render pass through attributes.
522:                RenderingUtilities.writeStringAttributes(component, writer,
523:                        stringAttributes, extraHtml);
524:            }
525:
526:            /**
527:             * Render enclosing tag for TableActions components.
528:             *
529:             * @param context FacesContext for the current request.
530:             * @param component TableActions to be rendered.
531:             * @param writer ResponseWriter to which the component should be rendered.
532:             *
533:             * @exception IOException if an input/output error occurs.
534:             */
535:            protected void renderEnclosingTagEnd(FacesContext context,
536:                    TableActions component, ResponseWriter writer)
537:                    throws IOException {
538:                if (component == null) {
539:                    log("renderEnclosingTagEnd", //NOI18N
540:                            "Cannot render enclosing tag, TableActions is null"); //NOI18N
541:                    return;
542:                }
543:                writer.endElement("td"); //NOI18N
544:            }
545:
546:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
547:            // Private methods
548:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
549:
550:            /**
551:             * Helper method to get style class for TableActions components.
552:             *
553:             * @param component TableActions to be rendered
554:             * @return The style class.
555:             */
556:            private String getStyleClass(TableActions component) {
557:                String styleClass = null;
558:                if (component == null) {
559:                    log("getStyleClass", //NOI18N
560:                            "Cannot obtain style class, TableActions is null"); //NOI18N
561:                    return styleClass;
562:                }
563:
564:                // Get style class.
565:                if (component.isActionsBottom()) {
566:                    styleClass = ThemeStyles.TABLE_ACTION_TD_LASTROW;
567:                } else {
568:                    styleClass = ThemeStyles.TABLE_ACTION_TD;
569:                }
570:                return getTheme().getStyleClass(styleClass);
571:            }
572:
573:            /** Helper method to get Theme objects. */
574:            private Theme getTheme() {
575:                return ThemeUtilities.getTheme(FacesContext
576:                        .getCurrentInstance());
577:            }
578:
579:            /**
580:             * Log fine messages.
581:             */
582:            private void log(String method, String message) {
583:                // Get class.
584:                Class clazz = this .getClass();
585:                if (LogUtil.fineEnabled(clazz)) {
586:                    // Log method name and message.
587:                    LogUtil.fine(clazz, clazz.getName() + "." + method + ": "
588:                            + message); //NOI18N
589:                }
590:            }
591:
592:            /**
593:             * Render the pagination controls for TableActions components. This does
594:             * not include the paginate button.
595:             *
596:             * @param context FacesContext for the current request.
597:             * @param component TableActions to be rendered.
598:             * @param writer ResponseWriter to which the component should be rendered.
599:             *
600:             * @exception IOException if an input/output error occurs.
601:             */
602:            private void renderPagination(FacesContext context,
603:                    TableActions component, ResponseWriter writer)
604:                    throws IOException {
605:                if (component == null) {
606:                    log("renderPagination", //NOI18N
607:                            "Cannot render pagination controls, TableActions is null"); //NOI18N
608:                    return;
609:                }
610:
611:                Theme theme = getTheme();
612:
613:                // Render span for left-side buttons.
614:                writer.writeText("\n", null); //NOI18N
615:                writer.startElement("span", component); //NOI18N
616:                writer.writeAttribute("class", theme.getStyleClass( //NOI18N
617:                        ThemeStyles.TABLE_PAGINATION_LEFT_BUTTON), null);
618:
619:                // Render first button.
620:                writer.writeText("\n", null); //NOI18N
621:                RenderingUtilities.renderComponent(component
622:                        .getPaginationFirstButton(), context);
623:
624:                // Render prev button.
625:                writer.writeText("\n", null); //NOI18N
626:                RenderingUtilities.renderComponent(component
627:                        .getPaginationPrevButton(), context);
628:                writer.endElement("span"); //NOI18N
629:
630:                // Render span for label.
631:                writer.writeText("\n", null); //NOI18N
632:                writer.startElement("span", component); //NOI18N
633:                writer.writeAttribute("class", theme.getStyleClass( //NOI18N
634:                        ThemeStyles.TABLE_PAGINATION_TEXT_BOLD), null);
635:
636:                // Render page field.
637:                writer.writeText("\n", null); //NOI18N
638:                RenderingUtilities.renderComponent(component
639:                        .getPaginationPageField(), context);
640:                writer.endElement("span"); //NOI18N
641:
642:                // Render total pages text.
643:                writer.writeText("\n", null); //NOI18N
644:                RenderingUtilities.renderComponent(component
645:                        .getPaginationPagesText(), context);
646:
647:                // Render span for submit button.
648:                writer.writeText("\n", null); //NOI18N
649:                writer.startElement("span", component); //NOI18N
650:                writer.writeAttribute("class", theme.getStyleClass( //NOI18N
651:                        ThemeStyles.TABLE_PAGINATION_SUBMIT_BUTTON), null); //NOI18N
652:
653:                // Render submit button.
654:                writer.writeText("\n", null); //NOI18N
655:                RenderingUtilities.renderComponent(component
656:                        .getPaginationSubmitButton(), context);
657:                writer.endElement("span"); //NOI18N
658:
659:                // Render span for right-side buttons.
660:                writer.writeText("\n", null); //NOI18N
661:                writer.startElement("span", component); //NOI18N
662:                writer.writeAttribute("class", theme.getStyleClass( //NOI18N
663:                        ThemeStyles.TABLE_PAGINATION_RIGHT_BUTTON), null);
664:
665:                // Render next button.
666:                writer.writeText("\n", null); //NOI18N
667:                RenderingUtilities.renderComponent(component
668:                        .getPaginationNextButton(), context);
669:
670:                // Render last button.
671:                writer.writeText("\n", null); //NOI18N
672:                RenderingUtilities.renderComponent(component
673:                        .getPaginationLastButton(), context);
674:                writer.endElement("span"); //NOI18N
675:            }
676:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.