Source Code Cross Referenced for EventsTableContainer.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:         * EventsTableContainer.java
003:         *
004:         * Created on April 15, 2005, 3:35 PM
005:         */
006:
007:        package com.sun.portal.app.sharedevents.faces;
008:
009:        import com.sun.comclient.calendar.DateTime;
010:        import com.sun.faces.config.beans.FacesConfigBean;
011:        import com.sun.portal.app.sharedevents.util.CalUserHelper;
012:        import java.util.ArrayList;
013:
014:        import com.sun.data.provider.impl.ObjectArrayDataProvider;
015:
016:        import com.sun.comclient.calendar.VEvent;
017:        import com.sun.portal.app.sharedevents.models.EventsListModel;
018:        import com.sun.portal.app.sharedevents.util.AppUtils;
019:        import java.util.logging.Logger;
020:        import javax.faces.context.FacesContext;
021:        import javax.faces.context.ExternalContext;
022:        import com.sun.portal.app.sharedevents.util.SharedConstants;
023:        import com.sun.portal.log.common.PortalLogger;
024:        import java.util.Map;
025:        import java.util.ResourceBundle;
026:        import java.util.TimeZone;
027:        import java.util.logging.Level;
028:        import javax.portlet.PortletSession;
029:        import javax.servlet.http.HttpSession;
030:
031:        /**
032:         * @author saisat
033:         */
034:        public class EventsTableContainer {
035:
036:            private String message = null; // Message text.
037:            private ObjectArrayDataProvider provider = null;
038:            //private Custom custom = null; // Custom util;
039:            //private EventsTableFilter filter = null; // Filter util
040:            private EventsTableActions actions = null;
041:            private EventsTablePreferences preferences = null;
042:            private EventsTableNavigation navigation = null;
043:            private Select select = null;
044:            private String CLASS_NAME = "EventsTableContainer";
045:            private String viewContext = null;
046:            private String viewContextStart = null;
047:            private String viewContextEnd = null;
048:
049:            private String filterType = null;
050:            private String filterValue = null;
051:            private String alertType = null;
052:            private String alertMsg = null;
053:            private String alertMsgDetail = null;
054:            private String displayViewContext = null;
055:            private String searchFilter = null;
056:
057:            private FacesContext context = null;
058:            private ExternalContext extContext = null;
059:            private boolean success = true;
060:            private boolean showAlert = false;
061:            private boolean actionsInvoked = false;
062:            private boolean navigationInvoked = false;
063:            private boolean searchInvoked = false;
064:            private boolean resetSearchInvoked = false;
065:            private boolean rollViewContextToNext = false;
066:            private boolean rollViewContextToPrev = false;
067:
068:            private DateTime _startDt = null;
069:            private DateTime _endDt = null;
070:            private ResourceBundle bundle = null;
071:
072:            private static Logger logger = PortalLogger
073:                    .getLogger(EventsTableContainer.class);
074:
075:            public EventsTableContainer() {
076:                logger.entering(CLASS_NAME, "EventsTableContainer()");
077:
078:                if (context == null) {
079:                    context = FacesContext.getCurrentInstance();
080:                }
081:
082:                extContext = context.getExternalContext();
083:
084:                bundle = getResourceBundle();
085:
086:                //custom = new Custom();
087:                //filter = new EventsTableFilter(this);
088:                actions = new EventsTableActions(this );
089:                preferences = new EventsTablePreferences(this );
090:                select = new Select(this );
091:                navigation = new EventsTableNavigation(this );
092:
093:                logger.exiting(CLASS_NAME, "EventsTableContainer()");
094:            }
095:
096:            /*
097:             * This method is a binding for sourceData for tableRowGroup.
098:             * Since this method is invoked during decode, validate, update and render phases 
099:             * of the request cycle, we need to obtain data from backend only once.
100:             * And this should be done after ascertaining that user has invoked any table actions or filters
101:             * or Table data Navigation (Previous and Next view contexts).
102:             * So based on those selections, execute the appropriate backend context.
103:             */
104:            public ObjectArrayDataProvider getEventsListProvider() {
105:                logger.entering(CLASS_NAME, "getEventsListProvider()");
106:
107:                constructDataProvider();
108:
109:                logger.exiting(CLASS_NAME, "getEventsListProvider()");
110:                return provider;
111:            }
112:
113:            public EventsTableActions getActions() {
114:
115:                return actions;
116:            }
117:
118:            public EventsTablePreferences getPreferences() {
119:
120:                return preferences;
121:            }
122:
123:            public Select getSelect() {
124:
125:                return select;
126:            }
127:
128:            public EventsTableNavigation getNavigation() {
129:
130:                return navigation;
131:            }
132:
133:            public boolean getRenderTable() {
134:                return success;
135:            }
136:
137:            public boolean getShowAlert() {
138:                return showAlert;
139:
140:            }
141:
142:            public void setShowAlert(boolean value) {
143:                showAlert = value;
144:            }
145:
146:            public String getAlertMessage() {
147:                return alertMsg;
148:
149:            }
150:
151:            public void setAlertMessage(String value) {
152:                alertMsg = value;
153:
154:            }
155:
156:            public String getAlertType() {
157:                return alertType;
158:
159:            }
160:
161:            public void setAlertType(String value) {
162:                alertType = value;
163:
164:            }
165:
166:            public String getAlertMessageDetail() {
167:                return alertMsgDetail;
168:
169:            }
170:
171:            public void setAlertMessageDetail(String value) {
172:                alertMsgDetail = value;
173:
174:            }
175:
176:            public void setActionsInvoked(boolean invoked) {
177:                actionsInvoked = invoked;
178:            }
179:
180:            /*
181:             * Used to set whether the view needs to be displayed based on the
182:             * navigation change (i.e previous & next view contexts)
183:             */
184:            public void setNavigationInvoked(boolean invoked) {
185:                navigationInvoked = invoked;
186:            }
187:
188:            /*
189:             * If this is set, the page is refreshed with data corresponding to the
190:             * context start date minus 1 unit.
191:             * i.e of the view context was DAY, the context start would be the previous day etc.
192:             */
193:            public void rollViewContextToPrev(boolean roll) {
194:                rollViewContextToPrev = roll;
195:            }
196:
197:            /*
198:             * If this is set, the page is refreshed with data corresponding to the
199:             * context start date plus 1 unit.
200:             * i.e of the view context was DAY, the context start would be the next day etc.
201:             */
202:            public void rollViewContextToNext(boolean roll) {
203:                rollViewContextToNext = roll;
204:            }
205:
206:            /*
207:             * Sets the appropriate View Context for the events list.
208:             * Set by the Table Actions class or by Navigation
209:             */
210:            public void setViewContext(String viewCtx) {
211:                logger.entering(CLASS_NAME, "setViewContext()");
212:                viewContext = viewCtx;
213:                logger.exiting(CLASS_NAME, "setViewContext()");
214:
215:            }
216:
217:            /*
218:             * Sets the appropriate View Context start date (in ISO format)for the events list.
219:             * Set by the  Navigation handlers
220:             */
221:
222:            public void setViewContextStart(String viewCtxStart) {
223:                viewContextStart = viewCtxStart;
224:            }
225:
226:            /*
227:             * This is used to set whether the view should be search view
228:             */
229:            public void setSearchInvoked(boolean value) {
230:                searchInvoked = value;
231:            }
232:
233:            /*
234:             * Invoked by table UI element components (ex: navigation) to act accordingly
235:             */
236:
237:            public boolean isSearchInvoked() {
238:                return searchInvoked;
239:            }
240:
241:            /*
242:             * This is used to indicate whether the current search view should be reset and
243:             * display the default view.
244:             */
245:            public void setResetSearchInvoked(boolean value) {
246:                resetSearchInvoked = value;
247:            }
248:
249:            /*
250:             * This is used by the search filter field to set the search string
251:             */
252:
253:            public void setSearchFilter(String value) {
254:                searchFilter = value;
255:            }
256:
257:            public String getCurrentViewContext() {
258:                if (viewContext != null) {
259:                    return viewContext;
260:                }
261:                String ctx = (String) AppUtils
262:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX);
263:                if (ctx != null) {
264:                    viewContext = ctx;
265:                }
266:                if (viewContext != null) {
267:                    return viewContext;
268:                }
269:                viewContext = SharedConstants.VIEW_CTX_DAY;
270:                return viewContext;
271:            }
272:
273:            public DateTime getCurrentContextStartDt() {
274:                if (_startDt != null) {
275:                    return _startDt;
276:                }
277:                String oldViewCtxStart = null;
278:                oldViewCtxStart = (String) AppUtils
279:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX_START);
280:
281:                DateTime startDate = null;
282:                if (oldViewCtxStart != null && oldViewCtxStart.length() > 0) {
283:
284:                    try {
285:                        String tzStr = CalUserHelper.getUserTimeZone();
286:                        TimeZone tz = TimeZone.getTimeZone(tzStr);
287:
288:                        startDate = new DateTime(oldViewCtxStart, tz);
289:                    } catch (Exception e1) {
290:                        startDate = CalUserHelper.getToday();
291:                    }
292:                } else {
293:                    startDate = CalUserHelper.getToday();
294:
295:                }
296:
297:                _startDt = AppUtils.getContextStart(startDate, viewContext,
298:                        startDate.getFirstDayOfWeek());
299:                return _startDt;
300:
301:            }
302:
303:            public DateTime getCurrentContextEndDt() {
304:
305:                if (_endDt != null) {
306:                    return _endDt;
307:                }
308:                if (_startDt == null) {
309:                    getCurrentContextStartDt();
310:                }
311:                _endDt = AppUtils.getContextEnd(_startDt, viewContext);
312:
313:                return _endDt;
314:
315:            }
316:
317:            private void constructStartAndEndDates() {
318:
319:                if (_startDt != null && _endDt != null) {
320:
321:                    if (logger.isLoggable(Level.FINE)) {
322:                        logger.log(Level.FINE, CLASS_NAME
323:                                + " constructStartAndEndDates(): "
324:                                + "_startDt is : " + _startDt.toISOString());
325:                    }
326:                    return;
327:                }
328:
329:                constructContextStartAndEndDates();
330:            }
331:
332:            public void constructContextStartAndEndDates() {
333:
334:                logger.entering(CLASS_NAME,
335:                        "constructContextStartAndEndDates()");
336:                String viewCtxStartInSess = null;
337:                viewCtxStartInSess = (String) AppUtils
338:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX_START);
339:
340:                DateTime startDate = null;
341:                if (viewCtxStartInSess != null
342:                        && viewCtxStartInSess.length() > 0) {
343:                    if (logger.isLoggable(Level.FINE)) {
344:                        logger.log(Level.FINE,
345:                                "viewCtxStartInSess in session: "
346:                                        + viewCtxStartInSess);
347:                    }
348:                    startDate = CalUserHelper
349:                            .getDateTimeFromISOString(viewCtxStartInSess);
350:                    if (startDate == null) {
351:                        logger
352:                                .log(Level.WARNING,
353:                                        "Could not construct Start Date. Defaulting to today. ");
354:                        startDate = CalUserHelper.getToday();
355:                    }
356:                } else {
357:                    if (logger.isLoggable(Level.FINE)) {
358:                        logger
359:                                .log(Level.FINE,
360:                                        "viewCtxStartInSess not in session. Defaulting to today");
361:                    }
362:                    startDate = CalUserHelper.getToday();
363:
364:                }
365:
366:                _startDt = AppUtils.getContextStart(startDate, viewContext,
367:                        startDate.getFirstDayOfWeek());
368:
369:                // This is done throws Navigation class
370:                /*
371:                if (rollViewContextToPrev) {
372:                    if (logger.isLoggable(Level.FINE)) {
373:                       logger.log(Level.FINE, "Rolling Start Date to Previous Context");
374:                    }
375:                    if (viewContext.equalsIgnoreCase(SharedConstants.VIEW_CTX_DAY)) {
376:                        _startDt.add(DateTime.DAY_OF_MONTH, -1);
377:                    }
378:                    else if (viewContext.equalsIgnoreCase(SharedConstants.VIEW_CTX_WEEK)) {
379:                        _startDt.add(DateTime.WEEK_OF_MONTH, -1);
380:                        
381:                    }
382:                    else if(viewContext.equalsIgnoreCase(SharedConstants.VIEW_CTX_MONTH)) {
383:                        _startDt.add(DateTime.MONTH, -1);
384:                    }
385:                    
386:                    rollViewContextToPrev = false;
387:                }
388:                
389:                if (rollViewContextToNext) {
390:                    if (logger.isLoggable(Level.FINE)) {
391:                       logger.log(Level.FINE, "Rolling Start Date to Next Context");
392:                    }
393:                    if (viewContext.equalsIgnoreCase(SharedConstants.VIEW_CTX_DAY)) {
394:                        _startDt.add(DateTime.DAY_OF_MONTH, +1);
395:                    }
396:                    else if (viewContext.equalsIgnoreCase(SharedConstants.VIEW_CTX_WEEK)) {
397:                        _startDt.add(DateTime.WEEK_OF_MONTH, +1);
398:                        
399:                    }
400:                    else if(viewContext.equalsIgnoreCase(SharedConstants.VIEW_CTX_MONTH)) {
401:                        _startDt.add(DateTime.MONTH, +1);
402:                    }
403:                    
404:                    rollViewContextToNext = false;
405:                }
406:                 */
407:
408:                viewContextStart = _startDt.toISOString();
409:                if (logger.isLoggable(Level.FINE)) {
410:                    logger.log(Level.FINE, "viewContextStart: "
411:                            + viewContextStart);
412:                }
413:
414:                _endDt = AppUtils.getContextEnd(_startDt, viewContext);
415:
416:                viewContextEnd = _endDt.toISOString();
417:
418:                if (logger.isLoggable(Level.FINE)) {
419:                    if (_endDt != null) {
420:                        logger.log(Level.FINE, "viewContextEnd: "
421:                                + viewContextEnd);
422:                    }
423:                }
424:
425:                // Set the context start and end dates in session
426:                AppUtils.setAttributeInSession(
427:                        SharedConstants.SESSION_CURR_VIEW_CTX_START,
428:                        viewContextStart);
429:                AppUtils.setAttributeInSession(
430:                        SharedConstants.SESSION_CURR_VIEW_CTX_END,
431:                        viewContextEnd);
432:
433:            }
434:
435:            private void constructViewContext() {
436:                logger.entering(CLASS_NAME, "constructViewContext()");
437:                if (viewContext != null) {
438:                    if (logger.isLoggable(Level.FINE)) {
439:                        logger.fine("viewContext: " + viewContext);
440:                    }
441:
442:                    logger.exiting(CLASS_NAME, "constructViewContext()");
443:                    return;
444:                }
445:                constructCurrentViewContext();
446:                logger.exiting(CLASS_NAME, "constructViewContext()");
447:            }
448:
449:            public void constructCurrentViewContext() {
450:                String oldViewCtx = null;
451:                oldViewCtx = (String) AppUtils
452:                        .getSessionAttribute(SharedConstants.SESSION_CURR_VIEW_CTX);
453:                if (oldViewCtx != null && oldViewCtx.length() > 0) {
454:                    if (logger.isLoggable(Level.FINE)) {
455:                        logger.fine("oldViewCtx in session: " + oldViewCtx);
456:                    }
457:                    viewContext = oldViewCtx;
458:                }
459:
460:                if (viewContext == null) {
461:                    viewContext = SharedConstants.VIEW_CTX_DAY;
462:                    if (logger.isLoggable(Level.FINE)) {
463:                        logger.fine("Setting Default View Context: "
464:                                + viewContext);
465:                    }
466:
467:                    // Set the current vew context in session
468:                    AppUtils.setAttributeInSession(
469:                            SharedConstants.SESSION_CURR_VIEW_CTX, viewContext);
470:                }
471:
472:            }
473:
474:            private void constructDataProvider() {
475:                logger.entering(CLASS_NAME, "constructDataProvider()");
476:
477:                boolean refreshData = false;
478:                // If the user chooses to view Actions or uses Navigation to move to
479:                // previous/next view contexts, we need to flush all the data and fetch it from the
480:                // backend
481:
482:                // The same is the case when some action was performed in other pages, thet require
483:                // this data to be refreshed. ex: A new event was created/deleted etc.
484:
485:                String dataRefreshRequired = (String) AppUtils
486:                        .getSessionAttribute(SharedConstants.SESSION_REFRESH_DATA);
487:                if (dataRefreshRequired != null
488:                        && dataRefreshRequired.equalsIgnoreCase("true")) {
489:
490:                    AppUtils
491:                            .removeAttributeFromSession(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT);
492:                    AppUtils
493:                            .removeAttributeFromSession(SharedConstants.SESSION_REFRESH_DATA);
494:                    viewContext = null;
495:                    _startDt = null;
496:                    _endDt = null;
497:                    refreshData = true;
498:                } else {
499:                    if (provider != null) {
500:
501:                        refreshData = false;
502:                    } else {
503:                        getProviderFromSession();
504:                        if (provider != null) {
505:                            refreshData = false;
506:                        } else {
507:                            viewContext = null;
508:                            _startDt = null;
509:                            _endDt = null;
510:                            refreshData = true;
511:                        }
512:                    }
513:
514:                }
515:
516:                /*
517:                if (actionsInvoked) {
518:                    AppUtils.removeAttributeFromSession(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT);
519:                    AppUtils.removeAttributeFromSession(SharedConstants.SESSION_CURR_VIEW_CTX);
520:                    AppUtils.removeAttributeFromSession(SharedConstants.SESSION_CURR_VIEW_CTX_START);
521:                    _startDt = null;
522:                    _endDt = null;
523:                    actionsInvoked = false;
524:                    refreshData = true;
525:                }
526:                else if(navigationInvoked) {
527:                    if (logger.isLoggable(Level.FINE)) {
528:                       logger.fine("navigationInvoked");
529:                	}
530:
531:                    removeAttributeFromSession(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT);
532:                    //_startDt = null;
533:                    //_endDt = null;
534:                    navigationInvoked = false;
535:                    
536:                    refreshData = true;
537:                }
538:                else if(searchInvoked) {
539:                    removeAttributeFromSession(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT);
540:                    _startDt = null;
541:                    _endDt = null;
542:                    searchInvoked = false;
543:                    refreshData = true;
544:                }
545:                else if(resetSearchInvoked) {
546:                    removeAttributeFromSession(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT);
547:                    removeAttributeFromSession(SharedConstants.SESSION_CURR_VIEW_CTX);
548:                    removeAttributeFromSession(SharedConstants.SESSION_CURR_VIEW_CTX_START);
549:                    _startDt = null;
550:                    _endDt = null;
551:                    resetSearchInvoked = false;
552:                    refreshData = true;
553:                }
554:                else if(dataRefreshRequired != null && dataRefreshRequired.equalsIgnoreCase("true")) {
555:                    removeAttributeFromSession(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT);
556:                    removeAttributeFromSession(SharedConstants.SESSION_REFRESH_DATA);
557:                    refreshData = true;
558:                }
559:                else {
560:                   if (provider != null) {
561:                      refreshData = false;
562:                   }
563:                   else {
564:                      getProviderFromSession();
565:                      if(provider != null) {
566:                         refreshData = false;
567:                      }
568:                      else {
569:                          refreshData = true;
570:                      }
571:                   }
572:                    
573:                }
574:                 */
575:
576:                constructViewContext();
577:
578:                if (!viewContext
579:                        .equalsIgnoreCase(SharedConstants.VIEW_CTX_SEARCH)) {
580:                    constructStartAndEndDates();
581:                }
582:
583:                if (!refreshData) {
584:                    return;
585:                }
586:
587:                EventsListModel model = getEventsListModel();
588:                String execViewContext = null;
589:
590:                if (logger.isLoggable(Level.FINE)) {
591:                    logger.fine("Obtaining data for viewContext: "
592:                            + viewContext);
593:                }
594:
595:                if (viewContext == null) {
596:                    execViewContext = SharedConstants.VIEW_CTX_DAY;
597:                } else {
598:                    execViewContext = viewContext;
599:                }
600:
601:                //Set the required attributes in Session
602:                //setAttributeInSession(SharedConstants.SESSION_CURR_VIEW_CTX, execViewContext);
603:
604:                /*
605:                if (logger.isLoggable(Level.FINE)) {
606:                   logger.log(Level.FINE, "Setting CURR_VIEW_CTX_START in session: " + viewContextStart);
607:                }
608:                
609:                if( viewContextStart != null) {
610:                   setAttributeInSession(SharedConstants.SESSION_CURR_VIEW_CTX_START, viewContextStart);
611:                }
612:                 */
613:
614:                // Set the View context to the Actions pane so that the drop-down shows the context
615:                // correctly
616:                if (!execViewContext
617:                        .equalsIgnoreCase(SharedConstants.VIEW_CTX_SEARCH)) {
618:                    actions.setActionBottom(execViewContext);
619:                    actions.setActionTop(execViewContext);
620:                }
621:
622:                model.setViewContext(execViewContext);
623:                model.setContextStartDt(_startDt);
624:                model.setContextEndDt(_endDt);
625:
626:                if (execViewContext
627:                        .equalsIgnoreCase(SharedConstants.VIEW_CTX_SEARCH)) {
628:                    searchFilter = (String) AppUtils
629:                            .getSessionAttribute(SharedConstants.SESSION_EVENTS_SEARCH_STRING);
630:                    model.setSearchMode(true);
631:                    model.setSearchFilter(searchFilter);
632:                }
633:
634:                try {
635:                    model.execute(SharedConstants.LOAD_EVENTS_CONTEXT);
636:                } catch (Exception e1) {
637:                    logger.severe("Failed to obtain events list: "
638:                            + e1.getMessage());
639:                    success = false;
640:                }
641:
642:                if (!success) {
643:                    logger
644:                            .severe("Error in obtaining events. Displaying error on page.");
645:                    showAlert = true;
646:                    alertType = SharedConstants.SHOW_ALERT_TYPE_ERROR;
647:
648:                    alertMsg = bundle.getString("eventsFetchFailSummary");
649:                    alertMsgDetail = bundle
650:                            .getString("eventsFetchFailMsgDetail");
651:                    provider = new ObjectArrayDataProvider();
652:                    return;
653:                }
654:
655:                ArrayList eventsList = model.getEvents();
656:                CalEvent[] events = toEventsArray(eventsList);
657:                if (events != null) {
658:                    if (logger.isLoggable(Level.FINE)) {
659:                        logger.fine("Number of Events obtained: "
660:                                + events.length);
661:                    }
662:                    provider = new ObjectArrayDataProvider(events);
663:                } else {
664:                    provider = new ObjectArrayDataProvider();
665:                }
666:
667:                setProviderInSession();
668:
669:                logger.exiting(CLASS_NAME, "constructDataProvider()");
670:
671:            }
672:
673:            private void removeProviderFromSession() {
674:                logger.entering(CLASS_NAME, "removeProviderFromSession()");
675:                extContext = FacesContext.getCurrentInstance()
676:                        .getExternalContext();
677:                Object obj1 = extContext.getSession(false);
678:                if (obj1 instanceof  HttpSession) {
679:                    ((HttpSession) obj1)
680:                            .removeAttribute(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT);
681:                } else {
682:                    ((PortletSession) obj1)
683:                            .removeAttribute(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT);
684:
685:                }
686:                logger.exiting(CLASS_NAME, "removeProviderFromSession()");
687:            }
688:
689:            private void setProviderInSession() {
690:                logger.entering(CLASS_NAME, "setProviderInSession()");
691:                if (provider != null) {
692:                    if (logger.isLoggable(Level.FINE)) {
693:                        logger.fine("Setting ProviderObject in session...");
694:                    }
695:                    extContext = FacesContext.getCurrentInstance()
696:                            .getExternalContext();
697:                    extContext.getSessionMap().put(
698:                            SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT,
699:                            provider);
700:                    /*
701:                    try {
702:                       extContext.getSessionMap().put(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT, provider);
703:                    }
704:                    catch(Throwable e) {
705:                        e.printStackTrace();
706:                                       
707:                        logger.log(Level.WARNING, "Exception in setting information in sessionMap: " );
708:                    }
709:                    if (logger.isLoggable(Level.FINE)) {
710:                        logger.fine("Successfully Set ProviderObject in session...");
711:                    }
712:                     */
713:                }
714:
715:                logger.exiting(CLASS_NAME, "setProviderInSession()");
716:            }
717:
718:            private void getProviderFromSession() {
719:
720:                extContext = FacesContext.getCurrentInstance()
721:                        .getExternalContext();
722:                Map sessMap = extContext.getSessionMap();
723:                Object pObj = null;
724:                if (sessMap != null) {
725:                    pObj = sessMap
726:                            .get(SharedConstants.SESSION_TABLE_DATA_PROVIDER_OBJECT);
727:                }
728:
729:                if (pObj != null) {
730:                    provider = (ObjectArrayDataProvider) pObj;
731:                } else {
732:                    provider = null;
733:                }
734:
735:            }
736:
737:            private EventsListModel getEventsListModel() {
738:                EventsListModel m = new EventsListModel(CLASS_NAME);
739:                return m;
740:            }
741:
742:            private CalEvent[] toEventsArray(ArrayList eventsList) {
743:
744:                CalEvent[] eventsA = null;
745:                if (eventsList != null && eventsList.size() > 0) {
746:                    Object[] objArr = eventsList.toArray();
747:                    eventsA = new CalEvent[objArr.length];
748:                    for (int i = 0; i < objArr.length; i++) {
749:                        eventsA[i] = new CalEvent((VEvent) objArr[i]);
750:                    }
751:                }
752:                return eventsA;
753:
754:            }
755:
756:            private ResourceBundle getResourceBundle() {
757:                return AppUtils.getResourceBundle();
758:            }
759:
760:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.