📄 datamatrix.java
字号:
String attributeName = getAttributeName(entityNbr, attributeNbr);
String rowDotEntityDotAttribName = String.valueOf(row) + "." +
entityName + "." + attributeName;
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Start processing attribute " +
rowDotEntityDotAttribName);
}
String originalParamName = UIWebUtility.getParamName(UIWebUtility.HTML_NAME_PREFIX_ORIGINAL,
uiScreenSection.getSectionName(), entityName,
attributeName, row);
String currentParamName = UIWebUtility.getParamName(UIWebUtility.HTML_NAME_PREFIX_CURRENT,
uiScreenSection.getSectionName(), entityName,
attributeName, row);
if (request.getParameter(originalParamName) != null) {
// This attribute exists in "original" hidden fields in the HTML data. Continue to process it.
boolean currentFound = false;
if (request.getParameter(currentParamName) == null) {
// Attribute does not appear in the "current" parameters. It could be excluded, or it could
// be a check box, which would not appear if it is not checked. Continue, but don't set flag.
} else {
// Attribute appears in the "current" parameters.
currentFound = true;
}
// We will need to determine whether this field is a check box. Get the field info.
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Start getting UIFieldInfo for " +
rowDotEntityDotAttribName);
}
UIFieldInfo uiFieldInfo = uiScreenSection.getUiField(entityName,
attributeName);
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Finished getting UIFieldInfo for " +
rowDotEntityDotAttribName);
}
if ((uiFieldInfo != null) &&
(uiFieldInfo.getDisplayOrder() > 0)) {
// The field info was found. Get the display object.
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Start getting UIDisplayObject for " +
rowDotEntityDotAttribName);
}
UIDisplayObject uiDisplayObject = uiFieldInfo.getUiDisplayObject();
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Finished getting UIDisplayObject for " +
rowDotEntityDotAttribName);
}
// Find out if this field is a check box. If so, need to use special handling.
boolean isCheckbox = false;
if (uiDisplayObject.getDisplayTypeId().equals(uiDisplayObject.DISPLAY_TYPE_CHECKBOX)) {
isCheckbox = true;
}
// Make sure the current value was found in the HTML, or that this is a checkbox field,
// which would not appear in the HTML if its box is not checked.
if (currentFound || isCheckbox) {
if (isCheckbox) {
// Need to load the display object attributes when there is a check box attribute.
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Start getting UIDisplayObject attributes for " +
rowDotEntityDotAttribName);
}
uiDisplayObject.loadAttributes();
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Finished getting UIDisplayObject attributes for " +
rowDotEntityDotAttribName);
}
}
// Get the original value and store it in the "original" buffer.
String originalAttributeValue = request.getParameter(originalParamName);
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Start getDataType for " +
rowDotEntityDotAttribName);
}
String fieldType = EventUtility.getDataType(originalGV,
attributeName, getDelegator());
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] End getDataType for " +
rowDotEntityDotAttribName);
}
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Start storeValue original for " +
rowDotEntityDotAttribName);
}
EventUtility.storeValue(originalGV, attributeName,
originalAttributeValue, getDelegator(),
fieldType);
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] End storeValue original for " +
rowDotEntityDotAttribName);
}
if (!currentFound) {
// Attribute does not appear in the "current" HTML parameters. It must be a checkbox, or this code
// would not be executing. Get the unchecked value, and store it in the buffer.
EventUtility.storeValue(currentGV,
attributeName,
uiDisplayObject.getAttribUncheckedValue(),
getDelegator(), fieldType);
} else {
// Attribute does appear in the "current" HTML parameters.
if (isCheckbox) {
// This is a checked checkbox. Get the checked value, and store it in the current buffer.
EventUtility.storeValue(currentGV,
attributeName,
uiDisplayObject.getAttribCheckedValue(),
getDelegator(), fieldType);
} else {
// Non-checkbox field. Just store the value.
String currentAttributeValue = request.getParameter(currentParamName);
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Calling storeValue for " +
rowDotEntityDotAttribName);
}
EventUtility.storeValue(currentGV,
attributeName, currentAttributeValue,
getDelegator(), fieldType);
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromHTML] Finished storeValue for " +
rowDotEntityDotAttribName);
}
}
}
}
}
}
}
}
// Store the new row in each buffer.
getCurrentBuffer().addContentsRow(currentRow);
getOriginalBuffer().addContentsRow(originalRow);
// Check for delete flag for the new row.
if (request.getParameter("deleteFlag" + String.valueOf(row)) != null) {
// The user specified for this row to be deleted. Set the delete flag to true for this row.
addDeleteFlag(true);
} else {
// Either there was no delete check box, or it was not checked. Set delete flag to false for this row.
addDeleteFlag(false);
}
if (TIMER) {
utilTimer.timerString(4, "[DataMatrix.addRowFromHTML] End");
}
return;
}
public void addRowFromArray( int row, Vector dataValues, Vector importFields, UIScreenSection uiScreenSection)
throws GenericEntityException
{
UtilTimer utilTimer = new UtilTimer();
if (TIMER) {
utilTimer.timerString(4, "[DataMatrix.addRowFromArray] Start");
}
// Create an empty row to be updated and stored in the current and original buffers.
Vector currentRow = getCurrentBuffer().getContentsRow(0);
Vector originalRow = getOriginalBuffer().getContentsRow(0);
if ( currentRow == null)
{
currentRow = getCurrentBuffer().createEmptyRow();
}
if ( originalRow == null )
{
originalRow = getOriginalBuffer().createEmptyRow();
}
for (int fieldNum = 0; fieldNum < dataValues.size(); fieldNum++) {
String paramName = (String) importFields.get(fieldNum);
if ((paramName == null) || (paramName.length() == 0)) {
continue;
}
String paramEntityName = UIWebUtility.getEntityFromParamName(paramName);
String paramAttributeName = UIWebUtility.getAttribFromParamName(paramName);
String paramDataValue = (String) dataValues.get(fieldNum);
// Loop through the entities and attributes for the current screen section, and get the value
// from the request object for each one, and store it in the contents.
for (int entityNbr = 0; entityNbr < getEntityParamVector().size();
entityNbr++) {
String entityName = getEntityName(entityNbr);
if (TIMER) {
utilTimer.timerString(4,
"[DataMatrix.addRowFromArray] Start processing entity " +
String.valueOf(entityNbr) + " (" + entityName + ")");
}
if (entityName.equals(paramEntityName)) {
// Get references to the orginal and current generic values for this entity.
GenericValue currentGV = (GenericValue) (currentRow.get(entityNbr));
String fieldType = EventUtility.getDataType(currentGV,
paramAttributeName, getDelegator());
EventUtility.storeValue(currentGV, paramAttributeName,
paramDataValue, getDelegator(), fieldType);
}
}
}
// Store the new row in each buffer.
getCurrentBuffer().setContentsRow(0,currentRow);
getOriginalBuffer().setContentsRow(0,originalRow);
if (TIMER) {
utilTimer.timerString(4, "[DataMatrix.addRowFromArray] End");
}
return;
}
/**
* DOCUMENT ME!
*
* @param row
* @param request
* @param dataValues
* @param importFields
* @param uiScreenSection
*
* @throws GenericEntityException
*/
public void addRowFromArray(int row, String[] dataValues, Vector importFields,
UIScreenSection uiScreenSection) throws GenericEntityException {
Vector values = new Vector( Arrays.asList( dataValues ) );
addRowFromArray(row, values, importFields, uiScreenSection);
return;
}
/**
* DOCUMENT ME!
*
* @param row
*
* @return
*/
public boolean getRowChanged(int row) {
// Compare all fields in the current generic value with the ones in the original generic value
// to see if the user changed any values in the current row.
Vector currentRow = getCurrentBuffer().getContentsRow(row);
Vector originalRow = getOriginalBuffer().getContentsRow(row);
boolean rowChanged = false;
for (int entityNumber = 0; entityNumber < currentRow.size();
entityNumber++) {
if (getIsUpdateable(entityNumber)) {
// This entity is updateable. See if any values changed in its generic value.
GenericValue currentGV = (GenericValue) currentRow.get(entityNumber);
GenericValue originalGV = (GenericValue) originalRow.get(entityNumber);
if (!currentGV.equals(originalGV)) {
rowChanged = true;
break;
}
}
}
return rowChanged;
}
public static DataMatrix fillFromDB(GenericDelegator delegator, UserInfo userInfo, UIScreenSection uiScreenSection,
GenericEventProcessor eventProcessor, GenericPK primaryKey)
{
try {
DataMatrix dataMatrix = new DataMatrix(delegator,
uiScreenSection.getEntityParamVector());
String primaryEntityName = uiScreenSection.getUiScreenSectionEntity(0).getUiEntity().getEntityName();
// Specify how the primary entity will be retrieved.
ArrayList orderBy = new ArrayList();
QueryInfo queryInfo = new QueryInfo(delegator, primaryEntityName);
Enumeration params = null;
String searchAttribValue = "";
String searchEntityName = "";
String searchAttribName = "";
String queryName = "";
EntityComparisonOperator entityOperator = null;
List relatedSearchClauses = new LinkedList();
List primaryPkFieldNames = uiScreenSection.getUiScreenSectionEntity(0).getUiEntity().getPrimaryKeyFieldNames();
Map fields = primaryKey.getAllFields();
// Specify how associated entities will be retrieved.
Iterator uiScreenSectionEntityI = uiScreenSection.getUiScreenSectionEntityList()
.iterator();
uiScreenSectionEntityI.next(); // Pass up the primary entity.
while (uiScreenSectionEntityI.hasNext()) {
UIScreenSectionEntity uiScreenSectionEntity = (UIScreenSectionEntity) uiScreenSectionEntityI.next();
relatedSearchClauses.add(uiScreenSectionEntity);
}
uiScreenSectionEntityI = null; // Reset the iterator.
// Specify the sort order.
orderBy = new DelimitedValueDecoder(uiScreenSection.getSortDef()).decode();
eventProcessor.processRetrieve(userInfo, primaryEntityName,
eventProcessor.RETRIEVE_METHOD_PK, fields, orderBy, queryInfo,
relatedSearchClauses, delegator, dataMatrix);
return dataMatrix;
}
catch (Exception e)
{
Debug.logError(e,module);
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -