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.ui;
018:
019: import java.util.ArrayList;
020: import java.util.HashMap;
021: import java.util.LinkedList;
022: import java.util.List;
023: import java.util.Map;
024: import java.util.Vector;
025:
026: import org.ofbiz.base.util.Debug;
027: import org.ofbiz.base.util.UtilMisc;
028: import org.ofbiz.entity.GenericDelegator;
029: import org.ofbiz.entity.GenericEntityException;
030:
031: import com.sourcetap.sfa.util.UserInfo;
032:
033: /**
034: * DOCUMENT ME!
035: *
036: */
037: public class UIUserDropDown extends UIDropDown {
038:
039: public static final String module = UIUserDropDown.class.getName();
040:
041: public UIUserDropDown() {
042: }
043:
044: /**
045: * Return a list of values for a drop down using a UI Display Object defined in the data base.
046: * This method overrides the parent class.
047: *
048: * @author John Nutting
049: *
050: * @param delegator Reference to the OFBIZ delegator being used to connect to the data base
051: * @param uiDisplayObject Reference to a display object defined in the data base and attached to the field to be displayed by the UI builder
052: * @param orderDef List of fields defining the sort order of the drop down values
053: * @param entityDetailsVector Vector of generic values containing the values to be displayed on the screen for all fields
054: * @param fieldInfo Reference to field info object containing attributes of the current field
055: * @param userInfo Reference to user info object containing information about the currently logged-in user
056: *
057: * @return List of generic values to be displayed in the drop down. This will be null if an error occurs.
058: */
059: public List getDropDownValues(GenericDelegator delegator,
060: UIDisplayObject uiDisplayObject, ArrayList orderDef,
061: Vector entityDetailsVector, UIFieldInfo fieldInfo,
062: UserInfo userInfo) {
063: return getDropDownValuesDynamic(delegator, new HashMap(),
064: userInfo);
065: }
066:
067: /**
068: * Return a list of values based on filter criteria. This is used by the dynamic filtered drop downs
069: * which are modified via DHTML. This method must be overridden in a desdendent class.<BR><BR>Note: This method
070: * is only used when the drop down is updated dynamically.
071: * When the screen is first displayed, the getDropDownValues method is used.
072: *
073: * @see #getDropDownValues(GenericDelegator, UIDisplayObject, ArrayList, Vector, UIFieldInfo, UserInfo)
074: *
075: * @author <a href='mailto:steve_fowler@sourcetap.com'>Steve Fowler</a>
076: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
077: *
078: * @param delegator Reference to the OFBIZ delegator being used to connect to the data base
079: * @param filterValues Map containing field/value pairs to be used for filtering the drop down list
080: * @param userInfo Reference to user info object containing information about the currently logged-in user
081: *
082: * @return List of generic values to be displayed in the drop down. This will be null if an error occurs.
083: */
084: public List getDropDownValuesDynamic(GenericDelegator delegator,
085: Map filterValues, UserInfo userInfo) {
086: ArrayList orderBy = new ArrayList();
087: orderBy.add("lastName");
088: orderBy.add("firstName");
089:
090: try {
091: return delegator.findByAnd("Contact", UtilMisc.toMap(
092: "contactTypeId", "user", "accountId", userInfo
093: .getAccountId()), orderBy);
094: } catch (GenericEntityException e) {
095: Debug
096: .logError(
097: "[UIUserDropDown.getDropDownValues] Error retrieving the dropdown values: ",
098: module);
099: Debug.logError(e.getLocalizedMessage(), module);
100:
101: return new LinkedList();
102: }
103: }
104: }
|