Source Code Cross Referenced for JsfSampleBean.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » sample » tool » 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 » ERP CRM Financial » sakai » org.sakaiproject.sample.tool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/samples/tags/sakai_2-4-1/sample-tool-jsf/src/java/org/sakaiproject/sample/tool/JsfSampleBean.java $
003:         * $Id: JsfSampleBean.java 17085 2006-10-12 19:38:14Z ggolden@umich.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2005, 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.sample.tool;
021:
022:        import java.util.Collection;
023:        import java.util.Iterator;
024:        import java.util.Vector;
025:
026:        import javax.faces.model.DataModel;
027:        import javax.faces.model.ListDataModel;
028:
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:
032:        /**
033:         * <p>
034:         * Sample JSF UI controller bean for the sample jsf tool.
035:         * </p>
036:         */
037:        public class JsfSampleBean {
038:            /** Our log (commons). */
039:            private static Log M_log = LogFactory.getLog(JsfSampleBean.class);
040:
041:            /** Our service, injected. */
042:            protected ItemService itemService;
043:
044:            /** This needs to hang around for the session, between response and request. */
045:            protected DataModel items = null;
046:
047:            /**
048:             * Access our item service.
049:             * 
050:             * @return The injected item service.
051:             */
052:            public ItemService getItemService() {
053:                return itemService;
054:            }
055:
056:            /**
057:             * Set the item service - used to inject the item service.
058:             * 
059:             * @param itemService
060:             *        the item service to use.
061:             */
062:            public void setItemService(ItemService itemService) {
063:                M_log.info("setItemSevice: " + itemService);
064:
065:                this .itemService = itemService;
066:            }
067:
068:            /**
069:             * Construct.
070:             */
071:            public JsfSampleBean() {
072:                M_log.info("constructed");
073:            }
074:
075:            /**
076:             * An action method to process and select the navigation for a UI control (button, link).<br />
077:             * Used for a button of the main page.
078:             * 
079:             * @return The navigation outcome string.
080:             */
081:            public String getNextStep() {
082:                M_log.info("getNextStep: returning 'list'");
083:                return "list";
084:            }
085:
086:            /**
087:             * An action method to process and select the navigation for a UI control (button, link).<br />
088:             * Used for the tool bar in the main page.
089:             * 
090:             * @return The navigation outcome string.
091:             */
092:            public String processToolBarItem() {
093:                M_log.info("processToolBarItem: returning 'list'");
094:                return "list";
095:            }
096:
097:            /**
098:             * Get data items (entities), wrapped in UI controllers, for a JSF data table.
099:             * 
100:             * @return The items for the table.
101:             */
102:            public DataModel getItems() {
103:                // if we have not yet computed, do so
104:                if (this .items == null) {
105:                    setItems(computeItems());
106:                }
107:
108:                return this .items;
109:            }
110:
111:            /**
112:             * Set the data items.
113:             * 
114:             * @param items
115:             *        Our data items.
116:             */
117:            public void setItems(DataModel items) {
118:                this .items = items;
119:            }
120:
121:            /**
122:             * Create the DataModel for the UI table component that has our UI controller objects for our item collection.
123:             * 
124:             * @return The items for the table.
125:             */
126:            protected DataModel computeItems() {
127:                M_log.info("computeItems");
128:
129:                // collect information from the appropriate service
130:                Collection items = getItemService().getItems();
131:
132:                // wrap the entities in controllers
133:                Collection wrappers = new Vector();
134:                for (Iterator i = items.iterator(); i.hasNext();) {
135:                    wrappers.add(new ItemController((Item) i.next()));
136:                }
137:
138:                // wrap a JSF object around our controllers
139:                DataModel rv = new ListDataModel();
140:                rv.setWrappedData(wrappers);
141:
142:                return rv;
143:            }
144:
145:            /**
146:             * This is a UI controller class that wraps the item's properties and methods,<br />
147:             * adding what we need to hook up with the UI components.
148:             */
149:            public class ItemController {
150:                /** We store only a reference (id), not the entire item (which would be large and caching). */
151:                protected String itemId = null;
152:
153:                /** Set when this item was selected in the interface. */
154:                boolean selected = false;
155:
156:                /** Set when this item was clicked on from the interface. */
157:                boolean clicked = false;
158:
159:                public ItemController(Item item) {
160:                    this .itemId = item.getId();
161:                    this .selected = false;
162:                }
163:
164:                /**
165:                 * When we need an Item, we get it from the service. Thread-local caching in the service is appreciated.
166:                 * 
167:                 * @return The item associated with our stored id.
168:                 */
169:                protected Item getItem() {
170:                    return itemService.getItem(itemId);
171:                }
172:
173:                public boolean isClicked() {
174:                    return clicked;
175:                }
176:
177:                public void setClicked(boolean clicked) {
178:                    this .clicked = clicked;
179:                }
180:
181:                /**
182:                 * Action method on the item.
183:                 * 
184:                 * @return The next navigation outcome value.
185:                 */
186:                public String processClick() {
187:                    M_log.info("processClick: id: " + itemId);
188:                    setClicked(true);
189:                    return "itemClick";
190:                }
191:
192:                public String getA() {
193:                    return getItem().getA();
194:                }
195:
196:                public String getB() {
197:                    return getItem().getB();
198:                }
199:
200:                public String getC() {
201:                    return getItem().getC();
202:                }
203:
204:                /*		public void setA(String a)
205:                 {
206:                 getItem().setA(a);
207:                 }
208:
209:                 public void setB(String b)
210:                 {
211:                 getItem().setB(b);
212:                 }
213:
214:                 public void setC(String c)
215:                 {
216:                 getItem().setC(c);
217:                 }
218:                 */
219:
220:                public boolean isSelected() {
221:                    return selected;
222:                }
223:
224:                public void setSelected(boolean selected) {
225:                    M_log.info("setSelected: id: " + itemId + " selected: "
226:                            + selected);
227:                    this .selected = selected;
228:                }
229:
230:                public String getId() {
231:                    return itemId;
232:                }
233:
234:                /*		public void setId(String id)
235:                 {
236:                 getItem().setId(id);
237:                 }
238:                 */
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.