📄 statedropdown.java
字号:
/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
* The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/
package com.sourcetap.sfa.address;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import com.sourcetap.sfa.ui.UIDisplayObject;
import com.sourcetap.sfa.ui.UIDropDown;
import com.sourcetap.sfa.ui.UIFieldInfo;
import com.sourcetap.sfa.ui.UIUtility;
import com.sourcetap.sfa.util.UserInfo;
/**
* DOCUMENT ME!
*
*/
public class StateDropDown extends UIDropDown {
public static final String module = StateDropDown.class.getName();
public StateDropDown() {
}
/**
* Return a list of values for a drop down using a UI Display Object defined in the data base.
* This method overrides the parent class. Note: This
* method is only used when the screen is first drawn. If the drop down list is updated dynamically, the
* getDropDownValuesDynamic method is used.
*
* @see #getDropDownValuesDynamic(GenericDelegator, Map, UserInfo)
*
* @author John Nutting
*
* @param delegator Reference to the OFBIZ delegator being used to connect to the data base
* @param uiDisplayObject Reference to a display object defined in the data base and attached to the field to be displayed by the UI builder
* @param orderDef List of fields defining the sort order of the drop down values
* @param entityDetailsVector Vector of generic values containing the values to be displayed on the screen for all fields
* @param fieldInfo Reference to field info object containing attributes of the current field
* @param userInfo Reference to user info object containing information about the currently logged-in user
*
* @return List of generic values to be displayed in the drop down. This will be null if an error occurs.
*/
public List getDropDownValues(GenericDelegator delegator,
UIDisplayObject uiDisplayObject, ArrayList orderDef,
Vector entityDetailsVector, UIFieldInfo fieldInfo, UserInfo userInfo) {
String country = UIUtility.getAttributeValue(entityDetailsVector,
"Address", "country");
HashMap map = new HashMap();
map.put("country", country);
return getDropDownValuesDynamic(delegator, map, userInfo);
}
/**
* Return a list of values based on filter criteria. This is used by the dynamic filtered drop downs
* which are modified via DHTML. This method overrides the standard method.<BR><BR>Note: This method
* is only used when the drop down is updated dynamically.
* When the screen is first displayed, the getDropDownValues method is used.
*
* @see #getDropDownValues(GenericDelegator, UIDisplayObject, ArrayList, Vector, UIFieldInfo, UserInfo)
*
* @author John Nutting
*
* @param delegator Reference to the OFBIZ delegator being used to connect to the data base
* @param filterValues Map containing field/value pairs to be used for filtering the drop down list
* @param userInfo Reference to user info object containing information about the currently logged-in user
*
* @return List of generic values to be displayed in the drop down. This will be null if an error occurs.
*/
public List getDropDownValuesDynamic(GenericDelegator delegator,
Map filterValues, UserInfo userInfo) {
ArrayList orderBy = new ArrayList();
orderBy.add("codeValue");
HashMap findMap = new HashMap();
String country = (String) filterValues.get("country");
if ((country != null)) {
// Country is selected. Return list of states for the selected country.
findMap.put("codeTypeId", "STATE");
findMap.put("parentCodeTypeId", "COUNTRY");
findMap.put("parentCodeId", country);
try {
return delegator.findByAnd("Code", findMap, orderBy);
} catch (GenericEntityException e) {
Debug.logError("Error retrieving the dropdown values: ", module);
Debug.logError(e.getLocalizedMessage(), module);
return new LinkedList();
}
} else {
// No country is selected. Return an empty list of states.
return new LinkedList();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -