001: /*
002: *
003: * Copyright (c) 2004 SourceTap - www.sourcetap.com
004: *
005: * The contents of this file are subject to the SourceTap Public License
006: * ("License"); You may not use this file except in compliance with the
007: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
008: * Software distributed under the License is distributed on an "AS IS" basis,
009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
010: * the specific language governing rights and limitations under the License.
011: *
012: * The above copyright notice and this permission notice shall be included
013: * in all copies or substantial portions of the Software.
014: *
015: */
016:
017: package com.sourcetap.sfa.customization;
018:
019: import java.util.HashMap;
020:
021: import javax.servlet.http.HttpServletRequest;
022: import javax.servlet.http.HttpServletResponse;
023:
024: import org.ofbiz.entity.GenericDelegator;
025: import org.ofbiz.entity.GenericValue;
026: import org.ofbiz.entity.model.ModelEntity;
027:
028: import com.sourcetap.sfa.event.DataMatrix;
029: import com.sourcetap.sfa.event.GenericEventProcessor;
030: import com.sourcetap.sfa.event.GenericWebEventProcessor;
031: import com.sourcetap.sfa.ui.UICache;
032: import com.sourcetap.sfa.ui.UIWebScreenSection;
033: import com.sourcetap.sfa.util.UserInfo;
034:
035: /**
036: * DOCUMENT ME!
037: *
038: */
039: public class UIScreenWebEventProcessor extends GenericWebEventProcessor {
040: public static final String module = UIScreenWebEventProcessor.class
041: .getName();
042:
043: /**
044: * DOCUMENT ME!
045: *
046: * @param userInfo
047: * @param uiWebScreenSection
048: * @param request
049: * @param response
050: * @param delegator
051: * @param eventProcessor
052: * @param dataMatrix
053: * @param uiCache
054: *
055: * @return
056: */
057: protected int postUpdate(UserInfo userInfo,
058: UIWebScreenSection uiWebScreenSection,
059: HttpServletRequest request, HttpServletResponse response,
060: GenericDelegator delegator,
061: GenericEventProcessor eventProcessor,
062: DataMatrix dataMatrix, UICache uiCache) {
063:
064: // Clear UI cache.
065: uiCache.clear();
066:
067: // Clear the cache holding the drop down values so this new screen will show up correctly in the UI Screen
068: // drop down on the screen section header.
069: delegator.getAllCache().clear();
070:
071: return STATUS_CONTINUE;
072: }
073:
074: /**
075: * DOCUMENT ME!
076: *
077: * @param userInfo
078: * @param uiWebScreenSection
079: * @param request
080: * @param response
081: * @param delegator
082: * @param eventProcessor
083: * @param dataMatrix
084: * @param uiCache
085: *
086: * @return
087: */
088: protected int postInsert(UserInfo userInfo,
089: UIWebScreenSection uiWebScreenSection,
090: HttpServletRequest request, HttpServletResponse response,
091: GenericDelegator delegator,
092: GenericEventProcessor eventProcessor,
093: DataMatrix dataMatrix, UICache uiCache) {
094:
095: // Clear UI cache.
096: uiCache.clear();
097:
098: // Clear the cache holding the drop down values so this new screen will show up in the UI Screen
099: // drop down on the screen section header.
100: delegator.getAllCache().clear();
101:
102: return STATUS_CONTINUE;
103: }
104:
105: /**
106: * DOCUMENT ME!
107: *
108: * @param userInfo
109: * @param uiWebScreenSection
110: * @param request
111: * @param response
112: * @param delegator
113: * @param eventProcessor
114: * @param primaryME
115: * @param fields
116: * @param uiCache
117: *
118: * @return
119: */
120: protected int postDelete(UserInfo userInfo,
121: UIWebScreenSection uiWebScreenSection,
122: HttpServletRequest request, HttpServletResponse response,
123: GenericDelegator delegator,
124: GenericEventProcessor eventProcessor,
125: ModelEntity primaryME, HashMap fields, UICache uiCache) {
126: // Clear UI cache.
127: uiCache.clear();
128:
129: // Clear the cache holding the drop down values so this new screen will no longer show up in the UI Screen
130: // drop down on the screen section header.
131: delegator.getAllCache().clear();
132:
133: return STATUS_CONTINUE;
134: }
135:
136: /**
137: * This function gets the application path to be used to reconstruct the URI when a
138: * UI History record is logged. Example: "/accounts"
139: * @author John Nutting
140: * @param url The URL used to open the screen section
141: * @return String containing the application path
142: */
143: protected String getUiHistoryAppPath(String url) {
144: return "/uiScreen";
145: }
146:
147: /**
148: * This function gets the description to store in the UI history table. This description
149: * will show up in the UI History drop list.
150: * @author John Nutting
151: * @param dataMatrix DataMatrix object containing the data from the screen
152: * @param delegator Generic delegator through which the data base is accessed
153: * @param action The action being performed on the screen
154: * @param uiWebScreenSection The UIWebScreenSection being used to construct the screen section
155: * @return String containing the UI History description
156: */
157: protected String getUiHistoryDescription(DataMatrix dataMatrix,
158: GenericDelegator delegator, String action,
159: UIWebScreenSection uiWebScreenSection) {
160: GenericValue primaryGV = dataMatrix.getCurrentBuffer()
161: .getGenericValue(0, 0);
162:
163: return "Screen: " + primaryGV.getString("screenName");
164: }
165: }
|