01: /*
02: *
03: * Copyright (c) 2004 SourceTap - www.sourcetap.com
04: *
05: * The contents of this file are subject to the SourceTap Public License
06: * ("License"); You may not use this file except in compliance with the
07: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
08: * Software distributed under the License is distributed on an "AS IS" basis,
09: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
10: * the specific language governing rights and limitations under the License.
11: *
12: * The above copyright notice and this permission notice shall be included
13: * in all copies or substantial portions of the Software.
14: *
15: */
16:
17: package com.sourcetap.sfa.ui;
18:
19: import java.util.ArrayList;
20: import java.util.LinkedList;
21: import java.util.List;
22: import java.util.Vector;
23:
24: import org.ofbiz.base.util.Debug;
25: import org.ofbiz.base.util.UtilMisc;
26: import org.ofbiz.entity.GenericDelegator;
27: import org.ofbiz.entity.GenericEntityException;
28: import org.ofbiz.entity.condition.EntityConditionList;
29: import org.ofbiz.entity.condition.EntityExpr;
30: import org.ofbiz.entity.condition.EntityOperator;
31:
32: import com.sourcetap.sfa.util.UserInfo;
33:
34: /**
35: * DOCUMENT ME!
36: *
37: */
38: public class UIAccountTypeDropDown extends UIDropDown {
39: public static final String module = UIAccountTypeDropDown.class
40: .getName();
41:
42: public UIAccountTypeDropDown() {
43: }
44:
45: /**
46: * Return a list of values for a drop down using a UI Display Object defined in the data base.
47: * This method overrides the parent class. Note: This
48: * method is only used when the screen is first drawn. If the drop down list is updated dynamically, the
49: * getDropDownValuesDynamic method is used.
50: *
51: * @see #getDropDownValuesDynamic(GenericDelegator, Map, UserInfo)
52: *
53: * @author John Nutting
54: *
55: * @param delegator Reference to the OFBIZ delegator being used to connect to the data base
56: * @param uiDisplayObject Reference to a display object defined in the data base and attached to the field to be displayed by the UI builder
57: * @param orderDef List of fields defining the sort order of the drop down values
58: * @param entityDetailsVector Vector of generic values containing the values to be displayed on the screen for all fields
59: * @param fieldInfo Reference to field info object containing attributes of the current field
60: * @param userInfo Reference to user info object containing information about the currently logged-in user
61: *
62: * @return List of generic values to be displayed in the drop down. This will be null if an error occurs.
63: */
64: public List getDropDownValues(GenericDelegator delegator,
65: UIDisplayObject uiDisplayObject, ArrayList orderDef,
66: Vector entityDetailsVector, UIFieldInfo fieldInfo,
67: UserInfo userInfo) {
68:
69: try {
70: EntityConditionList condition = new EntityConditionList(
71: UtilMisc.toList(new EntityExpr("codeId",
72: EntityOperator.NOT_EQUAL, "base"),
73: new EntityExpr("codeTypeId",
74: EntityOperator.EQUALS,
75: "ACCOUNT_TYPE")),
76: EntityOperator.AND);
77: return delegator.findByCondition("Code", condition, null,
78: UtilMisc.toList("codeValue"));
79: } catch (GenericEntityException e) {
80: Debug
81: .logError(
82: "[UIAccountTypeDropDown.getDropDownValues] Error retrieving the dropdown values: ",
83: module);
84: Debug.logError(e.getLocalizedMessage(), module);
85:
86: return new LinkedList();
87: }
88: }
89: }
|