Source Code Cross Referenced for DojoMenuItem.java in  » J2EE » fleXive » com » flexive » faces » components » menu » 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 » fleXive » com.flexive.faces.components.menu 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***************************************************************
002:         *  This file is part of the [fleXive](R) project.
003:         *
004:         *  Copyright (c) 1999-2007
005:         *  UCS - unique computing solutions gmbh (http://www.ucs.at)
006:         *  All rights reserved
007:         *
008:         *  The [fleXive](R) project is free software; you can redistribute
009:         *  it and/or modify it under the terms of the GNU General Public
010:         *  License as published by the Free Software Foundation;
011:         *  either version 2 of the License, or (at your option) any
012:         *  later version.
013:         *
014:         *  The GNU General Public License can be found at
015:         *  http://www.gnu.org/copyleft/gpl.html.
016:         *  A copy is found in the textfile GPL.txt and important notices to the
017:         *  license from the author are found in LICENSE.txt distributed with
018:         *  these libraries.
019:         *
020:         *  This library is distributed in the hope that it will be useful,
021:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
022:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023:         *  GNU General Public License for more details.
024:         *
025:         *  For further information about UCS - unique computing solutions gmbh,
026:         *  please see the company website: http://www.ucs.at
027:         *
028:         *  For further information about [fleXive](R), please see the
029:         *  project website: http://www.flexive.org
030:         *
031:         *
032:         *  This copyright notice MUST APPEAR in all copies of the file!
033:         ***************************************************************/package com.flexive.faces.components.menu;
034:
035:        import com.flexive.faces.FxJsfComponentUtils;
036:        import com.flexive.faces.FxJsfUtils;
037:        import com.flexive.faces.javascript.menu.MenuItem;
038:        import com.flexive.faces.javascript.menu.MenuItemContainer;
039:
040:        import javax.faces.component.UIOutput;
041:        import javax.faces.context.FacesContext;
042:        import java.io.IOException;
043:        import java.util.ArrayList;
044:        import java.util.HashMap;
045:        import java.util.List;
046:        import java.util.Map;
047:
048:        /**
049:         * Adds a dojo menu item to the enclosing Dojo menu container. DojoMenuItems
050:         * can be nested to create submenus, i.e. a DojoMenuItem is an item container
051:         * like DojoMenu itself.
052:         *
053:         * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
054:         * @version $Rev: 1 $
055:         * @see DojoMenu
056:         */
057:        public class DojoMenuItem extends UIOutput implements  MenuItemContainer {
058:            private final List<MenuItem> menuItems = new ArrayList<MenuItem>();
059:            private String labelKey;
060:            private String label;
061:            private String icon;
062:            private String clickHandler;
063:            private String link;
064:            private Map<String, Object> itemProperties;
065:
066:            public DojoMenuItem() {
067:                setRendererType(null);
068:            }
069:
070:            /**
071:             * {@inheritDoc}
072:             */
073:            @Override
074:            public void encodeBegin(FacesContext facesContext)
075:                    throws IOException {
076:                MenuItemContainer container = FxJsfUtils.findAncestor(this ,
077:                        MenuItemContainer.class);
078:                String itemLabel = getLabel() != null ? getLabel() : FxJsfUtils
079:                        .getLocalizedMessage(getLabelKey());
080:                // create an item that also includes nested menu items (added in the body of this component)
081:                MenuItem item = new MenuItem(getClientId(facesContext),
082:                        itemLabel, getIcon(), getClickHandler(),
083:                        getItemProperties(), getMenuItems());
084:                container.addMenuItem(item);
085:            }
086:
087:            /**
088:             * Return the new menu item's properties.
089:             *
090:             * @return the new menu item's properties
091:             */
092:            protected Map<String, Object> getItemProperties() {
093:                if (itemProperties == null) {
094:                    itemProperties = new HashMap<String, Object>();
095:                }
096:                return itemProperties;
097:            }
098:
099:            /**
100:             * {@inheritDoc}
101:             */
102:            public void addMenuItem(MenuItem menuItem) {
103:                menuItems.add(menuItem);
104:            }
105:
106:            /**
107:             * {@inheritDoc}
108:             */
109:            public List<MenuItem> getMenuItems() {
110:                return menuItems;
111:            }
112:
113:            public String getLabelKey() {
114:                if (labelKey == null) {
115:                    labelKey = FxJsfComponentUtils.getStringValue(this ,
116:                            "labelKey");
117:                }
118:                return labelKey;
119:            }
120:
121:            public void setLabelKey(String labelKey) {
122:                this .labelKey = labelKey;
123:            }
124:
125:            public String getIcon() {
126:                if (icon == null) {
127:                    icon = FxJsfComponentUtils.getStringValue(this , "icon");
128:                }
129:                return icon;
130:            }
131:
132:            public void setIcon(String icon) {
133:                this .icon = icon;
134:            }
135:
136:            public String getClickHandler() {
137:                if (clickHandler == null) {
138:                    clickHandler = FxJsfComponentUtils.getStringValue(this ,
139:                            "clickHandler");
140:                }
141:                if (clickHandler == null && getLink() != null) {
142:                    clickHandler = "function(menuItem) { loadContentPage('"
143:                            + getLink() + "'); }";
144:                }
145:                return clickHandler;
146:            }
147:
148:            public void setClickHandler(String clickHandler) {
149:                this .clickHandler = clickHandler;
150:            }
151:
152:            public String getLabel() {
153:                if (label == null) {
154:                    label = FxJsfComponentUtils.getStringValue(this , "label");
155:                }
156:                return label;
157:            }
158:
159:            public void setLabel(String label) {
160:                this .label = label;
161:            }
162:
163:            public String getLink() {
164:                if (link == null) {
165:                    link = FxJsfComponentUtils.getStringValue(this , "link");
166:                }
167:                return link;
168:            }
169:
170:            public void setLink(String link) {
171:                this .link = link;
172:            }
173:
174:            /**
175:             * {@inheritDoc}
176:             */
177:            @Override
178:            public Object saveState(FacesContext facesContext) {
179:                Object[] state = new Object[6];
180:                state[0] = super .saveState(facesContext);
181:                state[1] = clickHandler;
182:                state[2] = icon;
183:                state[3] = label;
184:                state[4] = labelKey;
185:                state[5] = link;
186:                return state;
187:            }
188:
189:            /**
190:             * {@inheritDoc}
191:             */
192:            @Override
193:            public void restoreState(FacesContext facesContext, Object o) {
194:                Object[] state = (Object[]) o;
195:                super .restoreState(facesContext, state[0]);
196:                clickHandler = (String) state[1];
197:                icon = (String) state[2];
198:                label = (String) state[3];
199:                labelKey = (String) state[4];
200:                link = (String) state[5];
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.