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


001:        package com.sun.portal.app.sharedtasks.faces.beans;
002:
003:        import java.text.ParseException;
004:        import java.util.Calendar;
005:        import java.util.Map;
006:
007:        import com.sun.comclient.calendar.DateTime;
008:        import com.sun.data.provider.impl.ObjectArrayDataProvider;
009:
010:        import com.sun.portal.app.sharedtasks.util.SharedConstants;
011:        import com.sun.portal.app.sharedtasks.util.TaskBeanFactory;
012:
013:        import com.sun.portal.log.common.PortalLogger;
014:        import java.util.logging.Logger;
015:        import java.util.logging.Level;
016:
017:        import javax.faces.context.FacesContext;
018:        import javax.portlet.PortletURL;
019:        import javax.portlet.RenderResponse;
020:
021:        /**
022:         * Maintains session state for the task list page.
023:         *
024:         * @author ashwin.mathew@sun.com
025:         */
026:        public class TaskListSessionBackingBean {
027:
028:            public static final String BEAN_NAME = "TaskListSessionBean";
029:
030:            private String searchString;
031:
032:            private String viewContext = SharedConstants.VIEW_CTX_DAY; // Default
033:
034:            private DateTime viewDateTime;
035:
036:            private String statusFilter;
037:
038:            private int displayRows = 5; // Default
039:
040:            private ObjectArrayDataProvider dataProvider;
041:
042:            private static Logger logger = PortalLogger
043:                    .getLogger(TaskListSessionBackingBean.class);
044:
045:            private PortletURL tasksPortletUrl = null;
046:
047:            public TaskListSessionBackingBean() {
048:                FacesContext context = FacesContext.getCurrentInstance();
049:                if (tasksPortletUrl == null) {
050:                    Object r = context.getExternalContext().getResponse();
051:                    if (r instanceof  RenderResponse) {
052:                        RenderResponse response = (RenderResponse) r;
053:                        String prefix = response.getNamespace();
054:                        PortletURL actionURL = response.createActionURL();
055:                        //try {
056:                        //    actionURL.setWindowState(WindowState.MAXIMIZED);
057:                        //} catch (Exception e) {
058:
059:                        //}
060:                        tasksPortletUrl = actionURL;
061:                        logger
062:                                .fine("TaskListSessionBackingBean.tasksPortletUrl="
063:                                        + actionURL);
064:
065:                    }
066:                }
067:
068:            }
069:
070:            public void setViewDate(String viewDate) {
071:                try {
072:                    setViewDateTime(new DateTime(viewDate));
073:                } catch (ParseException e) {
074:                    // Ignore, will never happen
075:                }
076:            }
077:
078:            public String getViewDate() {
079:                return getViewDateTime().toISOString();
080:            }
081:
082:            public DateTime getViewDateTime() {
083:                if (viewDateTime == null) {
084:                    TaskUserSessionBackingBean userSession = (TaskUserSessionBackingBean) TaskBeanFactory
085:                            .getBean(TaskUserSessionBackingBean.BEAN_NAME);
086:
087:                    viewDateTime = new DateTime(userSession.getTimeZone());
088:                }
089:
090:                return viewDateTime;
091:            }
092:
093:            public void setViewDateTime(DateTime viewDateTime) {
094:                this .viewDateTime = viewDateTime;
095:            }
096:
097:            /**
098:             * Sets the view context, must be one of SharedConstants.VIEW_CTX_*
099:             */
100:            public void setViewContext(String viewContext) {
101:                this .viewContext = viewContext;
102:            }
103:
104:            public String getViewContext() {
105:                return viewContext;
106:            }
107:
108:            public DateTime getContextStartDateTime() {
109:                return getContextStart(getViewDateTime(), getViewContext(),
110:                        Calendar.MONDAY);
111:            }
112:
113:            public DateTime getContextEndDateTime() {
114:                return getContextEnd(getViewDateTime(), getViewContext());
115:            }
116:
117:            /** 
118:             * Sets the status filter, must be one of SharedConstants.FILTER_*
119:             */
120:            public void setStatusFilter(String statusFilter) {
121:                this .statusFilter = statusFilter;
122:            }
123:
124:            public String getStatusFilter() {
125:                return statusFilter;
126:            }
127:
128:            public void setSearchString(String searchString) {
129:                if (searchString != null && searchString.trim().length() != 0) {
130:                    this .searchString = searchString;
131:                } else {
132:                    this .searchString = null;
133:                }
134:            }
135:
136:            public String getSearchString() {
137:                return searchString;
138:            }
139:
140:            public ObjectArrayDataProvider getDataProvider() {
141:                return dataProvider;
142:            }
143:
144:            public void setDataProvider(ObjectArrayDataProvider dataProvider) {
145:                this .dataProvider = dataProvider;
146:            }
147:
148:            public int getDisplayRows() {
149:                return displayRows;
150:            }
151:
152:            public void setDisplayRows(int displayRows) {
153:                this .displayRows = displayRows;
154:            }
155:
156:            /** 
157:             * Gets the context start date-time based on the given date and 
158:             * view context value passed.
159:             * <p>
160:             * @param dt Date to be adjusted to context start
161:             * @param viewCtx View context to be used to adjust the date passed in 'dt'. Valid values are UWCConstants.VIEW_CTX_DAY, UWCConstants.VIEW_CTX_WEEK, UWCConstants.VIEW_CTX_MONTH. Default view context used is UWCConstants.VIEW_CTX_DAY in case the this value passed is null or invalid.
162:             * @param firstDayOfWeek Used in case if viewCtx is UWCConstants.VIEW_CTX_WEEK, otherwise ignored. Valid values are Calendar.SUNDAY, Calendar.MONDAY, .., Calendar.SATURDAY 
163:             * <p>
164:             * This method clones the given date and then adjust it to the start of the
165:             * specified context.
166:             * For 'day' context it returns date-time for begining of the day, for 'week' context it returns date-time for start date of the week, for 'month' context it returns date-time for start date of the month.
167:             * <p>
168:             * For 'day' context it resets the hour, minute, second, millisecond components to zero.
169:             * For 'week' context it resets the hour, minute, second, millisecond components to zero, and resets DAY_OF_WEEK component to user's calendar's week-start-day preference.
170:             * For 'month' context it resets the hour, minute, second, millisecond components to zero, and resets DAY_OF_MONTH component to 1.
171:             * <p>
172:             */
173:            private static DateTime getContextStart(DateTime dt,
174:                    String viewCtx, int firstDayOfWeek) {
175:                if (null == dt) {
176:                    return null;
177:                }
178:
179:                dt = (DateTime) dt.clone();
180:
181:                // Reset the hours, minutes, seconds and millisecond components
182:                // This is applicable for all contexts such as day, week and month.
183:                //
184:                dt.setTime(0, 0, 0);
185:                dt.set(Calendar.MILLISECOND, 0);
186:
187:                if (SharedConstants.VIEW_CTX_WEEK.equalsIgnoreCase(viewCtx)) {
188:                    int dayOfWeek = dt.get(Calendar.DAY_OF_WEEK);
189:                    int difference = ((7 + dayOfWeek - firstDayOfWeek) % 7);
190:                    dt.add(Calendar.DAY_OF_YEAR, -difference);
191:                } else if (SharedConstants.VIEW_CTX_MONTH
192:                        .equalsIgnoreCase(viewCtx)) {
193:                    dt.set(Calendar.DAY_OF_MONTH, 1);
194:                }
195:
196:                return dt;
197:            }
198:
199:            /** 
200:             * Returns the context end date-time based on the given date and 
201:             * view context value passed.
202:             * <p>
203:             * @param dt Date to be adjusted to context end
204:             * @param viewCtx View context to be used to adjust the date passed in 'dt'. Valid values are UWCConstants.VIEW_CTX_DAY, UWCConstants.VIEW_CTX_WEEK, UWCConstants.VIEW_CTX_MONTH. Default view context used is UWCConstants.VIEW_CTX_DAY in case the this value passed is null or invalid.
205:             * <p>
206:             * This method clones the given date and then adjust it to the end of the
207:             * specified context.
208:             * For 'day' context it returns date-time for ending of the day, for 'week' context it returns date-time for end date of the week, for 'month' context it returns date-time for end date of the month.
209:             * <p> 
210:             * For example, advancement will be by 1 day for day view,
211:             * 7 days for week view, one month for month view.
212:             * It substracts the 'SECOND' component by 1 so that the resultant
213:             * end date-time will fall within the boundaries of a single day or
214:             * a single week or a single month.
215:             * <p>
216:             */
217:            private static DateTime getContextEnd(DateTime dt, String viewCtx) {
218:                if (null == dt) {
219:                    return null;
220:                }
221:
222:                dt = (DateTime) dt.clone();
223:
224:                if (SharedConstants.VIEW_CTX_DAY.equalsIgnoreCase(viewCtx)) {
225:                    dt.add(Calendar.DAY_OF_YEAR, 1);
226:                    dt.add(Calendar.SECOND, -1);
227:                } else if (SharedConstants.VIEW_CTX_WEEK
228:                        .equalsIgnoreCase(viewCtx)) {
229:                    dt.add(Calendar.DAY_OF_YEAR, 7);
230:                    dt.add(Calendar.SECOND, -1);
231:                } else if (SharedConstants.VIEW_CTX_MONTH
232:                        .equalsIgnoreCase(viewCtx)) {
233:                    dt.add(Calendar.MONTH, 1);
234:                    dt.add(Calendar.SECOND, -1);
235:                } else {
236:                    dt.add(Calendar.DAY_OF_YEAR, 1);
237:                    dt.add(Calendar.SECOND, -1);
238:                }
239:
240:                return dt;
241:            }
242:
243:            public PortletURL getPortletActionUrl() {
244:                return this .tasksPortletUrl;
245:            }
246:
247:            /*
248:            public boolean isSearchResultRequested(){
249:            	boolean result = false;
250:            	FacesContext context = FacesContext.getCurrentInstance();
251:                
252:                Map requestMap = context.getExternalContext().getRequestParameterMap();
253:                String searchSt  = (String) requestMap.get(SharedConstants.URL_COMM_SEARCH_TASKS);
254:            	if ( (searchSt != null) && (Boolean.valueOf(searchSt) == Boolean.TRUE ) ) {
255:            		TaskSessionBackingBean taskSessionBean = (TaskSessionBackingBean) TaskBeanFactory.getBean(TaskSessionBackingBean.BEAN_NAME);
256:            		taskSessionBean.setEditTask();
257:                	result = taskSessionBean.getIsEdit().booleanValue();
258:            	}
259:            	logger.exiting(TaskListSessionBackingBean.BEAN_NAME,"isSearchResultRequested()="+result);
260:            	return result;
261:            	
262:            }
263:             */
264:        }
ww__w___.__j___a_v__a2__s.___c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.