001: /*
002: * EventsListBackingBean.java
003: *
004: * Created on April 15, 2005, 3:25 PM
005: */
006:
007: package com.sun.portal.app.sharedevents.faces;
008:
009: import com.sun.portal.app.sharedevents.util.SharedConstants;
010: import java.beans.*;
011: import java.io.Serializable;
012: import java.util.ArrayList;
013: import java.util.Map;
014:
015: import com.sun.portal.app.sharedevents.models.EventsListModel;
016: import com.sun.portal.app.sharedevents.util.AppUtils;
017: import java.util.logging.Logger;
018: import java.util.logging.Level;
019:
020: import javax.faces.context.FacesContext;
021: import javax.portlet.PortletURL;
022: import javax.portlet.RenderResponse;
023:
024: import com.sun.portal.log.common.PortalLogger;
025:
026: //import com.sun.portal.log.common.PortalLogger;
027:
028: /**
029: * @author SaiSatish Vedam
030: */
031: public class EventsListBackingBean extends Object implements
032: Serializable {
033:
034: private transient String CLASS_NAME = "EventsListBackingBean";
035:
036: private String sampleProperty;
037:
038: private PropertyChangeSupport propertySupport;
039:
040: private EventsTableContainer tableContainer = null;
041: private ArrayList eventsList = null;
042: private String alertType = null;
043: private String alertMsg = null;
044: private String alertMsgDetail = null;
045: private String searchFilter = null;
046: private boolean success = true;
047: private boolean showAlert = false;
048:
049: private static Logger logger = PortalLogger
050: .getLogger(EventsListBackingBean.class);
051:
052: public EventsListBackingBean() {
053:
054: logger.entering(CLASS_NAME, "EventsListBackingBean()");
055:
056: if (logger.isLoggable(Level.FINE)) {
057: logger.fine("Constructing EventsListBackingBean...");
058: }
059:
060: /**
061: * setting the portlet action url in session.
062: * It will be used while a events is submitted to search server
063: */
064:
065: FacesContext context = FacesContext.getCurrentInstance();
066:
067: Map sessionMap = context.getExternalContext().getSessionMap();
068: Object obj = sessionMap
069: .get(SharedConstants.URL_EVENT_PORTLET_ACTION);
070: if (obj == null) {
071: Object r = context.getExternalContext().getResponse();
072: if (r instanceof RenderResponse) {
073: RenderResponse response = (RenderResponse) r;
074: String prefix = response.getNamespace();
075: PortletURL actionURL = response.createActionURL();
076: //try {
077: // actionURL.setWindowState(WindowState.MAXIMIZED);
078: //} catch (Exception e) {
079:
080: //}
081: sessionMap.put(
082: SharedConstants.URL_EVENT_PORTLET_ACTION,
083: actionURL);
084: logger.fine(SharedConstants.URL_EVENT_PORTLET_ACTION
085: + "=" + actionURL);
086:
087: }
088: }
089:
090: //Check if it needs to display Search Results
091: AppUtils.hasSearchResultsInURL();
092:
093: tableContainer = new EventsTableContainer();
094: logger.exiting(CLASS_NAME, "EventsListBackingBean()");
095:
096: }
097:
098: public boolean getRenderTitle() {
099: success = getTableContainer().getRenderTable();
100: return success;
101: }
102:
103: public boolean getShowAlert() {
104: showAlert = getTableContainer().getShowAlert();
105: return showAlert;
106:
107: }
108:
109: public String getAlertMessage() {
110: alertMsg = getTableContainer().getAlertMessage();
111: return alertMsg;
112:
113: }
114:
115: public String getAlertType() {
116: alertType = getTableContainer().getAlertType();
117: return alertType;
118:
119: }
120:
121: public String getAlertMessageDetail() {
122: alertMsgDetail = getTableContainer().getAlertMessageDetail();
123: return alertMsgDetail;
124:
125: }
126:
127: private EventsListModel getEventsListModel() {
128: EventsListModel m = new EventsListModel("EventsListBackingBean");
129: return m;
130: }
131:
132: public EventsTableContainer getTableContainer() {
133: if (tableContainer == null) {
134: if (logger.isLoggable(Level.FINE)) {
135: logger.fine("tableContainer is null!");
136: }
137: }
138: return tableContainer;
139: }
140:
141: public String getSearchFilter() {
142: return searchFilter;
143: }
144:
145: public void setSearchFilter(String value) {
146: searchFilter = value;
147: }
148:
149: public void handleSearch() {
150:
151: logger.entering(CLASS_NAME, "handleSearch()");
152:
153: /*
154: tableContainer.setSearchInvoked(true);
155: tableContainer.setSearchFilter(searchFilter);
156: tableContainer.setViewContext(SharedConstants.VIEW_CTX_SEARCH);
157: */
158:
159: AppUtils.setAttributeInSession(
160: SharedConstants.SESSION_REFRESH_DATA, "true");
161: AppUtils.setAttributeInSession(
162: SharedConstants.SESSION_CURR_VIEW_CTX,
163: SharedConstants.VIEW_CTX_SEARCH);
164: AppUtils.setAttributeInSession(
165: SharedConstants.SESSION_EVENTS_SEARCH_STRING,
166: searchFilter);
167:
168: // Remove context, context start & end from session
169: AppUtils
170: .removeAttributeFromSession(SharedConstants.SESSION_CURR_VIEW_CTX_START);
171: AppUtils
172: .removeAttributeFromSession(SharedConstants.SESSION_CURR_VIEW_CTX_END);
173:
174: logger.exiting(CLASS_NAME, "handleSearch()");
175:
176: }
177:
178: public void handleReset() {
179: logger.entering(CLASS_NAME, "handleReset()");
180: /*
181: tableContainer.setSearchInvoked(false);
182: tableContainer.setResetSearchInvoked(true);
183: tableContainer.setViewContext(SharedConstants.VIEW_CTX_DAY);
184: */
185: AppUtils.setAttributeInSession(
186: SharedConstants.SESSION_REFRESH_DATA, "true");
187: AppUtils.setAttributeInSession(
188: SharedConstants.SESSION_CURR_VIEW_CTX,
189: SharedConstants.VIEW_CTX_DAY);
190:
191: AppUtils
192: .removeAttributeFromSession(SharedConstants.SESSION_EVENTS_SEARCH_STRING);
193: AppUtils
194: .removeAttributeFromSession(SharedConstants.SESSION_CURR_VIEW_CTX_START);
195: AppUtils
196: .removeAttributeFromSession(SharedConstants.SESSION_CURR_VIEW_CTX_END);
197: AppUtils
198: .removeAttributeFromSession(SharedConstants.SESSION_CURR_VIEW_CTX);
199:
200: searchFilter = null;
201: logger.exiting(CLASS_NAME, "handleReset()");
202:
203: }
204:
205: /** This method returns true when the results from community search is clicked.
206: * Otherwise it is false.
207: *
208: */
209:
210: public boolean isShowEventDetail() {
211: boolean result = false;
212: if ((AppUtils
213: .getSessionAttribute(SharedConstants.SESSION_CURR_EVENT_UID) != null)
214: && (AppUtils
215: .getSessionAttribute(SharedConstants.SESSION_COMMUNITY_EVENT_SEARCH) != null)) {
216: result = true;
217: }
218: logger.exiting(CLASS_NAME, "isShowEventDetail().result="
219: + result);
220: return result;
221: }
222:
223: public boolean isShowEventsList() {
224: boolean result = true;
225: result = (!isShowEventDetail());
226: logger.exiting(CLASS_NAME, "isShowEventsList().result="
227: + result);
228: return result;
229: }
230:
231: }
|