📄 uidropdown.java
字号:
* @param fieldValue Value of field being displayed
* @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 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
* @param linkGenericValue Generic value returned to calling method
*
* @return One-dimensional array with 2 elements containing the data value and the display value.
*/
public String[] getValuePair(String fieldValue, GenericDelegator delegator,
UIDisplayObject uiDisplayObject, Vector entityDetailsVector,
UIFieldInfo fieldInfo, UserInfo userInfo, GenericValue linkGenericValue) {
linkGenericValue = getReadOnlyValue(fieldValue,
fieldInfo.getUiAttribute().getAttributeName(), uiDisplayObject,
entityDetailsVector, delegator);
return decodeValue(uiDisplayObject.getAttribEntityValueDef(),
uiDisplayObject.getAttribEntityDisplayDef(),
fieldInfo.getUiAttribute().getAttributeName(), linkGenericValue);
}
/**
* 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 must be overridden in a desdendent class.<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 <a href='mailto:steve_fowler@sourcetap.com'>Steve Fowler</a>
* @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
*
* @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) {
return new LinkedList();
}
/**
* Produces an HTML string to display the drop down on a web page being built by the UIWebScreenSection class.
* If the screen is being displayed in read-only mode, this method looks up the specified name value using the
* current value as the primary key, and displays the looked up name instead of a drop down.
*
* @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
*
* @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 protect Defines wether to show the current field in protected (read-only)_ mode
* @param htmlName The name to be used for the current field in the HTML
* @param fieldValue Value stored or to be stored in the data base
* @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 action Action string defining the current screen mode. See UIScreenSection for possible values.
* @param tabIndex Tab index (tab order) of the current field on the HTML form
* @param userInfo Reference to user info object containing information about the currently logged-in user
* @param delegator Reference to the OFBIZ delegator being used to connect to the data base
*
* @return String containing the HTML text that will draw the current field on the web page
*
* @see com.sourcetap.sfa.ui.UIWebScreenSection
*/
public String displayFieldHtml(UIDisplayObject uiDisplayObject,
boolean protect, String htmlName, String fieldValue,
Vector entityDetailsVector, UIFieldInfo fieldInfo, String action,
int tabIndex, UserInfo userInfo, GenericDelegator delegator) {
StringBuffer displayHtml = new StringBuffer();
// Build a drop down list.
if (uiDisplayObject.getAttribFillMethod().equals("ENTITY")) {
// Need to build the list using entity data from the data base.
if (!protect) {
// Mode is not protected, so create a drop down.
Debug.logVerbose("Starting to create a drop down.", module);
if (uiDisplayObject.getAttribEntityValueDef().trim().equals("")) {
// Value definition not specified.
// Just create a hidden field AND show the value as text in the table cell.
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue, fieldValue,
entityDetailsVector));
Debug.logWarning(
"[UIDropDown.displayField]: Attribute ENTITY_VALUE_DEF not specified in display object.", module);
return displayHtml.toString();
}
if (uiDisplayObject.getAttribEntityDisplayDef().trim().equals("")) {
// Display definition not specified.
// Just create a hidden field AND show the value as text in the table cell.
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue, fieldValue,
entityDetailsVector));
Debug.logWarning(
"[UIDropDown.displayField]: Attribute ENTITY_DISPLAY_DEF not specified in display object.", module);
return displayHtml.toString();
}
ArrayList orderDef = null;
if (!uiDisplayObject.getAttribEntityOrderDef().trim().equals("")) {
orderDef = new ArrayList();
orderDef.add(uiDisplayObject.getAttribEntityOrderDef());
}
// Find the entities for the list, and put them in a 2-dimensional array
String[][] valuePairArray = getValuePairArray(delegator,
uiDisplayObject, orderDef, entityDetailsVector,
fieldInfo, userInfo);
if (valuePairArray == null) {
// An error occurred while getting the drop down values. Just show the field value as read-only.
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue, fieldValue,
entityDetailsVector));
return displayHtml.toString();
}
boolean showMultiple = false;
if (action.equals(UIScreenSection.ACTION_SHOW_QUERY)) {
// Show a multi-select list box if the screen is being displayed in query mode.
//showMultiple = true;
showMultiple = false; // changed due to creation of advanced query mode.
}
// Append the HTML for the SELECT.
displayHtml.append(getSelectHtml(htmlName, tabIndex,
uiDisplayObject.getAttribSize(),
uiDisplayObject.getAttribDisabled(),
uiDisplayObject.getAttribClass(action,
fieldInfo.getIsMandatory()),
uiDisplayObject.getAttribEmptyFirst(action),
uiDisplayObject.getAttribEventHandling(),
valuePairArray, fieldValue, showMultiple));
if (fieldInfo.getIsMandatory() &&
!action.equals(UIScreenSection.ACTION_SHOW_QUERY) &&
!action.equals(UIScreenSection.ACTION_SHOW_QUERY_REPORT) &&
!action.equals(UIScreenSection.ACTION_SHOW_REPORT)) {
displayHtml.append("*\n");
}
return displayHtml.toString();
} else {
// User can't edit right now, so there's no point in showing the list. Just look up the
// the display value and show it.
GenericValue linkGenericValue = null;
String[] valuePair = getValuePair(fieldValue, delegator,
uiDisplayObject, entityDetailsVector, fieldInfo,
userInfo, linkGenericValue);
if (valuePair == null) {
// An error occurred while getting the read only value. Just show the field value as read-only.
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue, fieldValue,
new Vector()));
return displayHtml.toString();
}
displayHtml.append(getSelectHtmlReadOnly(fieldValue, htmlName,
fieldInfo.getUiAttribute().getAttributeName(),
uiDisplayObject, valuePair,
UIWebUtility.translateAttribAnchorHrefDef(
uiDisplayObject.getAttribAnchorHrefDef(),
entityDetailsVector,
fieldInfo.getUiAttribute().getAttributeName()),
UIWebUtility.translateAttribAnchorTarget(
uiDisplayObject.getAttribAnchorTarget()), delegator));
return displayHtml.toString();
}
} else if (uiDisplayObject.getAttribFillMethod().equals("FIXED")) {
// Build the list using the fixed values.
// *** Not completed ***
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue, fieldValue,
entityDetailsVector));
return displayHtml.toString();
} else {
// Invalid Fill Method. Just create a hidden field AND show the value as text in the table cell.
Debug.logWarning(
"[UIDropDown.displayField()] Fill method for field " +
htmlName + "(" + uiDisplayObject.getDisplayObjectId() + ") is invalid: " +
uiDisplayObject.getAttribFillMethod(), module);
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue, fieldValue,
entityDetailsVector));
return displayHtml.toString();
}
}
/**
* Produces an HTML string to display the drop down on a web page.
* <P>
* This method does not need a reference to the delegator since it does not connect to the data base.
* The values are passed in the genericValueVectorList parameter. This method also does not need
* a reference to a UIDisplayObject or a UIFieldInfo, so it can be used separately from the UI Builder
* if required.
*
* @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
*
* @param htmlName The name to be used for the current field in the HTML
* @param tabIndex Tab index (tab order) of the current field on the HTML form
* @param attribSize String for the HTML SIZE attribute to be inserted into the < SELECT >
* @param attribDisabled String for the HTML SIZE attribute to be inserted into the < SELECT >
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -