/*
*
* 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.ui;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilFormatOut;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilTimer;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericPK;
import org.ofbiz.entity.GenericValue;
import com.sourcetap.sfa.event.DataMatrix;
import com.sourcetap.sfa.util.Preference;
import com.sourcetap.sfa.util.StringHelper;
import com.sourcetap.sfa.util.UserInfo;
/**
* DOCUMENT ME!
*
*/
public class UIWebScreenSection extends UIScreenSection {
public static final String module = UIWebScreenSection.class.getName();
private static final boolean WEB_DEBUG = false;
private static final boolean TIMER = false;
protected final String IMAGE_COPY = "/sfaimages/Copy24.gif";
protected final String IMAGE_DELETE = "/sfaimages/Delete24.gif";
protected final String IMAGE_EDIT = "/sfaimages/Edit24.gif";
protected final String IMAGE_FIND = "/sfaimages/Find24.gif";
protected final String IMAGE_NEW = "/sfaimages/New24.gif";
protected final String IMAGE_OPEN = "/sfaimages/Open24.gif";
protected final String IMAGE_PRINT = "/sfaimages/Print24.gif";
protected final String IMAGE_PROPERTIES = "/sfaimages/Properties24.gif";
protected final String IMAGE_SAVE = "/sfaimages/Save24.gif";
protected final String IMAGE_SEARCH = "/sfaimages/Search24.gif";
protected final String IMAGE_SELECT = "/sfaimages/Refresh24.gif";
protected final String IMAGE_STOP = "/sfaimages/Stop24.gif";
protected final String IMAGE_ZOOM = "/sfaimages/Zoom24.gif";
protected final String IMAGE_ZOOM_SELECTED = "/sfaimages/Zoom24Selected.gif";
protected final String IMAGE_COPY_DISABLED = "/sfaimages/Copy24Disabled.gif";
protected final String IMAGE_DELETE_DISABLED = "/sfaimages/Delete24Disabled.gif";
protected final String IMAGE_EDIT_DISABLED = "/sfaimages/Edit24Disabled.gif";
protected final String IMAGE_FIND_DISABLED = "/sfaimages/Find24Disabled.gif";
protected final String IMAGE_NEW_DISABLED = "/sfaimages/New24Disabled.gif";
protected final String IMAGE_OPEN_DISABLED = "/sfaimages/Open24Disabled.gif";
protected final String IMAGE_PRINT_DISABLED = "/sfaimages/Print24Disabled.gif";
protected final String IMAGE_PROPERTIES_DISABLED = "/sfaimages/Properties24Disabled.gif";
protected final String IMAGE_SAVE_DISABLED = "/sfaimages/Save24Disabled.gif";
protected final String IMAGE_SEARCH_DISABLED = "/sfaimages/Search24Disabled.gif";
protected final String IMAGE_SELECT_DISABLED = "/sfaimages/Refresh24Disabled.gif";
protected final String IMAGE_STOP_DISABLED = "/sfaimages/Stop24Disabled.gif";
protected final String IMAGE_ZOOM_DISABLED = "/sfaimages/Zoom24Disabled.gif";
// protected final int FREE_FORM_ROW_HEIGHT = 16;
// protected final int FREE_FORM2_ROW_HEIGHT = 16;
// used for handling large result sets. start and end row can be set prior to calling display in order to handle
// paging of data.
protected int firstVisibleRow = 0;
protected boolean hasPriorPage = false;
protected boolean hasNextPage = false;
protected int priorPageStartRow = 0;
protected int nextPageStartRow = 0;
protected int totalRows = 0;
protected String queryMode = "standard";
public UIWebScreenSection(UserInfo userInfo, String screenName,
String sectionName, GenericDelegator delegator, UICache uiCache)
throws GenericEntityException {
super(userInfo, screenName, sectionName, delegator, uiCache);
}
/**
* DOCUMENT ME!
*
* @param rows
*/
public void setTotalRows(int rows) {
totalRows = rows;
}
/**
* DOCUMENT ME!
*
* @param dataMatrix
* @param action
* @param sectionTitle
* @param isSubsection
* @param tabOffset
*
* @return
*
* @throws GenericEntityException
*/
public String displayFreeFormSection(DataMatrix dataMatrix, String action,
String sectionTitle, boolean isSubsection, int tabOffset)
throws GenericEntityException {
UtilTimer timer = new UtilTimer();
if (TIMER) {
timer.timerString(1,
"[UIWebScreenSection.displayFreeFormSection] Start");
}
Debug.logVerbose("[displayFreeFormSection] Start", module);
Vector entityDetailsVector = dataMatrix.getCurrentBuffer()
.getContentsRow(0);
GenericValue primaryEntityDetails = dataMatrix.getCurrentBuffer()
.getGenericValue(0, 0);
Debug.logVerbose("[displayFreeFormSection()] Primary entity name: " +
primaryEntityDetails.getEntityName(), module);
StringBuffer displayHtml = new StringBuffer(5000);
// Get the key values so the form can pass them to the next page for the 4 buttons.
String keyParams = UIWebUtility.getHiddenArgs(getButtonKeyMap(),
entityDetailsVector, " ");
// Get the extra query parameters so the form can pass them to the next page.
String sendQueryParams = UIWebUtility.getHiddenArgs(getSendQueryParameterValueMap(),
" ");
Debug.logVerbose("[displayFreeFormSection] sendQueryParams: " +
sendQueryParams, module);
String keyUrlArgs = UIWebUtility.getUrlArgs(getButtonKeyMap(),
entityDetailsVector);
String queryUrlArgs = UIWebUtility.getUrlArgs(getSendQueryParameterMap(),
entityDetailsVector);
// Append script to refresh the list or detail section when this free form section is saved.
if (!getDetailButtonTarget().equals("") && !isSubsection &&
(action.equals(ACTION_UPDATE) || action.equals(ACTION_INSERT) ||
action.equals(ACTION_DELETE))) {
displayHtml.append(
"<SCRIPT FOR=\"window\" EVENT=\"onload\" LANGUAGE=\"JavaScript\">\n");
if (WEB_DEBUG) {
displayHtml.append(" alert('parent." +
getDetailButtonTarget() + ".location.href = ' + parent." +
getDetailButtonTarget() + ".location.href)\n");
}
displayHtml.append(" if (parent." + getDetailButtonTarget() +
".location.href.indexOf('" +
getDetailButtonAction().substring(13) + "') > 0) {\n");
displayHtml.append(
" // This is the detail section of the current screen section. Refresh it with new arguments.\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('Reloading related section using HREF: " +
getDetailButtonAction() + "?x=" + keyUrlArgs +
queryUrlArgs + "');\n");
}
displayHtml.append(" parent." + getDetailButtonTarget() +
".location.href = \"" + getDetailButtonAction() + "?x=" +
keyUrlArgs + queryUrlArgs + "\";\n");
displayHtml.append(" } else {\n");
displayHtml.append(
" // This is a list section. Refresh it with same arguments used last time.\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('Reloading related section using HREF: ' + parent." +
getDetailButtonTarget() + ".location.href);\n");
}
displayHtml.append(" parent." + getDetailButtonTarget() +
".location.href = parent." + getDetailButtonTarget() +
".location.href;\n");
displayHtml.append(" }\n");
displayHtml.append("</SCRIPT>\n");
}
// Insert the preSubmit function to prevent the onBeforeUnload popup window from being displayed
// if the Save button was just clicked.
if (getIsUpdateable()) {
displayHtml.append("<SCRIPT LANGUAGE=\"JavaScript\">\n");
displayHtml.append(" function preSubmit" + getSectionName() +
"() {\n");
displayHtml.append(" // Prevent the onBeforeUnload popup window\n");
displayHtml.append(" window.onbeforeunload = null;\n");
displayHtml.append(" return false;\n");
displayHtml.append(" }\n");
displayHtml.append("</SCRIPT>\n");
}
displayHtml.append(
" <TABLE WIDTH=\"100%\" CLASS=\"freeFormSectionTitleTable\">\n");
displayHtml.append(" <TR>\n");
String titleTdName = getSectionName() + "TitleTD";
displayHtml.append(" <TD NAME=\"" + titleTdName + "\" ID=\"" +
titleTdName + "\">\n");
displayHtml.append(sectionTitle + "\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" <TD ALIGN=\"right\">\n");
displayHtml.append(" <TABLE>\n");
displayHtml.append(" <TR>\n");
displayHtml.append("\n");
if (!isSubsection) {
// Buttons with configurable targets.
// Don't send query parameters when the new button is clicked from a free-form tab. This will
// prevent fields from be initialized to the same as the current record.
displayHtml.append(displayNewButton("", action));
displayHtml.append(displayEditButton(action, keyParams,
sendQueryParams, ACTION_BUTTON));
displayHtml.append(displayDetailButton(keyParams, sendQueryParams,
action));
// Buttons with same target as current window.
displayHtml.append(" <TD>\n");
displayHtml.append(" <FORM NAME=\"" + getSectionName() +
"FormButton\" METHOD=\"post\"" + " ACTION=\"" +
getButtonAction() + "\"");
if ((getButtonTarget() != null) && !getButtonTarget().equals("")) {
displayHtml.append(" TARGET=\"" + getButtonTarget() + "\"");
}
displayHtml.append(">\n");
displayHtml.append(keyParams);
displayHtml.append(sendQueryParams);
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
ACTION_BUTTON + "\">\n");
displayHtml.append(displayQueryButton(action));
displayHtml.append(displayDeleteButton(action));
displayHtml.append(displayCopyButton(action));
displayHtml.append(displayPrintButton(action));
displayHtml.append(" </FORM>\n");
displayHtml.append(" </TD>\n");
displayHtml.append("\n");
displayHtml.append(displayCustomizeButton());
}
displayHtml.append(" </TR>\n");
displayHtml.append(" </TABLE>\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
displayHtml.append(" </TABLE>\n");
displayHtml.append("\n");
if (TIMER) {
timer.timerString(1,
"[UIWebScreenSection.displayFreeFormSection] Finished title bar");
}
displayHtml.append(" <TABLE CLASS=\"freeFormSectionDisplayTable\" ");
if (!isSubsection) {
// displayHtml.append("HEIGHT=\"100%\"");
}
displayHtml.append(">\n");
if (!isSubsection) {
boolean isMultiPart = false;
for (int fieldNbr = 0; fieldNbr < getUiFieldList().size();
fieldNbr++) {
UIFieldInfo fieldInfo = getUiField(fieldNbr);
UIDisplayObject uiDisplayObject = fieldInfo.getUiDisplayObject();
if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_FILE)) {
isMultiPart = true;
break;
}
}
displayHtml.append(" <FORM METHOD=\"post\" NAME=\"" +
getSectionName() + "Form\"" + " onSubmit=\"preSubmit" +
getSectionName() + "()\"");
if (action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT)) {
Debug.logVerbose("[displayFreeFormSection] search action: " +
getSearchAction(), module);
Debug.logVerbose("[displayFreeFormSection] search target: " +
getSearchTarget(), module);
displayHtml.append(" ACTION=\"" + getSearchAction() + "\"");
if ((getSearchTarget() != null) &&
!getSearchTarget().equals("")) {
displayHtml.append(" TARGET=\"" + getSearchTarget() + "\"");
}
} else {
displayHtml.append(" ACTION=\"" + getButtonAction() + "\"");
if ((getButtonTarget() != null) &&
!getButtonTarget().equals("")) {
displayHtml.append(" TARGET=\"" + getButtonTarget() + "\"");
}
}
if (isMultiPart) {
displayHtml.append(" enctype=\"multipart/form-data\"");
}
displayHtml.append(">\n");
}
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
getNextAction(action) + "\">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"rowCount\" VALUE=\"1\">\n");
displayHtml.append(sendQueryParams);
int htmlColumnCount = 0;
int htmlRowCount = 0;
ArrayList requiredFields = new ArrayList();
if ( action.equals(ACTION_SHOW_QUERY) && getQueryMode().equals("advanced") )
{
int fieldListSize = getUiFieldList().size();
StringBuffer fieldNameOptions = new StringBuffer(200);
fieldNameOptions.append("<option value=''></option>");
for (int fieldNbr = 0; fieldNbr < fieldListSize; fieldNbr++) {
UIFieldInfo fieldInfo = getUiField(fieldNbr);
if (fieldInfo.getIsSearchable()) {
String htmlName = UIWebUtility.getHtmlName(getSectionName(), fieldInfo,0);
String displayObjectId = fieldInfo.getDisplayObjectId();
String displayTypeId = fieldInfo.getUiDisplayObject().getDisplayTypeId();
String attributeId = fieldInfo.getAttributeId();
String optValue = htmlName + ";" + attributeId + ";" + displayTypeId + ";" + displayObjectId;
fieldNameOptions.append("<option value='" + optValue + "'>" + fieldInfo.getDisplayLabel() + "</option>");
}
}
List extendedFields = getRelatedSectionQueryFields();
if ( extendedFields != null )
{
int numFields = extendedFields.size();
for ( int i=0; i < numFields; i++)
{
GenericValue fieldInfo = (GenericValue) extendedFields.get(i);
String entityName = fieldInfo.getString("entityName");
String attributeId = fieldInfo.getString("attributeId");
String attributeName = fieldInfo.getString("attributeName");
String displayObjectId = fieldInfo.getString("displayObjectId");
String displayTypeId = fieldInfo.getString("displayTypeId");
String sectionName = fieldInfo.getString("sectionName");
String sectionDescription = fieldInfo.getString("sectionDescription");
String displayLabel = fieldInfo.getString("displayLabel");
String htmlName = UIWebUtility.getHtmlName( sectionName, entityName, attributeName, 0 );
String optValue = htmlName + ";" + attributeId + ";" + displayTypeId + ";" + displayObjectId;
displayLabel = sectionDescription + "." + displayLabel;
fieldNameOptions.append("<option value='" + optValue + "'>" + displayLabel + "</option>");
}
}
StringBuffer conditionOptions = new StringBuffer(100);
conditionOptions.append("<option value='startsWith'>STARTS WITH</option>");
conditionOptions.append("<option value='equals'>=</option>");
conditionOptions.append("<option value='like'>CONTAINS</option>");
conditionOptions.append("<option value='endsWith'>ENDS WITH</option>");
conditionOptions.append("<option value='equals'>=</option>");
conditionOptions.append("<option value='notEqual'>NOT EQUAL</option>");
conditionOptions.append("<option value='lessThan'><</option>");
conditionOptions.append("<option value='greaterThan'>></option>");
conditionOptions.append("<option value='lessThanEqualTo'><=</option>");
conditionOptions.append("<option value='greaterThanEqualTo'>>=</option>");
conditionOptions.append("<option value='in'>IN</option>");
conditionOptions.append("<option value='not-in'>NOT IN</option>");
conditionOptions.append("<option value='between'>BETWEEN</option>");
displayHtml.append("<table id='queryListTable' border=1>\n");
displayHtml.append("<tr><td>Field</td><td>Condition</td><td>Value</td><td>Action</td></tr>\n");
// default show 4 rows
for ( int i=1; i < 5; i++)
{
displayHtml.append("<tr id=queryListRow" + i + "><td><select name=queryListField" + i + ">" + fieldNameOptions.toString() + "</select></td>\n");
displayHtml.append(" <td><select name=queryListOperator" + i + ">" + conditionOptions.toString() + "</select></td>\n");
displayHtml.append(" <td><input name=queryListValue" + i + " size=60></td>\n");
displayHtml.append(" <td><img src=/sfaimages/remove.gif alt=Del onClick=delConditionRow(" + i + ")>\n");
displayHtml.append(" <img src=/sfaimages/add.gif alt=Add onClick=addConditionRow(" + i + ")></td>\n");
displayHtml.append("</tr>");
}
displayHtml.append("</table>\n");
displayHtml.append("<input type=hidden id=queryListMaxRows name=queryListMaxRows value=4>\n");
displayHtml.append("<script type='text/javascript'>\n");
displayHtml.append("function addConditionRow(i) {\n");
displayHtml.append(" var tab1=document.getElementById('queryListTable')\n");
displayHtml.append(" if ( tab1 ) {\n");
displayHtml.append(" var numRows = tab1.rows.length\n");
displayHtml.append(" var maxRows = 10\n");
displayHtml.append(" if ( numRows > maxRows )\n");
displayHtml.append(" alert(\"Can't have more than 10 conditions\");\n");
displayHtml.append(" else {\n");
displayHtml.append(" var x = tab1.insertRow(numRows)\n");
displayHtml.append(" var maxRows = document.getElementById('queryListMaxRows')\n");
displayHtml.append(" var newRow = maxRows.value - -1\n");
displayHtml.append(" maxRows.value = newRow\n");
displayHtml.append(" x.id = \"queryListRow\" + newRow\n");
displayHtml.append(" var c1=x.insertCell(0)\n");
displayHtml.append(" var c2=x.insertCell(1)\n");
displayHtml.append(" var c3=x.insertCell(2)\n");
displayHtml.append(" var c4=x.insertCell(3)\n");
displayHtml.append(" c1.innerHTML=\"<select name=queryListField\" + newRow + \">" + fieldNameOptions.toString() + "</select>\"\n");
displayHtml.append(" c2.innerHTML=\"<select name=queryListOperator\" + newRow + \">" + conditionOptions.toString() +"</select>\"\n");
displayHtml.append(" c3.innerHTML=\"<input name=queryListValue\" + newRow + \" size=60>\"\n");
displayHtml.append(" c4.innerHTML=\"<img src=/sfaimages/remove.gif alt=Del onClick=delConditionRow(\" + newRow + \")>\" + \" <img src=/sfaimages/add.gif alt=Add onClick=addConditionRow(\" + newRow + \")>\"\n");
displayHtml.append(" }\n");
displayHtml.append(" fixSize()\n");
displayHtml.append(" }\n");
displayHtml.append("}\n");
displayHtml.append("function delConditionRow(i)\n");
displayHtml.append("{\n");
displayHtml.append(" var row1 = document.getElementById('queryListRow' + i)\n");
displayHtml.append(" var tab = document.getElementById('queryListTable')\n");
displayHtml.append(" var rows = tab.rows\n");
displayHtml.append(" if ( rows.length == 2 ) {\n");
displayHtml.append(" event.returnValue = false\n");
displayHtml.append(" return;\n");
displayHtml.append(" }\n");
displayHtml.append(" for ( i=0; i < rows.length; i++ ) {\n");
displayHtml.append(" row = rows[i];\n");
displayHtml.append(" if ( row.id == row1.id) {\n");
displayHtml.append(" tab.deleteRow(i);\n");
displayHtml.append(" break;\n");
displayHtml.append(" }\n");
displayHtml.append(" }\n");
displayHtml.append(" fixSize()\n");
displayHtml.append("}\n");
displayHtml.append("</script>\n");
}
else
{
int column = 1;
int row = 1;
boolean[][] cellUsed = new boolean[100][20];
boolean trOpen = false;
if (TIMER) {
timer.timerString(1,
"[UIWebScreenSection.displayFreeFormSection] Finished preparing form");
}
int fieldListSize = getUiFieldList().size();
for (int fieldNbr = 0; fieldNbr < fieldListSize; fieldNbr++) {
if (TIMER) {
timer.timerString(1,
"[UIWebScreenSection.displayFreeFormSection] Start field " +
String.valueOf(fieldNbr));
}
UIFieldInfo fieldInfo = getUiField(fieldNbr);
// Multiply the column count by 2 since we need space for the labels, too.
htmlColumnCount = (getColumnCount() > 1) ? (getColumnCount() * 2) : 2;
int rowSpan = (fieldInfo.getRowSpan() < 2) ? 1
: fieldInfo.getRowSpan();
// Double the col span and then substract one from the label to get the actual col span of the data field.
int colSpan = (fieldInfo.getColSpan() < 2) ? 1
: ((fieldInfo.getColSpan() * 2) -
1);
int displayOrder = fieldInfo.getDisplayOrder();
String attributeName = fieldInfo.getUiAttribute().getAttributeName();
int fieldWidth = fieldInfo.getDisplayLength();
boolean startOnNewRow = fieldInfo.getStartOnNewRow();
if (fieldInfo.getIsVisible()) {
if ( (startOnNewRow ) && (column > 1) )
{
int numCellsSkipped = 0;
for ( int i = column; i <= htmlColumnCount; i++)
{
if ( !cellUsed[row][i])
numCellsSkipped++;
cellUsed[row][i] = true;
}
if ( numCellsSkipped > 0)
displayHtml.append("<TD class=freeFormSectionField colspan=" + numCellsSkipped +"></TD>");
}
if (column == 1) {
// We are at the beginning of a new row.
Debug.logVerbose("[displayFreeFormSection] Starting row " +
String.valueOf(row), module);
displayHtml.append(" <TR>");
trOpen = true;
}
// Skip cells already used by fields that were taller or wider than one cell.
while (cellUsed[row][column]) {
column++;
if (column > htmlColumnCount) {
if (trOpen) {
displayHtml.append(" </TR>\n");
trOpen = false;
}
Debug.logVerbose("[displayFreeFormSection] Ending row " +
String.valueOf(row) + " (skipped used cells)", module);
column = 1;
row++;
Debug.logVerbose("[displayFreeFormSection] Starting row " +
String.valueOf(row) + " (skipped used cells)", module);
displayHtml.append(" <TR>");
// + " HEIGHT=\"" +
// String.valueOf(FREE_FORM_ROW_HEIGHT) + "\">\n");
trOpen = true;
}
}
if (fieldInfo.getIsMandatory() && !getProtect(action)) {
displayHtml.append(
" <TD CLASS=\"freeFormSectionLabel\"");
} else {
displayHtml.append(
" <TD CLASS=\"freeFormSectionLabelOptional\"");
}
if (rowSpan > 1) {
displayHtml.append(" ROWSPAN=\"" + String.valueOf(rowSpan) +
"\"");
}
displayHtml.append(">\n");
Debug.logVerbose("[displayFreeFormSection] Displaying label " +
fieldInfo.getDisplayLabel() + " at row " +
String.valueOf(row) + " column " +
String.valueOf(column), module);
displayHtml.append(" " + fieldInfo.getDisplayLabel() +
":\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" <TD CLASS=\"freeFormSectionField\"");
if (rowSpan > 1) {
displayHtml.append(" ROWSPAN=\"" + String.valueOf(rowSpan) +
"\"");
}
if (colSpan > 1) {
displayHtml.append(" COLSPAN=\"" + String.valueOf(colSpan) +
"\"");
}
displayHtml.append(">\n");
}
// Write all fields with display order greater than zero. The ones that are not visible
// may be created as hidden fields.
if ( fieldInfo.getIsVisible() || ( (fieldInfo.getDisplayOrder() > 0) && ( fieldInfo.getUiDisplayObject().getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_HIDDEN) ) ) )
{
displayHtml.append(displayField(fieldInfo, entityDetailsVector,
action, 0, isSubsection, tabOffset));
displayHtml.append("\n");
}
// If this is a required field, add it to the list of fields to be validated.
if (fieldInfo.getIsVisible() && fieldInfo.getIsMandatory()) {
requiredFields.add(fieldInfo);
}
if (fieldInfo.getIsVisible()) {
// Close the cell.
displayHtml.append(" </TD>\n");
// Mark used cells in the matrix.
// Mark all used rows.
for (int markRow = row; markRow < (row + rowSpan); markRow++) {
// Mark all used columns, including the label. That's why we have to add 1 here:
for (int markColumn = column;
markColumn < (column + colSpan + 1);
markColumn++) {
cellUsed[markRow][markColumn] = true;
}
}
// Get ready for next time through the loop by adding the column span plus 1 for the label.
column += (1 + colSpan);
if (column > htmlColumnCount) {
Debug.logVerbose("[displayFreeFormSection] Ending row " +
String.valueOf(row), module);
if (trOpen) {
displayHtml.append(" </TR>\n");
trOpen = false;
}
column = 1;
row++;
}
}
}
if (TIMER) {
timer.timerString(1,
"[UIWebScreenSection.displayFreeFormSection] Finished fields");
}
if (trOpen) {
displayHtml.append(" </TR>\n");
trOpen = false;
}
displayHtml.append("\n");
}
if (!isSubsection) {
displayHtml.append(" <TR HEIGHT=\"*\">\n");
displayHtml.append(
" <TD CLASS=\"freeFormSectionSaveButtonArea\" COLSPAN=\"" +
String.valueOf(htmlColumnCount) + "\">\n");
if (action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append(" Save Query Definition:\n");
displayHtml.append(
" <INPUT TYPE=\"text\" WIDTH=\"40\" NAME=\"queryName\">\n");
displayHtml.append(" Save Results to List:\n");
displayHtml.append(
" <INPUT TYPE=\"text\" WIDTH=\"40\" NAME=\"listName\">\n");
displayHtml.append(
" <INPUT TYPE=\"submit\" CLASS=\"button\" NAME=\"" +
getSectionName() +
"SaveButton\" VALUE=\"Run/Save Query\">\n");
} else {
if (!getProtect(action)) {
displayHtml.append(
" <INPUT TYPE=\"submit\" CLASS=\"button\" NAME=\"" +
getSectionName() +
"SaveButton\" VALUE=\"Save\" onClick=\"return verifyRequired" +
getSectionName() + "(this.form)\">\n");
}
}
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
displayHtml.append(" </FORM>\n");
displayHtml.append("\n");
}
displayHtml.append(" </TABLE>\n");
displayHtml.append("\n");
// Add the javascript methods for confirming delete and validating required fields.
displayHtml.append(UIWebUtility.writeConfirmDeleteScript());
displayHtml.append(UIWebUtility.writeVerifyRequiredScript(
getSectionName(), requiredFields));
if (TIMER) {
timer.timerString(1,
"[UIWebScreenSection.displayFreeFormSection] End");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param dataMatrix
* @param action
* @param sectionTitle
* @param queryId
*
* @return
*
* @throws GenericEntityException
*/
public String displayTabularSection(DataMatrix dataMatrix, String action,
String sectionTitle, String queryId) throws GenericEntityException {
Debug.logVerbose("[displayTabularSection()] Screen name: " +
getUiScreen().getScreenName() + " - SectionName = " +
getSectionName(), module);
UtilTimer timer = new UtilTimer();
if (TIMER) {
timer.timerString(1,
"[UIWebScreenSection.displayTabularSection] Start");
}
// Get the extra query parameters so the form can pass them to the next page.
Debug.logVerbose("displayTabularSection] getSendQueryParameterValueMap: " +
getSendQueryParameterValueMap().toString(), module);
String sendQueryParams = UIWebUtility.getHiddenArgs(getSendQueryParameterValueMap(),
" ");
Debug.logVerbose("[displayTabularSection] sendQueryParams: " +
sendQueryParams, module);
StringBuffer displayHtml = new StringBuffer(5000);
int row = 0;
int rows = dataMatrix.getCurrentBuffer().getContents().size();
hasPriorPage = firstVisibleRow > 0;
hasNextPage = (rowsPerPage > 0) && (totalRows > rowsPerPage );
priorPageStartRow = firstVisibleRow - rowsPerPage;
if (priorPageStartRow < 0) {
priorPageStartRow = 0;
}
nextPageStartRow = firstVisibleRow + rowsPerPage;
Debug.logVerbose("hasPrior=" + hasPriorPage + ", hasNext=" +
hasNextPage + ",priorStart=" + priorPageStartRow +
",nextStart=" + nextPageStartRow, module);
/* int lastVisibleRow = rows + 1;
int numPages = 1;
if ( (rowsPerPage > 0) && (rows > rowsPerPage) )
{
lastVisibleRow = firstVisibleRow + rowsPerPage -1;
numPages = rows/rowsPerPage;
if (rows % rowsPerPage > 0)
numPages++;
}
*/
displayHtml.append(displayTabularSectionHeader(action, sectionTitle,
queryId, rows, sendQueryParams));
Iterator entityDetailsVectorIterator = dataMatrix.getCurrentBuffer()
.getContents()
.iterator();
while (entityDetailsVectorIterator.hasNext()) {
// Get the next item from the vector of entity vectors.
Vector entityDetailsVector = (Vector) entityDetailsVectorIterator.next();
// Display the row of fields.
displayHtml.append(displayTabularSectionRow(row++, rows,
entityDetailsVector, action));
}
if (hasPriorPage || hasNextPage) {
displayHtml.append(displayPageButtons(hasPriorPage,
priorPageStartRow, hasNextPage, nextPageStartRow, queryId));
}
// Display the closing HTML tags, and the alpha search for the screen section.
displayHtml.append(displayTabularSectionFooter(action, sendQueryParams, queryId));
Debug.logVerbose("[displayTabularSection()] Finished Screen name: " +
getUiScreen().getScreenName() + " - SectionName = " +
getSectionName(), module);
if (TIMER) {
timer.timerString(1,
"[UIWebScreenSection.displayTabularSection] End");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param action
* @param sectionTitle
* @param queryId
* @param rows
* @param sendQueryParams
*
* @return
*
* @throws GenericEntityException
*/
public String displayTabularSectionHeader(String action,
String sectionTitle, String queryId, int rows, String sendQueryParams)
throws GenericEntityException {
UtilTimer timer = new UtilTimer();
if (TIMER) {
timer.timerString(2,
"[UIWebScreenSection.displayTabularSectionHeader] Start");
}
StringBuffer displayHtml = new StringBuffer(2000);
displayHtml.append("<SCRIPT>\n");
displayHtml.append(" function selectRow" + getSectionName() +
"(aLinkObj, aClickedObj) {\n");
if (WEB_DEBUG) {
displayHtml.append(" alert('[selectRow" + getSectionName() +
"] Clicked object name: ' + aClickedObj.name);\n");
}
if (WEB_DEBUG) {
displayHtml.append(" alert('[selectRow" + getSectionName() +
"] Clicked object ID: ' + aClickedObj.id);\n");
}
if (WEB_DEBUG) {
displayHtml.append(" alert('[selectRow" + getSectionName() +
"] Clicked object tag name: ' + aClickedObj.tagName);\n");
}
displayHtml.append(" if (aClickedObj.tagName == 'TD') {\n");
displayHtml.append(
" // An empty space in the row was clicked. Go ahead and click the hidden anchor.\n");
displayHtml.append(
" // Note: Catch exception to get rid of the 'undefined error' that pops up if the cancel \n");
displayHtml.append(
" // button is clicked in response to the onBeforeUnload processing.\n");
displayHtml.append(" try {\n");
displayHtml.append(" aLinkObj.click();\n");
displayHtml.append(" } catch (Exception) {\n");
displayHtml.append(" }\n");
displayHtml.append(" } else {\n");
displayHtml.append(
" // Either an anchor was clicked by the user, in which case that link\n");
displayHtml.append(
" // will take care of reloading pages, or a drop down was clicked, in which case\n");
displayHtml.append(
" // we don't want to select a new row, or this function is executing a second time\n");
displayHtml.append(
" // as the result of the click() it just triggered on the aLinkObj anchor.\n");
displayHtml.append(" // Don't do anything here. \n");
displayHtml.append(" }\n");
displayHtml.append(" }\n");
// Insert the preSubmit function to prevent the onBeforeUnload popup window from being displayed
// if the Save button was just clicked.
if (getIsUpdateable()) {
displayHtml.append(" function preSubmit" + getSectionName() +
"() {\n");
displayHtml.append(" // Prevent the onBeforeUnload popup window\n");
displayHtml.append(" window.onbeforeunload = null;\n");
displayHtml.append(" return false;\n");
displayHtml.append(" }\n");
}
displayHtml.append("</SCRIPT>\n");
displayHtml.append("\n");
displayHtml.append(
"<SCRIPT LANGUAGE=\"JScript\" TYPE=\"text/javascript\" FOR=\"window\" EVENT=\"onload\">\n");
displayHtml.append("\n");
displayHtml.append(
" // Turn on the scroll bars in case the window object is an Iframe that was\n");
displayHtml.append(
" // created to hold a set of tab pages, which don't have any scroll bars.\n");
displayHtml.append(" document.body.scroll=\"auto\";\n");
displayHtml.append("\n");
displayHtml.append("</SCRIPT>\n");
displayHtml.append("\n");
displayHtml.append(
" <TABLE WIDTH=\"100%\" CLASS=\"tabularSectionTitleTable\">\n");
displayHtml.append(" <TR>\n");
displayHtml.append("\n");
displayHtml.append(" <TD>\n");
displayHtml.append(" <NOBR>" + sectionTitle + "</NOBR>\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" <TD ALIGN=\"right\">\n");
displayHtml.append(" <TABLE>\n");
displayHtml.append(" <TR>\n");
displayHtml.append("\n");
displayHtml.append(displayQueryPicker(sendQueryParams, queryId));
if (getLayoutTypeId() != LAYOUT_TYPE_SELECT) {
displayHtml.append(displayNewButton(sendQueryParams, action));
}
if (getIsUpdateable()) {
displayHtml.append(displayEditButton(action, "", sendQueryParams,
ACTION_QUERY_UPDATE));
}
if (getLayoutTypeId() == LAYOUT_TYPE_SELECT) {
// This is actually a select section being displayed in tabular mode. Display the Select
// button so the user can put it back into Select mode.
displayHtml.append(" <TD WIDTH=\"70\">\n");
displayHtml.append(" <FORM NAME=\"" + getSectionName() +
"FormEditButton\" METHOD=\"post\"" + " ACTION=\"" +
getButtonAction() + "\"");
if ((getButtonTarget() != null) && !getButtonTarget().equals("")) {
displayHtml.append(" TARGET=\"" + getButtonTarget() + "\"");
}
displayHtml.append(">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
ACTION_SHOW_SELECT + "\">\n");
displayHtml.append(sendQueryParams);
displayHtml.append(displaySelectButton(action));
displayHtml.append(" </FORM>\n");
displayHtml.append(" </TD>\n");
displayHtml.append("\n");
}
displayHtml.append(displayCustomizeButton());
displayHtml.append(" </TR>\n");
displayHtml.append(" </TABLE>\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
displayHtml.append(" </TABLE>\n\n");
displayHtml.append(" <TABLE CLASS=\"grid\" ID=\"table" +
getSectionName() + "\" WIDTH=\"" + getRowWidth(getUiFieldList()) +
"\" CELLSPACING=\"0\">\n");
displayHtml.append(" <THEAD>\n");
displayHtml.append(" <TR valign=\"middle\">\n");
// Write out the column headings.
int tempColumnCount = 0;
for (int column = 0; column < getUiFieldList().size(); column++) {
UIFieldInfo fieldInfo = (UIFieldInfo) getUiField(column);
if (fieldInfo.getIsVisible()) {
displayHtml.append(" <TD WIDTH=\"");
if (fieldInfo.getDisplayLabel().length() > fieldInfo.getDisplayLength()) {
displayHtml.append((fieldInfo.getDisplayLabel().length() +
35));
} else {
displayHtml.append((fieldInfo.getDisplayLength() + 35));
}
displayHtml.append(
"\" ><INPUT type=button style='width:100%;height:20;font:12px menu;' value='" +
fieldInfo.getDisplayLabel() + "'></TD>\n");
}
tempColumnCount++;
}
// Column count in database is not used for tabular screen sections.
setColumnCount(tempColumnCount);
displayHtml.append(" </TR>\n");
displayHtml.append(" </THEAD>\n");
displayHtml.append(" <TBODY ID='tableDetails'>\n");
if ((getButtonAction() != null) && !getButtonAction().equals("") &&
(getButtonTarget() != null) && !getButtonTarget().equals("") &&
getIsUpdateable()) {
displayHtml.append(" <FORM METHOD=\"post\" NAME=\"" +
getSectionName() + "Form\"" + " onSubmit=\"preSubmit" +
getSectionName() + "()\"" + " ACTION=\"" + getButtonAction() +
"\"");
displayHtml.append(" TARGET=\"" + getButtonTarget() + "\"");
displayHtml.append(">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
getNextAction(action) + "\">\n");
displayHtml.append(sendQueryParams);
}
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"rowCount\" VALUE=\"" +
String.valueOf(rows) + "\">\n");
if (TIMER) {
timer.timerString(2,
"[UIWebScreenSection.displayTabularSectionHeader] End");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param row
* @param rows
* @param entityDetailsVector
* @param action
*
* @return
*
* @throws GenericEntityException
*/
public String displayTabularSectionRow(int row, int rows,
Vector entityDetailsVector, String action)
throws GenericEntityException {
UtilTimer timer = new UtilTimer();
if (TIMER) {
timer.timerString(2,
"[UIWebScreenSection.displayTabularSectionRow] Start - row " +
String.valueOf(row));
}
StringBuffer displayHtml = new StringBuffer(200);
String rowClass = (((row % 2) != 0) ? "light" : "medium");
// String rowClass = (((row % 2) != 0) ? "tabularSectionField1" : "tabularSectionField2");
GenericValue primaryEntityDetails = (GenericValue) entityDetailsVector.firstElement();
displayHtml.append(" <TR CLASS=\"" + rowClass + "\" ID=\"tr_" +
getSectionName() + "_");
displayHtml.append(String.valueOf(row) + "\"");
String hrefName = "a_" + getSectionName() + "_" + String.valueOf(row);
if (!getDetailButtonAction().equals("") &&
!getDetailButtonTarget().equals("")) {
displayHtml.append(" onclick=\"selectRow" + getSectionName() + "(" +
hrefName + ", window.event.srcElement)\"");
}
displayHtml.append(">\n");
if (!getDetailButtonAction().equals("") &&
!getDetailButtonTarget().equals("")) {
// Insert the row select button.
String href = " <A HREF=\"" + getDetailButtonAction() +
"?action=show" +
UIWebUtility.getUrlArgs(getButtonKeyMap(), entityDetailsVector) +
"\" TARGET=\"" + getDetailButtonTarget() + "\" name=" +
hrefName + "></A>\n";
displayHtml.append(href);
}
for (int fieldNbr = 0; fieldNbr < getUiFieldList().size();
fieldNbr++) {
UIFieldInfo fieldInfo = getUiField(fieldNbr);
String attributeName = fieldInfo.getUiAttribute().getAttributeName();
if (fieldInfo.getIsVisible()) {
Debug.logVerbose("[displayTabularSection()] Section name: " +
getSectionName() + " - Field Name = " + attributeName, module);
displayHtml.append(" <TD NOWRAP ID=\"td_" +
String.valueOf(row) + "_" + String.valueOf(fieldNbr) +
"\">\n");
}
displayHtml.append(displayField(fieldInfo, entityDetailsVector,
action, row, false, 0));
if (fieldInfo.getIsVisible()) {
displayHtml.append(" </TD>\n");
}
displayHtml.append("\n");
}
// Make a blank column at the right side so the colors will look right.
displayHtml.append(" <TD CLASS=\"tabularSectionBlankLabel\">\n");
displayHtml.append("  \n");
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
if (TIMER) {
timer.timerString(2,
"[UIWebScreenSection.displayTabularSectionRow] End - row " +
String.valueOf(row));
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param action
* @param sendQueryParams
*
* @return
*/
public String displayTabularSectionFooter(String action,
String sendQueryParams, String queryId) {
UtilTimer timer = new UtilTimer();
if (TIMER) {
timer.timerString(2,
"[UIWebScreenSection.displayTabularSectionFooter] Start");
}
StringBuffer displayHtml = new StringBuffer(200);
if ((getButtonAction() != null) && !getButtonAction().equals("") &&
(getButtonTarget() != null) && !getButtonTarget().equals("") &&
getIsUpdateable() &&
(action.equals(ACTION_QUERY_UPDATE) || action.equals(ACTION_SHOW_INSERT) ||
action.equals(ACTION_UPDATE))) {
displayHtml.append(" <TR>\n");
displayHtml.append(" <TD></TD>\n");
displayHtml.append(
" <TD CLASS=\"tabularSectionSaveButtonArea\" COLSPAN=\"" +
String.valueOf(getColumnCount()) + "\">\n");
displayHtml.append(
" <INPUT TYPE=\"submit\" CLASS=\"button\" NAME=\"" +
getSectionName() + "SaveButton\" VALUE=\"Save\">\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
displayHtml.append("\n");
}
if ((getButtonAction() != null) && !getButtonAction().equals("") &&
(getButtonTarget() != null) && !getButtonTarget().equals("") &&
getIsUpdateable()) {
displayHtml.append(" </FORM>\n");
}
displayHtml.append(" </TBODY>\n");
displayHtml.append(" </TABLE>\n");
Debug.logVerbose("[displayTabularSection()] getSearchAction(): " +
getSearchAction(), module);
Debug.logVerbose("[displayTabularSection()] getSearchTarget(): " +
getSearchTarget(), module);
Debug.logVerbose("[displayTabularSection()] getSearchAttributeId(): " +
getSearchAttributeId(), module);
if (hasPriorPage || hasNextPage) {
String scrollAction = action;
if ( scrollAction.equals(ACTION_UPDATE) || ( scrollAction.equals(ACTION_INSERT)))
scrollAction = ACTION_QUERY;
displayHtml.append(
"<FORM STYLE=\"padding=0; border=0; margin=0\" ACTION=\"" +
getSearchAction() + "\"" + " TARGET=\"" + getSearchTarget() +
"\" NAME=\"" + getSectionName() + "PageButtons\">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
scrollAction + "\">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"startRow\" VALUE=\"" + 0 +
"\">\n");
displayHtml.append(sendQueryParams);
if ( queryId != null && queryId.length() > 0)
displayHtml.append("<INPUT TYPE=hidden name=queryId value=\"" + queryId + "\">\n");
displayHtml.append("<CENTER><TABLE>\n<TR>\n");
displayHtml.append("<TD ALIGN=CENTER>");
if (hasPriorPage) {
displayHtml.append(
"<input type=submit CLASS=\"titleBarImageButton\" title=\"Previous Page\" name=previous value=\"Previous\" onClick=\"startRow.value =" +
priorPageStartRow + "\">\n");
}
displayHtml.append("</TD><TD ALIGN=CENTER>");
if (hasNextPage) {
displayHtml.append(
"<TD><input type=submit CLASS=\"titleBarImageButton\" title=\"Next Page\" name=next value=\"Next\" onClick=\"startRow.value =" +
nextPageStartRow + "\">\n");
}
displayHtml.append("</TD></TR></TABLE></CENTER>\n");
displayHtml.append("</FORM>\n");
}
if (!getSearchAction().equals("") && !getSearchTarget().equals("") &&
!getSearchAttributeId().equals("")) {
// Draw the alpha search under the list.
Debug.logVerbose("[displayTabularSection()] Displaying alpha search buttons.", module);
displayHtml.append(" <TABLE WIDTH=\"100%\">\n");
String[] alphabet = {
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"*"
};
displayHtml.append("\n");
displayHtml.append(" <TR>\n");
displayHtml.append(" <TD WIDTH=\"30\"></TD>\n");
displayHtml.append(" <TD ALIGN=\"left\">\n");
displayHtml.append(
" <FORM STYLE=\"padding=0; border=0; margin=0\" ACTION=\"" +
getSearchAction() + "\"" + " TARGET=\"" + getSearchTarget() +
"\" NAME=\"" + getSectionName() + "AlphaQueryForm\">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
ACTION_QUERY + "\">\n");
displayHtml.append(sendQueryParams);
displayHtml.append(
" <TABLE BORDER=\"0\" BGCOLOR=\"white\" CELLSPACING=\"0\" CELLPADDING=\"0\" BORDER=\"0\">\n");
displayHtml.append(" <TR>\n");
for (int letterNbr = 0; letterNbr < alphabet.length; letterNbr++) {
displayHtml.append(" <TD>\n");
displayHtml.append(
" <INPUT WIDTH=\"10\" TYPE=\"submit\" CLASS=\"button\" NAME=\"nameToSearch\" VALUE=\"" +
alphabet[letterNbr] + "\">\n");
displayHtml.append(" </TD>\n");
}
displayHtml.append(" </TR>\n");
displayHtml.append(" </TABLE>\n");
displayHtml.append(" </FORM>\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
displayHtml.append(" </TABLE>\n");
displayHtml.append("\n");
}
if (TIMER) {
timer.timerString(2,
"[UIWebScreenSection.displayTabularSectionFooter] End");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param dataMatrix
* @param action
* @param sectionTitle
* @param queryId
*
* @return
*
* @throws GenericEntityException
*/
public String displaySelectSection(DataMatrix dataMatrix, String action,
String sectionTitle, String queryId) throws GenericEntityException {
Debug.logVerbose("[displaySelectSection] Screen name: " +
getUiScreen().getScreenName() + " - SectionName = " +
getSectionName(), module);
int rows = dataMatrix.getCurrentBuffer().getContents().size();
// Get the extra query parameters so the form can pass them to the next page.
Debug.logVerbose(
"[displaySelectSection] getSendQueryParameterValueMap: " +
getSendQueryParameterValueMap().toString(), module);
String sendQueryParams = UIWebUtility.getHiddenArgs(getSendQueryParameterValueMap(),
" ");
Debug.logVerbose("[displaySelectSection] sendQueryParams: " +
sendQueryParams, module);
StringBuffer displayHtml = new StringBuffer(5000);
if (action.equals(ACTION_SHOW_SELECT) ||
action.equals(ACTION_UPDATE_SELECT)) {
// Need to display the screen section in select mode.
// Insert the client side scripts.
Debug.logVerbose("[displaySelectSection] Inserting scripts.", module);
displayHtml.append("<SCRIPT LANGUAGE=\"JavaScript\">\n");
displayHtml.append("function handleUnassignedChange" +
getSectionName() + "() {\n");
displayHtml.append(" document." + getSectionName() + "Form." +
getSectionName() + "AssignedSel.selectedIndex = -1;\n");
displayHtml.append(" document." + getSectionName() + "Form." +
getSectionName() + "SelectButton.disabled = false;\n");
displayHtml.append(" document." + getSectionName() + "Form." +
getSectionName() + "SelectButton.value = \">>>\";\n");
displayHtml.append("}\n");
displayHtml.append("function handleAssignedChange" +
getSectionName() + "() {\n");
displayHtml.append(" document." + getSectionName() + "Form." +
getSectionName() + "UnassignedSel.selectedIndex = -1;\n");
displayHtml.append(" document." + getSectionName() + "Form." +
getSectionName() + "SelectButton.disabled = false;\n");
displayHtml.append(" document." + getSectionName() + "Form." +
getSectionName() + "SelectButton.value = \"<<<\";\n");
displayHtml.append("}\n");
displayHtml.append("\n");
displayHtml.append("function selectTransfer" + getSectionName() +
"(btnObj)\n");
displayHtml.append("{\n");
displayHtml.append(" selectTransfer" + getSectionName() +
"(btnObj, \"N\");\n");
displayHtml.append("}\n");
displayHtml.append("\n");
displayHtml.append("function selectTransfer" + getSectionName() +
"(btnObj, requiredFlag)\n");
displayHtml.append("{\n");
displayHtml.append(" var selFrom;\n");
displayHtml.append(" var selTo;\n");
displayHtml.append(" var selDB;\n");
displayHtml.append(" var selDBAlt;\n");
displayHtml.append(" var curOpt;\n");
displayHtml.append("\n");
displayHtml.append(" if (btnObj.value == \">>>\") {\n");
displayHtml.append(" // An item is being added\n");
displayHtml.append(" selTo = document.all('" + getSectionName() +
"AssignedSel');\n");
displayHtml.append(" selFrom = document.all('" + getSectionName() +
"UnassignedSel');\n");
displayHtml.append(" selDB = document.all('" + getSectionName() +
"AddDBSel');\n");
displayHtml.append(" selDBAlt = document.all('" +
getSectionName() + "DeleteDBSel');\n");
displayHtml.append(" } else {\n");
displayHtml.append(" // An item is being deleted\n");
displayHtml.append(" selTo = document.all('" + getSectionName() +
"UnassignedSel');\n");
displayHtml.append(" selFrom = document.all('" + getSectionName() +
"AssignedSel');\n");
displayHtml.append(" selDB = document.all('" + getSectionName() +
"DeleteDBSel');\n");
displayHtml.append(" selDBAlt = document.all('" +
getSectionName() + "AddDBSel');\n");
displayHtml.append(" }\n");
displayHtml.append("\n");
displayHtml.append(" // Make sure an item was selected\n");
displayHtml.append(" if (selFrom.selectedIndex < 0) {\n");
displayHtml.append(" alert('Please select an item first');\n");
displayHtml.append(" return;\n");
displayHtml.append(" }\n");
displayHtml.append("\n");
displayHtml.append(
" curOpt = selFrom.options[selFrom.selectedIndex];\n");
displayHtml.append(" var selectedValue = curOpt.value;\n");
displayHtml.append(" var selectedText = curOpt.text;\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('selectedValue = ' + selectedValue);\n");
}
displayHtml.append(" // Add the entry to the 'select to' list\n");
displayHtml.append(
" selTo.options[selTo.length] = new Option(selectedText, selectedValue, false, true);\n");
displayHtml.append("\n");
displayHtml.append("\n");
displayHtml.append(
" // Remove the entry from the 'select from' list\n");
displayHtml.append(
" selFrom.options[selFrom.selectedIndex] = null;\n");
displayHtml.append("\n");
displayHtml.append(
" // If this is a reversal of a prior selection, remove the item from the reverse DB action list.\n");
displayHtml.append(" var handled = false;\n");
displayHtml.append(" for (i=0; i< selDBAlt.length; i++) {\n");
displayHtml.append(" var checkOptionObj = selDBAlt.options[i];\n");
displayHtml.append(" var checkValue = checkOptionObj.value;\n");
displayHtml.append(" if (checkValue == selectedValue) {\n");
displayHtml.append(
" // Just remove the item from the DB list since no action will be required at Save time\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('Removing item from the reverse DB action list.');\n");
}
displayHtml.append(" selDBAlt.removeChild(checkOptionObj);\n");
displayHtml.append(" handled = true;\n");
displayHtml.append(" break;\n");
displayHtml.append(" }\n");
displayHtml.append(" }\n");
displayHtml.append("\n");
displayHtml.append(
" // If the item was not already handled by deleting it from the reverse DB action list, add it to the DB action list.\n");
displayHtml.append(" if (!handled) {\n");
displayHtml.append(
" selDB.options[selDB.length] = new Option(selectedText, selectedValue, false, true);\n");
displayHtml.append(" }\n");
displayHtml.append("\n");
displayHtml.append(" // Change the look of the arrow button\n");
displayHtml.append(" if (selTo == document." + getSectionName() +
"Form." + getSectionName() + "UnassignedSel)\n");
displayHtml.append(" handleUnassignedChange" + getSectionName() +
"();\n");
displayHtml.append(" else if (selTo == document." +
getSectionName() + "Form." + getSectionName() +
"AssignedSel)\n");
displayHtml.append(" handleAssignedChange" + getSectionName() +
"();\n");
displayHtml.append("\n");
displayHtml.append(" if ( document." + getSectionName() + "Form." +
getSectionName() +
"AssignedSel.length < 1 && requiredFlag==\"Y\")\n");
displayHtml.append(" {\n");
displayHtml.append(" document." + getSectionName() + "Form." +
getSectionName() + "SaveButton.disabled = true;\n");
displayHtml.append(" }\n");
displayHtml.append(" else\n");
displayHtml.append(" {\n");
displayHtml.append(" document." + getSectionName() + "Form." +
getSectionName() + "SaveButton.disabled = false;\n");
displayHtml.append(" }\n");
displayHtml.append("}\n");
displayHtml.append("\n");
displayHtml.append("function preSubmit" + getSectionName() +
"()\n");
displayHtml.append("{\n");
displayHtml.append(" var i;\n");
displayHtml.append(" var tmpStr = \"\";\n");
displayHtml.append(" var opt = \"\";\n");
displayHtml.append("\n");
displayHtml.append(
" // Build the delete string which will be used by the event processor to remove records.\n");
displayHtml.append(" var deleteDBSelObj = document.all('" +
getSectionName() + "DeleteDBSel');\n");
displayHtml.append(" for (i=0; i< deleteDBSelObj.length; i++) {\n");
displayHtml.append(" opt = deleteDBSelObj.options[i].value;\n");
displayHtml.append(" tmpStr = tmpStr + opt + \";\";\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('Added unassigned option to delete string: ' + opt);\n");
}
displayHtml.append(" }\n");
displayHtml.append(" document." + getSectionName() +
"Form.inpUnassigned.value = tmpStr;\n");
if (WEB_DEBUG) {
displayHtml.append(" alert('Delete string: ' + tmpStr);\n");
}
displayHtml.append(" tmpStr = \"\";\n");
displayHtml.append("\n");
displayHtml.append(
" // Build the add string which will be used by the event processor to add records.\n");
displayHtml.append(" var addDBSelObj = document.all('" +
getSectionName() + "AddDBSel');\n");
displayHtml.append(" for (i=0; i< addDBSelObj.length; i++)\n");
displayHtml.append(" {\n");
displayHtml.append(" opt = addDBSelObj.options[i].value;\n");
displayHtml.append(" tmpStr = tmpStr + opt + \";\";\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('Added assigned option to add string: ' + opt);\n");
}
displayHtml.append(" }\n");
displayHtml.append(" document." + getSectionName() +
"Form.inpAssigned.value = tmpStr;\n");
if (WEB_DEBUG) {
displayHtml.append(" alert('Add string: ' + tmpStr);\n");
}
displayHtml.append(
" // Prevent the onBeforeUnload popup window\n");
displayHtml.append(" window.onbeforeunload = null;\n");
displayHtml.append(" return false;\n");
displayHtml.append("}\n");
displayHtml.append("\n");
Debug.logVerbose("[displaySelectSection] Inserting function " +
getSectionName() + "Send(selectObj)", module);
displayHtml.append("function " + getSectionName() +
"Send(selectObj){\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('Selected account ID = ' + selectObj.value);\n");
}
if (WEB_DEBUG) {
displayHtml.append(
" alert('Length = ' + selectObj.value.length);\n");
}
displayHtml.append(" if(selectObj.value.length > 0) {\n");
displayHtml.append(" var searchValue = selectObj.value;\n");
if (WEB_DEBUG) {
displayHtml.append(" alert('searchValue = ' + searchValue);\n");
}
displayHtml.append(" var selectName = selectObj.name;\n");
if (WEB_DEBUG) {
displayHtml.append(" alert('selectName = ' + selectName);\n");
}
displayHtml.append(" var searchUrl = '" + getSearchAction() +
"?searchValue=' + searchValue");
Iterator sendQueryParameterI = getSendQueryParameterValueMap()
.keySet().iterator();
while (sendQueryParameterI.hasNext()) {
String sendQueryParameterKey = (String) sendQueryParameterI.next();
String sendQueryParameterValue = (String) getSendQueryParameterValueMap()
.get(sendQueryParameterKey);
displayHtml.append(" + '&" + sendQueryParameterKey + "=" +
sendQueryParameterValue + "'");
}
displayHtml.append(";\n");
displayHtml.append(" var assignedSelectObj = document.all.item('" +
getSectionName() + "AssignedSel');\n");
displayHtml.append(
" var assignedOptionObjs = assignedSelectObj.children.tags('OPTION');\n");
displayHtml.append(
" var assignedOptionCount = assignedOptionObjs.length;\n");
displayHtml.append(
" for (assignedOptionNbr = 0; assignedOptionNbr < assignedOptionCount; assignedOptionNbr++) {\n");
displayHtml.append(
" var assignedValue = assignedOptionObjs(assignedOptionNbr).value;\n");
displayHtml.append(
" searchUrl = searchUrl + '&assignedValue_' + assignedOptionNbr + '=' + assignedValue;\n");
displayHtml.append(" }\n");
displayHtml.append(
" searchUrl = searchUrl + '&assignedOptionCount=' + assignedOptionCount;\n");
displayHtml.append(";\n");
if (WEB_DEBUG) {
displayHtml.append(" alert('searchUrl = ' + searchUrl);\n");
}
displayHtml.append(" var anchorObj = document.anchors('" +
getSectionName() + "Anchor');\n");
displayHtml.append(" anchorObj.href=searchUrl;\n");
displayHtml.append(" anchorObj.click();\n");
displayHtml.append(" }\n");
displayHtml.append("}\n");
displayHtml.append("\n");
Debug.logVerbose("[displaySelectSection] Inserting function " +
getSectionName() + "UpdateAvailable()", module);
displayHtml.append("function " + getSectionName() +
"UpdateAvailable() {\n");
if (WEB_DEBUG) {
displayHtml.append(" alert('Starting " + getSectionName() +
"UpdateAvailable()');\n");
}
displayHtml.append(" var searchIframeDoc = document.frames('" +
getSectionName() + "Iframe').document;\n");
displayHtml.append(
" var realTimeAvailSelectObj = searchIframeDoc.all('" +
getSectionName() + "RealTimeAvailSelect');\n");
displayHtml.append(" var unassignedSelectObj = document.all.item('" +
getSectionName() + "UnassignedSel');\n");
displayHtml.append(" if(realTimeAvailSelectObj != null) {\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('realTimeAvailSelectObj was found.');\n");
}
displayHtml.append(
" var oldOptionObjs = unassignedSelectObj.children.tags('OPTION');\n");
displayHtml.append(
" for (oldOptionNbr = oldOptionObjs.length - 1; oldOptionNbr >= 0; oldOptionNbr--) {\n");
displayHtml.append(
" // Remove this option from the visible select box\n");
if (WEB_DEBUG) {
displayHtml.append(" alert('Removing an old option');\n");
}
displayHtml.append(
" unassignedSelectObj.removeChild(oldOptionObjs(oldOptionNbr));\n");
displayHtml.append(" }\n");
displayHtml.append(
" var newOptionObjs = realTimeAvailSelectObj.children.tags('OPTION');\n");
displayHtml.append(
" for (newOptionNbr = 0; newOptionNbr < newOptionObjs.length; newOptionNbr++) {\n");
displayHtml.append(
" // Create a new element to add to the select\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('Tag of child node: ' + newOptionObjs(newOptionNbr).tagName);\n");
}
displayHtml.append(
" var newUnassignedOptionObj = document.createElement('OPTION');\n");
displayHtml.append(
" newUnassignedOptionObj.value = newOptionObjs(newOptionNbr).value;\n");
displayHtml.append(
" newUnassignedOptionObj.text = newOptionObjs(newOptionNbr).text;\n");
if (WEB_DEBUG) {
displayHtml.append(
" alert('Adding new option: ' + newUnassignedOptionObj.value + '/' + newUnassignedOptionObj.text);\n");
}
displayHtml.append(
" unassignedSelectObj.options.add(newUnassignedOptionObj, newOptionNbr);\n");
displayHtml.append(" }\n");
displayHtml.append(" }\n");
displayHtml.append("}\n");
displayHtml.append("\n");
displayHtml.append("</SCRIPT>\n");
// Make a list of the primary keys of the entities that are already assigned.
Debug.logVerbose(
"[displaySelectSection] Getting selected entities.", module);
ArrayList selectedEntityGVC = new ArrayList();
ArrayList selectedEntityPKC = new ArrayList();
for (int row = 0;
row < dataMatrix.getCurrentBuffer().getContents().size();
row++) {
// Get the generic value for the current row for the entity being listed. This must be
// the second entity (element 1) in the retrieve order defined in the screen section
// entities for this screen section.
GenericValue listGV = dataMatrix.getCurrentBuffer()
.getGenericValue(row, 1);
selectedEntityGVC.add(listGV);
selectedEntityPKC.add(listGV.getPrimaryKey());
}
// Get the list of all eligible entities.
Debug.logVerbose(
"[displaySelectSection] Getting eligible entities.", module);
List eligibleEntityL = getEligibleEntityList(getUseQueryParameterValueMap(),
getUiScreenSectionEntity(1).getUiEntity().getEntityName(),
userInfo, delegator);
// Remove selected entities from the list of eligible entities.
Debug.logVerbose(
"[displaySelectSection] Removing selected entities.", module);
eligibleEntityL = UIUtility.removeSelectedEligibleEntities(selectedEntityPKC,
eligibleEntityL);
// Display the title bar.
Debug.logVerbose("[displaySelectSection] Displaying title bar", module);
displayHtml.append(
"<TABLE WIDTH=\"100%\" CLASS=\"tabularSectionTitleTable\">\n");
displayHtml.append(" <TR>\n");
displayHtml.append("\n");
displayHtml.append(" <TD>\n");
displayHtml.append(" <NOBR>" + sectionTitle + "</NOBR>\n");
displayHtml.append(" </TD>\n");
displayHtml.append("\n");
if (getIsUpdateable()) {
displayHtml.append(displayEditButton(action, "",
sendQueryParams, ACTION_QUERY_UPDATE));
}
displayHtml.append(" <TD WIDTH=\"70\">\n");
displayHtml.append(displaySelectButton(action));
displayHtml.append(" </TD>\n");
displayHtml.append(displayCustomizeButton());
displayHtml.append(" </TR>\n");
displayHtml.append("</TABLE>\n"); // End of title table.
displayHtml.append("\n");
// Display the select screen contents.
// Start of table with one row for the select boxes and one row for the Save button.
Debug.logVerbose("[displaySelectSection] Displaying screen contents", module);
displayHtml.append(
"<TABLE WIDTH=\"100%\" CLASS=\"freeFormSectionDisplayTable\">\n");
if ((getButtonAction() != null) && !getButtonAction().equals("") &&
getIsUpdateable()) {
displayHtml.append(" <FORM METHOD=\"post\" NAME=\"" +
getSectionName() + "Form\" " + "onSubmit=\"preSubmit" +
getSectionName() + "()\" ACTION=\"" + getButtonAction() +
"\"");
if ((getButtonTarget() != null) &&
!getButtonTarget().equals("")) {
displayHtml.append(" TARGET=\"" + getButtonTarget() + "\"");
}
displayHtml.append(">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
getNextAction(action) + "\">\n");
displayHtml.append(sendQueryParams);
}
// Display the empty hidden vars to hold the selected and de-selected entity keys.
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"inpUnassigned\" ID=\"inpUnassigned\" VALUE=\"\">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"inpAssigned\" ID=\"inpAssigned\" VALUE=\"\">\n");
displayHtml.append(" <TR>\n");
displayHtml.append(" <TD>\n");
// Start of table that shows the two select boxes.
displayHtml.append(
" <TABLE BORDER=\"0\" WIDTH=\"100%\" CLASS=\"freeFormSectionDisplayTable\">\n");
displayHtml.append(" <TR>\n");
displayHtml.append(
" <TD WIDTH=\"25%\" CLASS=\"selectSectionLabel\">Available</TD>\n");
// Insert invisible drop list for setting an extra query parameter for the available list.
displayHtml.append(
" <TD WIDTH=\"20%\" CLASS=\"selectSectionLabel\">\n");
displayHtml.append(" <SELECT ID=\"" + getSectionName() +
"FilterId\" NAME=\"" + getSectionName() +
"FilterId\" TABINDEX=\"1\" ");
displayHtml.append(
"CLASS=\"querySelectBox\" STYLE=\"visibility: hidden\" ");
displayHtml.append("onchange=\"" + getSectionName() +
"Send(this);\">\n");
displayHtml.append(" </SELECT>\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" <TD></TD>\n"); // Space for arrow button.
displayHtml.append(
" <TD WIDTH=\"45%\" CLASS=\"selectSectionLabel\">Selected</TD>\n");
displayHtml.append(" </TR>\n");
displayHtml.append(" <TR>\n");
// Display the eligible (available) entities.
displayHtml.append(" <TD COLSPAN=\"2\">\n");
displayHtml.append(" <SELECT STYLE=\"width: 100%\" " +
"NAME=\"" + getSectionName() + "UnassignedSel\" ID=\"" +
getSectionName() +
"UnassignedSel\" SIZE=\"10\" onChange=\"handleUnassignedChange" +
getSectionName() + "()\">\n");
Iterator eligibleEntityI = eligibleEntityL.iterator();
while (eligibleEntityI.hasNext()) {
GenericValue eligibleGV = (GenericValue) eligibleEntityI.next();
GenericPK eligiblePK = eligibleGV.getPrimaryKey();
Iterator eligiblePKFieldI = eligiblePK.getAllFields().entrySet()
.iterator();
// Add an option to the available select box for this entity.
// Example of value with 1 field in the key: "contactId:10341"
// Example of value with 3 fields in the key: "displayObjectId:10021,displayTypeId:22320,displayAttribId:SIZE"
displayHtml.append(" <OPTION VALUE=\"");
int fieldCount = 0;
StringBuffer keyStringBuf = new StringBuffer();
while (eligiblePKFieldI.hasNext()) {
Map.Entry eligiblePKField = (Map.Entry) eligiblePKFieldI.next();
Debug.logVerbose("[displaySelectSection] eligiblePKField: " +
eligiblePKField.toString(), module);
String eligiblePKFieldName = (String) eligiblePKField.getKey();
Debug.logVerbose("[displaySelectSection] eligiblePKFieldName: " +
eligiblePKFieldName.toString(), module);
String eligiblePKFieldValue = (String) eligiblePKField.getValue();
Debug.logVerbose("[displaySelectSection] eligiblePKFieldValue: " +
eligiblePKFieldValue.toString(), module);
if (++fieldCount > 1) {
keyStringBuf.append(",");
}
keyStringBuf.append(eligiblePKFieldName + ":" +
eligiblePKFieldValue);
}
// Append the key and the name.
Vector listedEntityVector = new Vector();
listedEntityVector.add(eligibleGV);
String eligibleItemName = UIUtility.decodeEntityDisplayDef(getSelectNameDef(),
listedEntityVector, "");
displayHtml.append(keyStringBuf.toString() + "\">" +
eligibleItemName + "\n");
}
displayHtml.append(" </SELECT>\n");
displayHtml.append(" </TD>\n");
// Display the arrow button.
displayHtml.append(" <TD ALIGN=\"center\">\n");
displayHtml.append(" <INPUT DISABLED TYPE=\"button\" NAME=\"" +
getSectionName() + "SelectButton\" value=\"---\" " +
"onClick=\"selectTransfer" + getSectionName() + "(this)\">\n");
displayHtml.append(" </TD>\n");
// Display the selected entities.
displayHtml.append(" <TD>\n");
displayHtml.append(" <SELECT STYLE=\"width: 100%\" " +
"NAME=\"" + getSectionName() + "AssignedSel\" ID=\"" +
getSectionName() +
"AssignedSel\" SIZE=\"10\" onChange=\"handleAssignedChange" +
getSectionName() + "()\">\n");
Iterator selectedEntityGVI = selectedEntityGVC.iterator();
while (selectedEntityGVI.hasNext()) {
GenericValue selectedGV = (GenericValue) selectedEntityGVI.next();
GenericPK selectedPK = (GenericPK) selectedGV.getPrimaryKey();
Iterator selectedPKFieldI = selectedPK.getAllFields().entrySet()
.iterator();
// Add an option to the available select box for this entity.
// Example of value with 1 field in the key: "contactId:10341"
// Example of value with 3 fields in the key: "displayObjectId:10021,displayTypeId:22320,displayAttribId:SIZE"
displayHtml.append(" <OPTION VALUE=\"");
int fieldCount = 0;
StringBuffer keyStringBuf = new StringBuffer();
while (selectedPKFieldI.hasNext()) {
Map.Entry selectedPKField = (Map.Entry) selectedPKFieldI.next();
Debug.logVerbose("[displaySelectSection] selectedPKField: " +
selectedPKField.toString(), module);
String selectedPKFieldName = (String) selectedPKField.getKey();
String selectedPKFieldValue = (String) selectedPKField.getValue();
if (++fieldCount > 1) {
keyStringBuf.append(",");
}
keyStringBuf.append(selectedPKFieldName + ":" +
selectedPKFieldValue);
}
// Append the key and the name.
Vector listedEntityVector = new Vector();
listedEntityVector.add(selectedGV);
String selectedItemName = UIUtility.decodeEntityDisplayDef(getSelectNameDef(),
listedEntityVector, "");
displayHtml.append(keyStringBuf.toString() + "\">" +
selectedItemName + "\n");
}
displayHtml.append(" </SELECT>\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
displayHtml.append(" </TABLE>\n"); // End of table that shows the two select boxes.
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
if ((getButtonAction() != null) && !getButtonAction().equals("") &&
(getButtonTarget() != null) &&
!getButtonTarget().equals("") && getIsUpdateable()) {
displayHtml.append(" <TR>\n");
displayHtml.append(
" <TD CLASS=\"freeFormSectionSaveButtonArea\">\n");
displayHtml.append(
" <INPUT TYPE=\"submit\" CLASS=\"button\" NAME=\"" +
getSectionName() + "SaveButton\" VALUE=\"Save\">\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
displayHtml.append("\n");
}
// Create hidden SELECTs for items to be added or deleted.
displayHtml.append(" <TR>\n");
displayHtml.append(
" <TD CLASS=\"freeFormSectionSaveButtonArea\">\n");
displayHtml.append(" <SELECT STYLE=\"visibility: hidden\" " +
"NAME=\"" + getSectionName() + "AddDBSel\" ID=\"" +
getSectionName() + "AddDBSel\"></SELECT>\n");
displayHtml.append(" <SELECT STYLE=\"visibility: hidden\" " +
"NAME=\"" + getSectionName() + "DeleteDBSel\" ID=\"" +
getSectionName() + "DeleteDBSel\"></SELECT>\n");
displayHtml.append(" </TD>\n");
displayHtml.append(" </TR>\n");
if ((getButtonAction() != null) && !getButtonAction().equals("") &&
(getButtonTarget() != null) &&
!getButtonTarget().equals("") && getIsUpdateable()) {
displayHtml.append(" </FORM>\n");
}
displayHtml.append("</TABLE>\n");
// End of table with one row for the select boxes and one row for the Save button.
// Create hidden Anchor and I-Frame for searching for available values.
displayHtml.append("<A STYLE='visibility:hidden' ID='" +
getSectionName() + "Anchor' " + "NAME='" + getSectionName() +
"Anchor' " + "TARGET='" + getSectionName() + "Iframe'>\n");
displayHtml.append("</A>\n");
displayHtml.append(
"<IFRAME STYLE='visibility:hidden; width:0; height:0; margin:0; padding:0;' " +
"ID='" + getSectionName() + "Iframe' NAME='" +
getSectionName() + "Iframe' " +
"FRAMEBORDER='0' FRAMESPACING='0' MARGINWIDTH='0' MARGINHEIGHT='0' " +
"onload='" + getSectionName() + "UpdateAvailable();'>\n");
displayHtml.append("</IFRAME>\n");
displayHtml.append("\n");
} else {
// Don't need to display this section in select mode right now. Just display it as a normal
// tabular section.
displayHtml.append(displayTabularSection(dataMatrix, action,
sectionTitle, queryId));
}
Debug.logVerbose("[displaySelectSection] Finished Screen name: " +
getUiScreen().getScreenName() + " - SectionName = " +
getSectionName(), module);
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param useQueryParameterValueMap
* @param listedEntityName
* @param userInfo
* @param delegator
*
* @return
*/
public List getEligibleEntityList(HashMap useQueryParameterValueMap,
String listedEntityName, UserInfo userInfo, GenericDelegator delegator) {
Debug.logVerbose("[getEligibleEntityList] Start", module);
ArrayList eligibleEntities = new ArrayList();
// Default to all values of the given entity type. Descendant should override this if filtering
// is required.
try {
List listedEntityGVL = delegator.findAll(listedEntityName);
Iterator listedEntityGVI = listedEntityGVL.iterator();
while (listedEntityGVI.hasNext()) {
GenericValue listedEntityGV = (GenericValue) listedEntityGVI.next();
eligibleEntities.add(listedEntityGV);
}
} catch (GenericEntityException e) {
Debug.logError(
"UIWebScreenSection.getEligibleEntityList] An error occurred while searching for eligible " +
listedEntityName + " entities:", module);
Debug.logError(e.getLocalizedMessage(), module);
return eligibleEntities;
}
Debug.logVerbose("[getEligibleEntityList] End", module);
return eligibleEntities;
}
/**
* This function returns a string containing the HTML text needed to display a field in the format
* defined by the display object to which it is attached.
* @param entityDetailsVector A vector containing GenericValues objects for the entities being displayed
* one the screen. The primary entity should be put into the vector first
* in the calling script. This is required so this function can get the value for the current field,
* and also in case we need to do any logic with other values from the screen, such as filtering a dropdown list.
* @param action If this is ACTION_SHOW or "", the HTML text will be modified to make the field non-editable.
* @return String An HTML String for display.
*/
public String displayField(UIFieldInfo fieldInfo,
Vector entityDetailsVector, String action, int row,
boolean isSubsection, int tabOffset) {
UtilTimer timer = new UtilTimer();
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] Start " +
fieldInfo.getUiAttribute().getAttributeName());
}
StringBuffer displayHtml = new StringBuffer();
int maxLength;
GenericValue genericValue = null;
String findAttributeValue = "";
boolean protect = false;
Debug.logVerbose("[displayField()] getEntityName() -> " +
fieldInfo.getUiAttribute().getUiEntity().getEntityName(), module);
Debug.logVerbose("[displayField()] getAttributeName() ->" +
fieldInfo.getUiAttribute().getAttributeName(), module);
// If the screen is being displayed in query mode, and the current field is not searchable, don't display it.
Debug.logVerbose("[displayField()] action -> " + action, module);
Debug.logVerbose("[displayField()] getIsSearchable() -> " +
String.valueOf(fieldInfo.getIsSearchable()), module);
if ((action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT)) &&
!fieldInfo.getIsSearchable()) {
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] in query mode and not a searchable field");
}
return "";
}
// Get the details of the field's entity. For example, if this is the account detail screen,
// but the current field is the city from the Address entity, this will get the address entity
// off the vector that was passed in.
GenericValue fieldEntityDetails = null;
Iterator entityDetailsIterator = entityDetailsVector.iterator();
while (entityDetailsIterator.hasNext()) {
GenericValue testEntity = (GenericValue) entityDetailsIterator.next();
if (testEntity.getEntityName().equals(fieldInfo.getUiAttribute()
.getUiEntity()
.getEntityName())) {
fieldEntityDetails = testEntity;
}
}
if (fieldEntityDetails == null) {
Debug.logVerbose(
"[displayField()] fieldEntityDetails is null. Assuming a null field", module);
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] fieldEntityDetails is null. Assuming a null field");
}
return "";
}
// Get the details of the primary entity being displayed on the screen. For example, if this is
// the account detail screen, this will get the account entity off the vector that was passed in.
GenericValue primaryEntityDetails = (GenericValue) entityDetailsVector.firstElement();
// Get the current field's value passed in from the jsp script.
String fieldValue = (String.valueOf(fieldEntityDetails.get(
fieldInfo.getUiAttribute().getAttributeName())) != null)
? String.valueOf(fieldEntityDetails.get(fieldInfo.getUiAttribute()
.getAttributeName()))
: "";
if ((fieldValue == null) || fieldValue.equals("null")) {
fieldValue = "";
}
Debug.logVerbose("[displayField()] fieldValue -> " +
fieldValue, module);
if (fieldInfo.getUiAttribute().getUiEntity().getEntityName().equals("")) {
// Entity name not specified.
Debug.logWarning(
"[UIWebScreenSection.displayField]: Entity name not specified.", module);
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End (entity name not specified)");
}
return fieldValue;
}
if (fieldInfo.getUiAttribute().getAttributeName().equals("")) {
// Field name not specified.
Debug.logWarning(
"[UIWebScreenSection.displayField]: Field name not specified.", module);
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End (attribute name not specified)");
}
return fieldValue;
}
if (action.equals(ACTION_SHOW) || action.equals(ACTION_INSERT) ||
action.equals(ACTION_UPDATE) || action.equals(ACTION_QUERY) ||
action.equals("") || (action == null) ||
((fieldInfo.getIsReadOnly() ||
!fieldInfo.getUiScreenSectionEntity().getIsUpdateable()) &&
!action.equals(ACTION_SHOW_QUERY) &&
!action.equals(ACTION_SHOW_QUERY_REPORT) &&
!action.equals(ACTION_SHOW_REPORT)) ||
((action.equals(ACTION_SHOW_UPDATE) ||
action.equals(ACTION_QUERY_UPDATE)) &&
fieldInfo.getUiAttribute().getIsPk())) {
protect = true;
}
// If the action is SHOW_COPY, and this is a primary key field that is auto-generated, need to clear the value
// before displaying. The original value will be saved as is in case the primary key of the copied record
// is needed for custom processing later.
// Save a copy of the original field value in case we change the field value.
String origFieldValue = fieldValue;
if (UIWebUtility.getIsCopiedPrimaryKey(action, fieldInfo)) {
fieldValue = "";
Debug.logVerbose("[displayField()] Clearing primary key field.", module);
}
String htmlName = UIWebUtility.getHtmlName(getSectionName(), fieldInfo,
row);
String htmlNameOriginal = UIWebUtility.getHtmlNameOriginal(getSectionName(),
fieldInfo, row);
int tabIndex = tabOffset + fieldInfo.getDisplayOrder();
UIDisplayObject uiDisplayObject = fieldInfo.getUiDisplayObject();
try {
uiDisplayObject.loadAttributes();
Debug.logVerbose("[displayField()] Starting to decode field " +
htmlName + " of type " +
uiDisplayObject.getDisplayTypeId(), module);
if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_SELECT)) {
// Default to the generic UIDropDown class.
String uiDropDownClassName = "";
if (uiDisplayObject.getAttribEntityFindMethod().equals("CUSTOM_CLASS")) {
// A custom class has been constructed to handle the retrieval of entities from the data base.
// Need to use that class instead of the plain UIDropDown class.
uiDropDownClassName = uiDisplayObject.getAttribEntityFindDef();
}
UIDropDown uiDropDown = UIUtility.getUIDropDown(uiDropDownClassName);
displayHtml.append(uiDropDown.displayFieldHtml(
uiDisplayObject, protect, htmlName, fieldValue,
entityDetailsVector, fieldInfo, action, tabIndex,
getUserInfo(), getDelegator()));
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (text - protected)");
}
} else if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_SEARCH_TEXT)) {
// Search Text field. Searches for a value and then turns into a select field.
/*
* fieldName (htmlName) , entityName (ENTITY), idName (ENTITY_VALUE_DEF)
<script for='firstName' event='onblur()' language='JavaScript'>sendData(this, this.form);</script>
<script for='firstName' event='onchange()' language='JavaScript'>searchAgain(this, this.form);</script>
<p id='firstNameHolder' name='firstNameHolder' >
<input type="text" name="firstName" id="firstName" entityName="Contact" fieldName="firstName" idName="contactId" >
</p>
*/
// Default to the generic UISearchField class.
String uiSearchFieldClassName = "";
if (uiDisplayObject.getAttribEntityFindMethod().equals("CUSTOM_CLASS")) {
// A custom class has been constructed to handle the retrieval of entities from the data base.
// Need to use that class instead of the plain UISearchField class.
uiSearchFieldClassName = uiDisplayObject.getAttribEntityFindDef();
}
UISearchField uiSearchField = UIUtility.getUISearchField(uiSearchFieldClassName);
displayHtml.append(uiSearchField.displayFieldHtml(
uiDisplayObject, protect, htmlName, fieldValue,
entityDetailsVector, fieldInfo, action, tabIndex,
getUserInfo(), getDelegator()));
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (text - protected)");
}
} else if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_TEXT)) {
// Text field
if (!protect) {
// Mode is not protected, so create a text tag.
displayHtml.append("<INPUT TYPE=\"TEXT\" NAME=\"" +
htmlName + "\" TABINDEX=\"" + String.valueOf(tabIndex) +
"\" ");
displayHtml.append(UIWebUtility.translateAttribSize(
uiDisplayObject.getAttribSize()));
displayHtml.append(UIWebUtility.translateAttribMaxLength(
uiDisplayObject.getAttribMaxLength(),
String.valueOf(fieldInfo.getMaxLength())));
displayHtml.append(UIWebUtility.translateAttribDisabled(
uiDisplayObject.getAttribDisabled()));
displayHtml.append(UIWebUtility.translateAttribReadOnly(
uiDisplayObject.getAttribReadOnly()));
displayHtml.append(UIWebUtility.translateAttribAlign(
uiDisplayObject.getAttribAlign()));
displayHtml.append(UIWebUtility.translateAttribClass(
uiDisplayObject.getAttribClass(action,
fieldInfo.getIsMandatory())));
displayHtml.append(" VALUE='" + fieldValue + "'>");
if (fieldInfo.getIsMandatory() &&
!action.equals(ACTION_SHOW_QUERY) &&
!action.equals(ACTION_SHOW_QUERY_REPORT) &&
!action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append("*\n");
}
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (text)");
}
} else {
// In protect mode. Just create a hidden field AND show the value as text in the table cell.
// Create an anchor tag if the ANCHOR_HREF_DEF attribute was set in the display object.
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue, fieldValue,
entityDetailsVector));
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (text - protected)");
}
}
} else if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_FILE)) {
// Text field
if (!protect) {
// Mode is not protected, so create a text tag.
displayHtml.append("<INPUT TYPE=\"FILE\" NAME=\"" +
htmlName + "\" TABINDEX=\"" + String.valueOf(tabIndex) +
"\" ");
displayHtml.append(UIWebUtility.translateAttribSize(
uiDisplayObject.getAttribSize()));
displayHtml.append(UIWebUtility.translateAttribMaxLength(
uiDisplayObject.getAttribMaxLength(),
String.valueOf(fieldInfo.getMaxLength())));
displayHtml.append(UIWebUtility.translateAttribDisabled(
uiDisplayObject.getAttribDisabled()));
displayHtml.append(UIWebUtility.translateAttribReadOnly(
uiDisplayObject.getAttribReadOnly()));
displayHtml.append(UIWebUtility.translateAttribAlign(
uiDisplayObject.getAttribAlign()));
displayHtml.append(UIWebUtility.translateAttribClass(
uiDisplayObject.getAttribClass(action,
fieldInfo.getIsMandatory())));
displayHtml.append(" VALUE='" + fieldValue + "'>");
if (fieldInfo.getIsMandatory() &&
!action.equals(ACTION_SHOW_QUERY) &&
!action.equals(ACTION_SHOW_QUERY_REPORT) &&
!action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append("*\n");
}
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (text)");
}
} else {
// In protect mode. Just create a hidden field AND show the value as text in the table cell.
// Create an anchor tag if the ANCHOR_HREF_DEF attribute was set in the display object.
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue, fieldValue,
entityDetailsVector));
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (text - protected)");
}
}
} else if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_CHECKBOX)) {
// Check box
if (!protect) {
// Mode is not protected, so create an input tag.
displayHtml.append("<INPUT TYPE=\"CHECKBOX\" NAME=\"" +
htmlName + "\" TABINDEX=\"" + String.valueOf(tabIndex) +
"\" ");
if (fieldValue.equals(
uiDisplayObject.getAttribCheckedValue())) {
displayHtml.append("CHECKED ");
}
displayHtml.append(UIWebUtility.translateAttribSize(
uiDisplayObject.getAttribSize()));
displayHtml.append(UIWebUtility.translateAttribDisabled(
uiDisplayObject.getAttribDisabled()));
displayHtml.append(UIWebUtility.translateAttribReadOnly(
uiDisplayObject.getAttribReadOnly()));
displayHtml.append(UIWebUtility.translateAttribClass(
uiDisplayObject.getAttribClass(action,
fieldInfo.getIsMandatory())));
displayHtml.append(">\n");
if (fieldInfo.getIsMandatory() &&
!action.equals(ACTION_SHOW_QUERY) &&
!action.equals(ACTION_SHOW_QUERY_REPORT) &&
!action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append("*\n");
}
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (checkbox)");
}
} else {
// In protect mode. Just create a hidden field AND show the value as text in the table cell.
displayHtml.append("<INPUT TYPE=\"HIDDEN\" NAME=\"" +
htmlName + "\" VALUE='" + fieldValue + "'>\n");
if (fieldValue.equals(
uiDisplayObject.getAttribCheckedValue())) {
displayHtml.append(uiDisplayObject.getAttribCheckedDisplay());
} else if (fieldValue.equals(
uiDisplayObject.getAttribUncheckedValue())) {
displayHtml.append(uiDisplayObject.getAttribUncheckedDisplay());
} else {
displayHtml.append("Undefined");
}
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (checkbox - protected)");
}
}
} else if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_NUMBER) ||
uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_CURRENCY) ||
uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_PERCENT)) {
// Number or currency field
String formattedNumberString = fieldValue;
if ((fieldValue != null) && !fieldValue.equals("")) {
NumberFormat numberFormat = null;
if (uiDisplayObject.getDisplayTypeId().equals("NUMBER")) {
numberFormat = NumberFormat.getInstance();
} else if (uiDisplayObject.getDisplayTypeId().equals("CURRENCY")) {
numberFormat = NumberFormat.getCurrencyInstance();
} else if (uiDisplayObject.getDisplayTypeId().equals("PERCENT")) {
numberFormat = NumberFormat.getPercentInstance();
}
Debug.logVerbose(
"[displayField()] Starting to parse number from " +
fieldValue, module);
DecimalFormat decimalParser = new DecimalFormat();
ParsePosition parsePosition = new ParsePosition(0);
Number parsedNumber = decimalParser.parse(fieldValue,
parsePosition);
Debug.logVerbose(
"[displayField()] Finished parsing number: " +
String.valueOf(parsedNumber), module);
formattedNumberString = numberFormat.format(parsedNumber);
// Change the original and current value strings to match the formatted value so a false change won't
// be detected when the user navigates away from this screen section.
origFieldValue = formattedNumberString;
if (!UIWebUtility.getIsCopiedPrimaryKey(action, fieldInfo)) {
fieldValue = formattedNumberString;
}
}
if (!protect) {
// Mode is not protected, so create a text tag.
displayHtml.append("<INPUT TYPE=\"TEXT\" NAME=\"" +
htmlName + "\" TABINDEX=\"" + String.valueOf(tabIndex) +
"\" ");
displayHtml.append(UIWebUtility.translateAttribSize(
uiDisplayObject.getAttribSize()));
displayHtml.append(UIWebUtility.translateAttribMaxLength(
uiDisplayObject.getAttribMaxLength(),
String.valueOf(fieldInfo.getMaxLength())));
displayHtml.append(UIWebUtility.translateAttribDisabled(
uiDisplayObject.getAttribDisabled()));
displayHtml.append(UIWebUtility.translateAttribReadOnly(
uiDisplayObject.getAttribReadOnly()));
displayHtml.append(UIWebUtility.translateAttribAlign(
uiDisplayObject.getAttribAlign()));
displayHtml.append(UIWebUtility.translateAttribClass(
uiDisplayObject.getAttribClass(action,
fieldInfo.getIsMandatory())));
displayHtml.append(" VALUE=\"" + formattedNumberString +
"\">");
if (fieldInfo.getIsMandatory() &&
!action.equals(ACTION_SHOW_QUERY) &&
!action.equals(ACTION_SHOW_QUERY_REPORT) &&
!action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append("*\n");
}
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (number)");
}
} else {
// In protect mode. Just create a hidden field AND show the value as text in the table cell.
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue,
formattedNumberString, entityDetailsVector));
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (number - protected)");
}
}
} else if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_DATE) ||
uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_TIME) ||
uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_DATETIME)) {
// Date, DateTime, or Time field
String formattedDateString = fieldValue;
if ((fieldValue != null) && !fieldValue.equals("")) {
Debug.logVerbose(
"-->[UIFieldsInfo.displayField()] Field value is not null.", module);
SimpleDateFormat dateFormat = null;
// Try to parse as an sql DATETIME column.
String parseMask = "yyyy-MM-dd HH:mm:ss.S";
Debug.logVerbose(
"[displayField()] Starting to parse date from " +
fieldValue + " using mask " + parseMask, module);
SimpleDateFormat dateParser = new SimpleDateFormat(parseMask);
ParsePosition parsePosition = new ParsePosition(0);
Date parsedDate = dateParser.parse(fieldValue, parsePosition);
if (parsedDate == null) {
// Try to parse as an sql DATE column.
parseMask = "yyyy-MM-dd";
Debug.logVerbose(
"[displayField()] Starting to parse date from " +
fieldValue + " using mask " + parseMask, module);
dateParser = new SimpleDateFormat(parseMask);
parsedDate = dateParser.parse(fieldValue, parsePosition);
}
Debug.logVerbose("-->[UIFieldsInfo.displayField()] Finished parsing date.", module);
if (parsedDate != null) {
Debug.logVerbose("-->[UIFieldsInfo.displayField()] Parsed date is not null.", module);
if (uiDisplayObject.getDisplayTypeId().equals("DATE")) {
if (uiDisplayObject.getAttribDisplayMask().equals("")) {
// Use system default date mask.
Debug.logVerbose(
"[displayField()] DATE: using standard date format.", module);
dateFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT);
} else {
// Use display mask specified in the display object.
Debug.logVerbose(
"[displayField()] DATE: using display mask - \"" +
uiDisplayObject.getAttribDisplayMask() +
"\"", module);
dateFormat = new SimpleDateFormat(uiDisplayObject.getAttribDisplayMask());
}
} else if (uiDisplayObject.getDisplayTypeId().equals("TIME")) {
if (uiDisplayObject.getAttribDisplayMask().equals("")) {
// Use system default date mask.
Debug.logVerbose(
"[displayField()] TIME: using standard time format.", module);
dateFormat = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.SHORT);
} else {
// Use display mask specified in the display object.
Debug.logVerbose(
"[displayField()] TIME: using display mask - \"" +
uiDisplayObject.getAttribDisplayMask() +
"\"", module);
dateFormat = new SimpleDateFormat(uiDisplayObject.getAttribDisplayMask());
}
} else if (uiDisplayObject.getDisplayTypeId().equals("DATETIME")) {
if (uiDisplayObject.getAttribDisplayMask().equals("")) {
// Use system default date mask.
Debug.logVerbose(
"[displayField()] DATETIME: using standard datetime format.", module);
dateFormat = (SimpleDateFormat) DateFormat.getDateTimeInstance();
} else {
// Use display mask specified in the display object.
Debug.logVerbose(
"[displayField()] DATETIME: using display mask - \"" +
uiDisplayObject.getAttribDisplayMask() +
"\"", module);
dateFormat = new SimpleDateFormat(uiDisplayObject.getAttribDisplayMask());
}
}
formattedDateString = dateFormat.format(parsedDate);
} else {
Debug.logVerbose("-->[UIFieldsInfo.displayField()] Parsed date is null.", module);
formattedDateString = "";
}
// Change the original and current value strings to match the formatted value so a false change
// won't be detected when the user navigates away from this screen section.
origFieldValue = formattedDateString;
if (!UIWebUtility.getIsCopiedPrimaryKey(action, fieldInfo)) {
fieldValue = formattedDateString;
}
}
if (!protect) {
// Mode is not protected, so create a text tag.
displayHtml.append("<INPUT TYPE=\"TEXT\" NAME=\"" +
htmlName + "\" TABINDEX=\"" + String.valueOf(tabIndex) +
"\" ");
displayHtml.append(UIWebUtility.translateAttribSize(
uiDisplayObject.getAttribSize()));
displayHtml.append(UIWebUtility.translateAttribMaxLength(
uiDisplayObject.getAttribMaxLength(),
String.valueOf(fieldInfo.getMaxLength())));
displayHtml.append(UIWebUtility.translateAttribDisabled(
uiDisplayObject.getAttribDisabled()));
displayHtml.append(UIWebUtility.translateAttribReadOnly(
uiDisplayObject.getAttribReadOnly()));
displayHtml.append(UIWebUtility.translateAttribAlign(
uiDisplayObject.getAttribAlign()));
displayHtml.append(UIWebUtility.translateAttribClass(
uiDisplayObject.getAttribClass(action,
fieldInfo.getIsMandatory())));
displayHtml.append(" VALUE=\"" + formattedDateString +
"\">\n");
if (uiDisplayObject.getDisplayTypeId().equals("DATE") ||
uiDisplayObject.getDisplayTypeId().equals("DATETIME")) {
boolean isDateTime = true;
if (uiDisplayObject.getDisplayTypeId().equals("DATE")) {
isDateTime = false;
}
String formName = "";
String fieldName = "";
if (isSubsection) {
// This section is being displayed as a subsection, so there isn't a form
// for just this section. Need to use the one called "compositeForm".
formName = "document." +
UIWebUtility.HTML_COMPOSITE_FORM_NAME;
} else {
// This section is being alone, so a form is being generated by this class.
// Use the form with the section name in it.
formName = "document." + getSectionName() + "Form";
}
fieldName = formName + "." + htmlName;
// Use onfocus and onblur events to set variable to make the onBeforeUnload
// script skip the popup message.
displayHtml.append(" <A\n" + " TABINDEX=\"" +
String.valueOf(tabIndex) + "\"\n" +
" TARGET=\"_self\"\n " +
" HREF=\"javascript:show_calendar('" + fieldName +
"', " + fieldName + ".value, " +
(isDateTime ? "1" : "0") + ");\"\n" +
" onfocus=\"checkForChanges = false;\"\n" +
" onblur=\"checkForChanges = true;\"\n" + " >\n");
displayHtml.append(
" <IMG SRC='/sfaimages/cal.gif' WIDTH='16' HEIGHT='16' BORDER='0' " +
"ALT='Click here for calendar'>\n");
displayHtml.append(" </A>\n");
}
if (fieldInfo.getIsMandatory() &&
!action.equals(ACTION_SHOW_QUERY) &&
!action.equals(ACTION_SHOW_QUERY_REPORT) &&
!action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append("*\n");
}
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (date)");
}
} else {
// In protect mode. Just create a hidden field AND show the value as text in the table cell.
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue,
formattedDateString, entityDetailsVector));
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (date - protected)");
}
}
} else if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_TEXTAREA)) {
// Text field
if (!protect) {
// Mode is not protected, so create a text tag.
displayHtml.append("<TEXTAREA NAME=\"" + htmlName +
"\" TABINDEX=\"" + String.valueOf(tabIndex) + "\" ");
displayHtml.append(UIWebUtility.translateAttribCols(
uiDisplayObject.getAttribCols()));
displayHtml.append(UIWebUtility.translateAttribRows(
uiDisplayObject.getAttribRows()));
displayHtml.append(UIWebUtility.translateAttribDisabled(
uiDisplayObject.getAttribDisabled()));
displayHtml.append(UIWebUtility.translateAttribReadOnly(
uiDisplayObject.getAttribReadOnly()));
displayHtml.append(UIWebUtility.translateAttribAlign(
uiDisplayObject.getAttribAlign()));
displayHtml.append(UIWebUtility.translateAttribWrap(
uiDisplayObject.getAttribWrap()));
displayHtml.append(UIWebUtility.translateAttribClass(
uiDisplayObject.getAttribClass(action,
fieldInfo.getIsMandatory())));
displayHtml.append(">" + fieldValue + "</TEXTAREA>\n");
if (fieldInfo.getIsMandatory() &&
!action.equals(ACTION_SHOW_QUERY) &&
!action.equals(ACTION_SHOW_QUERY_REPORT) &&
!action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append("*\n");
}
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (text area)");
}
} else {
// In protect mode. Just create a hidden field AND show the value as text in the table cell.
displayHtml.append(UIWebUtility.displayFieldReadOnly(
uiDisplayObject, htmlName, fieldValue, StringHelper.textToHtml(fieldValue),
entityDetailsVector));
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (protected text area)");
}
}
} else if (uiDisplayObject.getDisplayTypeId().equals(UIDisplayObject.DISPLAY_TYPE_HIDDEN)) {
// Hidden field
displayHtml.append("<INPUT TYPE=\"HIDDEN\" NAME=\"" + htmlName +
"\" VALUE='" + fieldValue + "'>\n");
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (hidden field)");
}
} else {
// Unknown display type. Use the plain value.
if (TIMER) {
timer.timerString(3,
"[UIWebScreenSection.displayField] End " +
fieldInfo.getUiAttribute().getAttributeName() +
" (unknown display type)");
}
displayHtml.append(fieldValue);
}
// Create hidden field to hold the original value for update capability.
displayHtml.append("<INPUT TYPE=\"HIDDEN\" NAME=\"" +
htmlNameOriginal + "\" VALUE='" + origFieldValue + "'>\n");
return displayHtml.toString();
} catch (GenericEntityException e) {
Debug.logError(
"[UIWebScreenSection.displayField]: Error occurred while getting the display object attributes for displayObjectId " +
fieldInfo.getDisplayObjectId() + ":", module);
Debug.logError(" " + e.getLocalizedMessage(), module);
return fieldValue;
}
}
/**
* DOCUMENT ME!
*
* @param action
*
* @return
*/
protected String displayQueryButton(String action) {
StringBuffer displayHtml = new StringBuffer("");
String queryLabel = "Query";
if (getHideButtons().indexOf("query") < 0) {
if ( action.equals(ACTION_SHOW_QUERY) )
{
String newMode = "standard";
if ( getQueryMode().equals("standard") )
{
queryLabel = "Advanced Query";
newMode = "advanced";
}
else
{
queryLabel = "Standard Query";
newMode = "standard";
}
displayHtml.append("<INPUT TYPE=HIDDEN NAME='queryMode' VALUE='" + newMode + "'>\n");
}
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" NAME=\"queryButton\" TITLE=\"Create a new query\"");
if (//action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append(" DISABLED");
displayHtml.append(" SRC=\"" + IMAGE_FIND_DISABLED + "\">\n");
} else {
displayHtml.append(" SRC=\"" + IMAGE_FIND + "\">\n");
}
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Create a new query\" VALUE=\"" + queryLabel + "\"");
if ( // removed for use with Standard / Advanced Query Toggle action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append(" DISABLED");
}
displayHtml.append(">\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param sendQueryParams
* @param action
*
* @return
*/
protected String displayNewButton(String sendQueryParams, String action) {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("new") < 0) {
displayHtml.append(" <TD>\n");
displayHtml.append(
" <FORM NAME=\"newForm\" METHOD=\"post\" ACTION=\"" +
getNewButtonAction() + "\"");
if ((getNewButtonTarget() != null) &&
!getNewButtonTarget().equals("")) {
displayHtml.append(" TARGET=\"" + getNewButtonTarget() + "\"");
}
displayHtml.append(">\n");
displayHtml.append(sendQueryParams);
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
ACTION_BUTTON + "\">\n");
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" NAME=\"newButton\" TITLE=\"Create a new record\"");
if (action.equals(ACTION_SHOW_INSERT)) {
displayHtml.append(" DISABLED");
displayHtml.append(" SRC=\"" + IMAGE_NEW_DISABLED + "\">\n");
} else {
displayHtml.append(" SRC=\"" + IMAGE_NEW + "\">\n");
}
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Create a new record\" VALUE=\"New\"");
if (action.equals(ACTION_SHOW_INSERT)) {
displayHtml.append(" DISABLED");
}
displayHtml.append(">\n");
displayHtml.append(" </FORM>\n");
displayHtml.append("\n");
displayHtml.append(" </TD>\n");
displayHtml.append("\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param action
* @param keyParams
* @param sendQueryParams
* @param nextAction
*
* @return
*/
protected String displayEditButton(String action, String keyParams,
String sendQueryParams, String nextAction) {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("edit") < 0) {
displayHtml.append(" <TD>\n");
displayHtml.append(
" <FORM name=\"editForm\" METHOD=\"post\" ACTION=\"" +
getEditButtonAction() + "\"");
if ((getEditButtonTarget() != null) &&
!getEditButtonTarget().equals("")) {
displayHtml.append(" TARGET=\"" + getEditButtonTarget() + "\"");
}
displayHtml.append(">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
nextAction + "\">\n");
displayHtml.append(keyParams);
displayHtml.append(sendQueryParams);
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" NAME=\"editButton\" TITLE=\"Edit the information\"");
if (action.equals(ACTION_SHOW_INSERT) ||
action.equals(ACTION_SHOW_UPDATE) ||
action.equals(ACTION_QUERY_UPDATE) ||
action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT) || !getIsUpdateable()) {
displayHtml.append(" DISABLED");
displayHtml.append(" SRC=\"" + IMAGE_EDIT_DISABLED + "\">\n");
} else {
displayHtml.append(" SRC=\"" + IMAGE_EDIT + "\">\n");
}
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Edit the information\" VALUE=\"Edit\"");
if (action.equals(ACTION_SHOW_INSERT) ||
action.equals(ACTION_SHOW_UPDATE) ||
action.equals(ACTION_QUERY_UPDATE) ||
action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT) || !getIsUpdateable()) {
displayHtml.append(" DISABLED");
}
displayHtml.append(">\n");
displayHtml.append(" </FORM>\n");
displayHtml.append("\n");
displayHtml.append(" </TD>\n");
displayHtml.append("\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param action
*
* @return
*/
protected String displayDeleteButton(String action) {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("delete") < 0) {
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" NAME=\"deleteButton\" TITLE=\"Delete the current record\" onClick=\"return confirmDelete()\"");
if (action.equals(ACTION_SHOW_INSERT) ||
action.equals(ACTION_DELETE) ||
action.equals(ACTION_SHOW_COPY) ||
action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT) || !getIsUpdateable()) {
displayHtml.append(" DISABLED");
displayHtml.append(" SRC=\"" + IMAGE_DELETE_DISABLED + "\">\n");
} else {
displayHtml.append(" SRC=\"" + IMAGE_DELETE + "\">\n");
}
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Delete the current record\" VALUE=\"Delete\" onClick=\"return confirmDelete()\"");
if (action.equals(ACTION_SHOW_INSERT) ||
action.equals(ACTION_DELETE) ||
action.equals(ACTION_SHOW_COPY) ||
action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT) || !getIsUpdateable()) {
displayHtml.append(" DISABLED");
}
displayHtml.append(">\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param action
*
* @return
*/
protected String displayCopyButton(String action) {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("copy") < 0) {
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" NAME=\"copyButton\" TITLE=\"Create a copy of the current record\"");
if (action.equals(ACTION_SHOW_INSERT) ||
action.equals(ACTION_DELETE) ||
action.equals(ACTION_SHOW_COPY) ||
action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT) || !getIsUpdateable()) {
displayHtml.append(" DISABLED");
displayHtml.append(" SRC=\"" + IMAGE_COPY_DISABLED + "\">\n");
} else {
displayHtml.append(" SRC=\"" + IMAGE_COPY + "\">\n");
}
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Create a copy of the current record\" VALUE=\"Copy\"");
if (action.equals(ACTION_SHOW_INSERT) ||
action.equals(ACTION_DELETE) ||
action.equals(ACTION_SHOW_COPY) ||
action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT) || !getIsUpdateable()) {
displayHtml.append(" DISABLED");
}
displayHtml.append(">\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param action
*
* @return
*/
protected String displaySelectButton(String action) {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("select") < 0) {
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" NAME=\"selectButton\" TITLE=\"Add and remove entities\"");
if (action.equals(ACTION_SHOW_SELECT) ||
action.equals(ACTION_UPDATE_SELECT) || !getIsUpdateable()) {
displayHtml.append(" DISABLED");
displayHtml.append(" SRC=\"" + IMAGE_SELECT_DISABLED + "\">\n");
} else {
displayHtml.append(" SRC=\"" + IMAGE_SELECT + "\">\n");
}
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Add and remove entities\" VALUE=\"Select\"");
if (action.equals(ACTION_SHOW_SELECT) ||
action.equals(ACTION_UPDATE_SELECT) || !getIsUpdateable()) {
displayHtml.append(" DISABLED");
}
displayHtml.append(">\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param action
*
* @return
*/
protected String displayPrintButton(String action) {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("print") < 0) {
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" NAME=\"printButton\" TITLE=\"Print the current record\"");
if (action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT)) {
displayHtml.append(" DISABLED");
displayHtml.append(" SRC=\"" + IMAGE_PRINT_DISABLED + "\">\n");
} else {
displayHtml.append(" DISABLED"); // Remove this when the print button is activated.
displayHtml.append(" SRC=\"" + IMAGE_PRINT + "\">\n");
}
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Print the current record\" VALUE=\"Print\"");
if (action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT)) {
// displayHtml.append(" DISABLED"); Uncomment this when the print button is activated.
}
displayHtml.append(" DISABLED"); // Remove this when the print button is activated.
displayHtml.append(">\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param action
*
* @return
*/
protected String displayCancelButton(String action) {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("cancel") < 0) {
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" NAME=\"cancelButton\" TITLE=\"Cancel the current action\"");
// if ( action.equals(ACTION_SHOW_QUERY) || action.equals(ACTION_SHOW_QUERY_REPORT) || action.equals(ACTION_SHOW_REPORT)) {
// displayHtml.append(" DISABLED");
// displayHtml.append(" SRC=\"" + IMAGE_STOP_DISABLED + "\">\n");
// } else {
displayHtml.append(" SRC=\"" + IMAGE_STOP + "\">\n");
// }
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Cancel the current action\" VALUE=\"Cancel\"");
// if (action.equals(ACTION_SHOW_QUERY) || action.equals(ACTION_SHOW_QUERY_REPORT) || action.equals(ACTION_SHOW_REPORT)) {
// displayHtml.append(" DISABLED");
// }
displayHtml.append(">\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @return
*/
protected String displayCustomizeButton() {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("customize") < 0) {
displayHtml.append(" <TD ALIGN=\"right\">\n");
displayHtml.append(
" <FORM METHOD=\"post\" ACTION=\"/sfa/control/uiScreenSectionCustomize\" TARGET=\"content\">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"sectionId\" VALUE=\"" +
getSectionId() + "\">\n");
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" SRC=\"" +
IMAGE_PROPERTIES +
"\" NAME=\"customizeButton\" TITLE=\"Customize this screen section\">\n");
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Customize this screen section\" VALUE=\"Customize\">\n");
displayHtml.append(" </FORM>\n");
displayHtml.append(" </TD>\n");
displayHtml.append("\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param keyParams
* @param sendQueryParams
* @param action
*
* @return
*/
protected String displayDetailButton(String keyParams,
String sendQueryParams, String action) {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("detail") < 0) {
displayHtml.append(" <TD>\n");
displayHtml.append(" <FORM METHOD=\"post\" ACTION=\"" +
getDetailButtonAction() + "\"");
if ((getDetailButtonTarget() != null) &&
!getDetailButtonTarget().equals("")) {
displayHtml.append(" TARGET=\"" + getDetailButtonTarget() +
"\"");
}
displayHtml.append(">\n");
displayHtml.append(keyParams);
displayHtml.append(sendQueryParams);
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"button\">\n");
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"image\" NAME=\"detailButton\" TITLE=\"Show detail for current record\"");
if (action.equals(ACTION_SHOW_INSERT) ||
action.equals(ACTION_DELETE) ||
action.equals(ACTION_SHOW_COPY) ||
action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT) ||
getDetailButtonAction().equals("")) {
displayHtml.append(" DISABLED");
displayHtml.append(" SRC=\"" + IMAGE_OPEN_DISABLED + "\">\n");
} else {
displayHtml.append(" SRC=\"" + IMAGE_OPEN + "\">\n");
}
displayHtml.append(
" <INPUT CLASS=\"titleBarImageButton\" TYPE=\"submit\" NAME=\"buttonAction\" TITLE=\"Show detail for current record\" VALUE=\"Detail\"");
if (action.equals(ACTION_SHOW_INSERT) ||
action.equals(ACTION_DELETE) ||
action.equals(ACTION_SHOW_COPY) ||
action.equals(ACTION_SHOW_QUERY) ||
action.equals(ACTION_SHOW_QUERY_REPORT) ||
action.equals(ACTION_SHOW_REPORT) ||
getDetailButtonAction().equals("")) {
displayHtml.append(" DISABLED");
}
displayHtml.append(">\n");
displayHtml.append(" </FORM>\n");
displayHtml.append("\n");
displayHtml.append(" </TD>\n");
displayHtml.append("\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param sendQueryParams
* @param queryId
*
* @return
*
* @throws GenericEntityException
*/
protected String displayQueryPicker(String sendQueryParams, String queryId)
throws GenericEntityException {
StringBuffer displayHtml = new StringBuffer("");
if (getHideButtons().indexOf("querypicker") < 0) {
displayHtml.append(
" <TD CLASS=\"freeFormSectionDisplayTable\" ALIGN=\"right\">\n");
List queryGVL = UIQuery.getUiQueryList(getDelegator(),
getUserInfo().getPartyId(), getSectionName(),
getUiScreen().getScreenName());
displayHtml.append(" <FORM METHOD=\"post\" ACTION=\"" +
getSearchAction() + "\" TARGET=\"" + getSearchTarget() +
"\" NAME=\"" + getSectionName() + "QueryForm\">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
ACTION_QUERY + "\">\n");
displayHtml.append(sendQueryParams);
displayHtml.append(UIDropDown.getSelectHtml("queryId", 1, "", "N",
"querySelectBox", "Y",
"onchange=\"document." + getSectionName() +
"QueryForm.submit();\"",
UIDropDown.decodeValueArray("queryId", "queryName",
"queryId", queryGVL), queryId, false));
displayHtml.append(" </FORM>\n");
displayHtml.append(" </TD>\n");
displayHtml.append("\n");
}
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param sendQueryParams
* @param queryId
*
* @return
*
* @throws GenericEntityException
*/
protected String displayMultiPageForm(String sendQueryParams, String queryId)
throws GenericEntityException {
StringBuffer displayHtml = new StringBuffer("");
displayHtml.append(" <FORM METHOD=\"post\" ACTION=\"" +
getSearchAction() + "\" TARGET=\"" + getSearchTarget() +
"\" NAME=\"" + getSectionName() + "PageForm\">\n");
displayHtml.append(
" <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
ACTION_QUERY + "\">\n");
displayHtml.append(sendQueryParams);
displayHtml.append("<INPUT TYPE=\"HIDDEN\" NAME=\"" + getSectionName() +
"_page_selector\" value=\"\">");
displayHtml.append("<SCRIPT LANGUAGE=\"javascript\">");
displayHtml.append("function " + getSectionName() +
"_selectPage (value) {");
displayHtml.append(" document.forms[0]." + getSectionName() +
"_page_selector.value=value;");
displayHtml.append(" document.forms[0].submit();");
displayHtml.append("}");
displayHtml.append("</SCRIPT>");
displayHtml.append(" Use Saved Query:\n");
/* displayHtml.append(
UIDropDown.getSelectHtml(
"queryId",
1,
"",
"N",
"querySelectBox",
"Y",
"queryId",
"queryName",
"onchange=\"document." + getSectionName() + "QueryForm.submit();\"",
queryGVL,
queryId,
false
)
); */
displayHtml.append(" </FORM>\n");
displayHtml.append(" </TD>\n");
displayHtml.append("\n");
return displayHtml.toString();
}
/**
* DOCUMENT ME!
*
* @param hasPriorPage
* @param priorPageStartRow
* @param hasNextPage
* @param nextPageStartRow
*
* @return
*/
public String displayPageButtons(boolean hasPriorPage,
int priorPageStartRow, boolean hasNextPage, int nextPageStartRow, String queryId) {
return "";
}
/**
* DOCUMENT ME!
*
* @return
*/
public int getFirstVisibleRow() {
return firstVisibleRow;
}
/**
* DOCUMENT ME!
*
* @param row
*/
public void setFirstVisibleRow(int row) {
firstVisibleRow = row;
}
public List getRelatedSectionQueryFields()
{
try
{
List relatedFields = getDelegator().findByAnd("UiRelatedSectionQueryFields",
UtilMisc.toMap("sectionId", getSectionId(), "useInAdvancedQueries", "Y", "isSearchable", "Y"),
UtilMisc.toList("relatedSectionId", "displayOrder"));
return relatedFields;
} catch (GenericEntityException e)
{
Debug.logError("Unable to get Related Screen Fields:" + e.getMessage(), module);
e.printStackTrace();
return null;
}
}
/**
* DOCUMENT ME!
*
* @param userInfo
* @param screenName
* @param sectionName
* @param delegator
* @param uiCache
*
* @return
*
* @throws GenericEntityException
*/
public static UIWebScreenSection getUiWebScreenSection(UserInfo userInfo,
String screenName, String sectionName, GenericDelegator delegator,
UICache uiCache) throws GenericEntityException {
// This method is here so a child class can specify a different screen section class.
Debug.logVerbose("Looking in cache for UIScreenSection", module);
UIScreenSection uiScreenSection = uiCache.getUiScreenSection(screenName,
sectionName, userInfo.getPartyId());
UIWebScreenSection uiWebScreenSection = null;
if (uiScreenSection == null) {
Debug.logVerbose("Screen section not found in cache. Creating", module);
uiWebScreenSection = new UIWebScreenSection(userInfo, screenName,
sectionName, delegator, uiCache);
uiCache.putUiScreenSection(screenName, sectionName,
userInfo.getPartyId(), (UIScreenSection) uiWebScreenSection);
} else {
Debug.logVerbose("Screen section found in cache", module);
uiWebScreenSection = (UIWebScreenSection) uiScreenSection;
}
return uiWebScreenSection;
}
/**
* @return Returns the queryMode.
*/
public String getQueryMode() {
return queryMode;
}
/**
* @param queryMode The queryMode to set.
*/
public void setQueryMode(String queryMode) {
this.queryMode = queryMode;
}
}