Examples of UtilTimer


Examples of org.ofbiz.base.util.UtilTimer

          * @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)");
                }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.