Source Code Cross Referenced for EventsTableNavigation.java in  » Portal » Open-Portal » com » sun » portal » app » sharedevents » faces » 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 » Portal » Open Portal » com.sun.portal.app.sharedevents.faces 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * EventsTableNavigation.java
003:         *
004:         * Created on May 16, 2005, 2:47 PM
005:         *
006:         * 
007:         */
008:
009:        package com.sun.portal.app.sharedevents.faces;
010:
011:        import com.sun.comclient.calendar.DateTime;
012:        import com.sun.portal.app.sharedevents.util.AppUtils;
013:        import com.sun.portal.app.sharedevents.util.CalUserHelper;
014:        import com.sun.portal.app.sharedevents.util.SharedConstants;
015:        import com.sun.portal.log.common.PortalLogger;
016:        import java.text.DateFormat;
017:        import java.util.ResourceBundle;
018:        import java.util.TimeZone;
019:        import java.util.logging.Level;
020:        import java.util.logging.Logger;
021:        import javax.faces.event.ActionEvent;
022:
023:        /**
024:         * This class provides functionality for Table Navigation 
025:         * (Traversing to previous and next view contexts (Day/Week/Month)
026:         * @author SaiSatish Vedam
027:         */
028:        public class EventsTableNavigation {
029:
030:            private EventsTableContainer tableContainer = null;
031:            private String CLASS_NAME = "EventsTableNavigation";
032:            private String displayViewContextDuration = null;
033:            private String displayViewContext = null;
034:            private String viewCtx = null;
035:            private String viewCtxStart = null;
036:            private DateTime startDt = null;
037:            private DateTime endDt = null;
038:            private ResourceBundle bundle = null;
039:            private boolean rollViewContextToPrev = false;
040:            private boolean rollViewContextToNext = false;
041:
042:            //These are the request parameter names passed from the JSP 
043:            private String CURR_VIEW_CTX_PARAM = "currViewCtx";
044:            private String VIEW_CTX_START_PARAM = "currViewCtxStart";
045:
046:            private boolean renderUIElement = true;
047:
048:            private static Logger logger = PortalLogger
049:                    .getLogger(EventsTableNavigation.class);
050:
051:            /** Creates a new instance of EventsTableNavigation */
052:            public EventsTableNavigation(EventsTableContainer container) {
053:                logger.entering(CLASS_NAME, "EventsTablePreferences()");
054:                tableContainer = container;
055:                if (bundle == null) {
056:                    bundle = getResourceBundle();
057:                }
058:                logger.exiting(CLASS_NAME, "EventsTablePreferences()");
059:
060:            }
061:
062:            /*
063:             * This method is invoked by the caller (EventsTableContainer) to the view context
064:             * (Day/Week/Month) being displayed.
065:             * This information will be used to show the displayable view context
066:             */
067:            public void setViewContext(String ctx) {
068:                viewCtx = ctx;
069:
070:            }
071:
072:            /*
073:             * This is used as value binding to set whether the UI element needs to be rendered
074:             * or not. This could be the case when Search is invoked.
075:             */
076:
077:            public boolean getRenderComponent() {
078:                /*
079:                if (tableContainer.isSearchInvoked()) {
080:                    renderUIElement = false;
081:                }
082:                 */
083:                String viewCtx = (String) AppUtils
084:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX);
085:
086:                if (viewCtx != null
087:                        && viewCtx
088:                                .equalsIgnoreCase(SharedConstants.VIEW_CTX_SEARCH)) {
089:                    renderUIElement = false;
090:                } else {
091:                    renderUIElement = true;
092:                }
093:                return renderUIElement;
094:            }
095:
096:            /*
097:             * This method is invoked by the caller (EventsTableContainer) to the view context
098:             * Start date (in ISO format)(Day/Week/Month) being displayed.
099:             * This information will be used for navigation
100:            
101:            public void setViewContextStart(String ctxSt) {
102:                System.out.println(CLASS_NAME + "ENTERING: " + "setViewContextStart()");
103:                viewCtxStart = ctxSt;
104:                System.out.println(CLASS_NAME + "EXITING: " + "setViewContextStart()");
105:                
106:            }
107:             */
108:
109:            /*
110:             * This method is invoked by the caller (EventsTableContainer) to set the view context
111:             * Start date. This will be used to construct display view context duration
112:             */
113:            public void setViewContextStartDt(DateTime dt) {
114:                startDt = dt;
115:
116:            }
117:
118:            /*
119:             * This method is invoked by the caller (EventsTableContainer) to set the view context
120:             * End date. This will be used to construct display view context duration
121:             */
122:            public void setViewContextEndDt(DateTime dt) {
123:                endDt = dt;
124:
125:            }
126:
127:            /*
128:             * This is the value binding for the view context parameter in the JSP
129:             */
130:
131:            public String getDisplayViewContext() {
132:                //String viewCtx = null; 
133:                viewCtx = (String) AppUtils
134:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX);
135:                if (viewCtx != null && viewCtx.length() > 0) {
136:
137:                } else {
138:                    viewCtx = SharedConstants.VIEW_CTX_DAY;
139:                }
140:
141:                if (viewCtx.equalsIgnoreCase(SharedConstants.VIEW_CTX_DAY)) {
142:                    displayViewContext = bundle
143:                            .getString("displayViewContextDay");
144:
145:                }
146:                if (viewCtx.equalsIgnoreCase(SharedConstants.VIEW_CTX_WEEK)) {
147:                    displayViewContext = bundle
148:                            .getString("displayViewContextWeek");
149:
150:                }
151:                if (viewCtx.equalsIgnoreCase(SharedConstants.VIEW_CTX_MONTH)) {
152:                    displayViewContext = bundle
153:                            .getString("displayViewContextMonth");
154:
155:                }
156:
157:                return displayViewContext;
158:
159:            }
160:
161:            /*
162:             * This is the value binding for context duration in JSP
163:             */
164:            public String getDisplayViewContextDuration() {
165:
166:                viewCtx = (String) AppUtils
167:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX);
168:                String isoStDt = (String) AppUtils
169:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX_START);
170:                String isoEdDt = (String) AppUtils
171:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX_END);
172:
173:                if (isoStDt != null && isoStDt.length() > 0) {
174:                    startDt = CalUserHelper.getDateTimeFromISOString(isoStDt);
175:                } else {
176:                    startDt = CalUserHelper.getToday();
177:                }
178:
179:                if (isoEdDt != null && isoEdDt.length() > 0) {
180:                    endDt = CalUserHelper.getDateTimeFromISOString(isoEdDt);
181:                } else {
182:                    endDt = CalUserHelper.getToday();
183:                }
184:
185:                displayViewContextDuration = null;
186:                if (viewCtx.equalsIgnoreCase(SharedConstants.VIEW_CTX_DAY)) {
187:                    if (startDt != null) {
188:                        displayViewContextDuration = AppUtils
189:                                .getLocaleDatePerPattern(
190:                                        startDt,
191:                                        bundle
192:                                                .getString("dayContextDurationPattern"),
193:                                        DateFormat.FULL);
194:                    }
195:
196:                }
197:                if (viewCtx.equalsIgnoreCase(SharedConstants.VIEW_CTX_WEEK)) {
198:                    String start = null;
199:                    if (startDt != null) {
200:                        start = AppUtils
201:                                .getLocaleDatePerPattern(
202:                                        startDt,
203:                                        bundle
204:                                                .getString("weekContextDurationPattern1"),
205:                                        DateFormat.LONG);
206:                    }
207:
208:                    String end = null;
209:
210:                    if (endDt != null) {
211:                        end = AppUtils.getLocaleDatePerPattern(endDt, bundle
212:                                .getString("weekContextDurationPattern2"),
213:                                DateFormat.LONG);
214:                    }
215:
216:                    if (start != null && end != null) {
217:                        displayViewContextDuration = start + " - " + end;
218:                    }
219:
220:                }
221:                if (viewCtx.equalsIgnoreCase(SharedConstants.VIEW_CTX_MONTH)) {
222:
223:                    if (startDt != null) {
224:                        displayViewContextDuration = AppUtils
225:                                .getLocaleDatePerPattern(
226:                                        startDt,
227:                                        bundle
228:                                                .getString("monthContextDurationPattern"),
229:                                        DateFormat.LONG);
230:                    }
231:                }
232:
233:                return displayViewContextDuration;
234:
235:            }
236:
237:            /**
238:             * Action Listener for handling Navigation icons on the table
239:             */
240:            public void handlePrevContext(ActionEvent e) {
241:                logger.entering(CLASS_NAME, "handlePrevContext()");
242:                String currViewCtx = null;
243:                String viewCtxStart = null;
244:
245:                // As the Table Container to fetch new data based on the view context information
246:                /*
247:                tableContainer.setNavigationInvoked(true);
248:                tableContainer.rollViewContextToPrev(true);
249:                tableContainer.constructContextStartAndEndDates();
250:                 */
251:                rollViewContextToPrev = true;
252:                setContextStartAndEndDates();
253:                AppUtils.setAttributeInSession(
254:                        SharedConstants.SESSION_REFRESH_DATA, "true");
255:
256:                logger.exiting(CLASS_NAME, "handlePrevContext()");
257:
258:            }
259:
260:            /**
261:             * Action Listener for handling Navigation icons on the table
262:             */
263:            public void handleNextContext(ActionEvent e) {
264:                logger.entering(CLASS_NAME, "handleNextContext()");
265:                String currViewCtx = null;
266:                String viewCtxStart = null;
267:
268:                // As the Table Container to fetch new data based on the view context information
269:                /*
270:                tableContainer.setNavigationInvoked(true);
271:                tableContainer.rollViewContextToNext(true);
272:                tableContainer.constructContextStartAndEndDates();
273:                 */
274:                rollViewContextToNext = true;
275:                setContextStartAndEndDates();
276:                AppUtils.setAttributeInSession(
277:                        SharedConstants.SESSION_REFRESH_DATA, "true");
278:
279:                logger.exiting(CLASS_NAME, "handleNextContext()");
280:            }
281:
282:            private ResourceBundle getResourceBundle() {
283:                return AppUtils.getResourceBundle();
284:            }
285:
286:            private void setContextStartAndEndDates() {
287:
288:                logger.entering(CLASS_NAME, "setContextStartAndEndDates()");
289:                String oldViewCtxStart = null;
290:                oldViewCtxStart = (String) AppUtils
291:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX_START);
292:
293:                DateTime startDate = null;
294:                if (oldViewCtxStart != null && oldViewCtxStart.length() > 0) {
295:                    if (logger.isLoggable(Level.FINE)) {
296:                        logger.log(Level.FINE, "oldViewCtxStart: "
297:                                + oldViewCtxStart);
298:                    }
299:                    startDate = CalUserHelper
300:                            .getDateTimeFromISOString(oldViewCtxStart);
301:                } else {
302:                    if (logger.isLoggable(Level.FINE)) {
303:                        logger.log(Level.FINE, "oldViewCtxStart: "
304:                                + oldViewCtxStart);
305:                    }
306:                    startDate = CalUserHelper.getToday();
307:
308:                }
309:
310:                String viewContext = null;
311:                viewContext = (String) AppUtils
312:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX);
313:
314:                if (viewContext != null && viewContext.length() > 0) {
315:
316:                } else {
317:                    viewContext = SharedConstants.VIEW_CTX_DAY;
318:                }
319:
320:                if (rollViewContextToPrev) {
321:                    if (logger.isLoggable(Level.FINE)) {
322:                        logger.log(Level.FINE,
323:                                "Rolling Start Date to Previous Context");
324:                    }
325:                    if (viewContext
326:                            .equalsIgnoreCase(SharedConstants.VIEW_CTX_DAY)) {
327:                        startDate.add(DateTime.DAY_OF_MONTH, -1);
328:                    } else if (viewContext
329:                            .equalsIgnoreCase(SharedConstants.VIEW_CTX_WEEK)) {
330:                        startDate.add(DateTime.WEEK_OF_MONTH, -1);
331:
332:                    } else if (viewContext
333:                            .equalsIgnoreCase(SharedConstants.VIEW_CTX_MONTH)) {
334:                        startDate.add(DateTime.MONTH, -1);
335:                    }
336:
337:                    rollViewContextToPrev = false;
338:                }
339:
340:                if (rollViewContextToNext) {
341:                    if (logger.isLoggable(Level.FINE)) {
342:                        logger.log(Level.FINE,
343:                                "Rolling Start Date to Next Context");
344:                    }
345:                    if (viewContext
346:                            .equalsIgnoreCase(SharedConstants.VIEW_CTX_DAY)) {
347:                        startDate.add(DateTime.DAY_OF_MONTH, +1);
348:                    } else if (viewContext
349:                            .equalsIgnoreCase(SharedConstants.VIEW_CTX_WEEK)) {
350:                        startDate.add(DateTime.WEEK_OF_MONTH, +1);
351:
352:                    } else if (viewContext
353:                            .equalsIgnoreCase(SharedConstants.VIEW_CTX_MONTH)) {
354:                        startDate.add(DateTime.MONTH, +1);
355:                    }
356:
357:                    rollViewContextToNext = false;
358:                }
359:
360:                String viewContextStart = null;
361:                viewContextStart = startDate.toISOString();
362:
363:                DateTime endDate = null;
364:                if (logger.isLoggable(Level.FINE)) {
365:                    logger.log(Level.FINE, "viewContextStart: "
366:                            + viewContextStart);
367:                }
368:                endDate = AppUtils.getContextEnd(startDate, viewContext);
369:                String viewContextEnd = null;
370:                if (endDate != null) {
371:                    viewContextEnd = endDate.toISOString();
372:                    if (logger.isLoggable(Level.FINE)) {
373:                        logger.log(Level.FINE, "viewContextEnd: "
374:                                + endDate.toISOString());
375:                    }
376:
377:                }
378:
379:                // Set the computed context start and end dates in session
380:                AppUtils.setAttributeInSession(
381:                        SharedConstants.SESSION_CURR_VIEW_CTX_START,
382:                        viewContextStart);
383:                AppUtils.setAttributeInSession(
384:                        SharedConstants.SESSION_CURR_VIEW_CTX_END,
385:                        viewContextEnd);
386:
387:            }
388:
389:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.