Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -141,9 +141,9 @@ this.widgetStyle = fieldElement.getAttribute("widget-style"); this.tooltipStyle = fieldElement.getAttribute("tooltip-style"); this.requiredFieldStyle = fieldElement.getAttribute("required-field-style"); - this.sortFieldStyle = fieldElement.getAttribute("sort-field-style"); + this.sortFieldStyle = fieldElement.getAttribute("sort-field-style"); this.sortFieldAscStyle = fieldElement.getAttribute("sort-field-asc-style"); - this.sortFieldDescStyle = fieldElement.getAttribute("sort-field-desc-style"); + this.sortFieldDescStyle = fieldElement.getAttribute("sort-field-desc-style"); this.redWhen = fieldElement.getAttribute("red-when"); this.setUseWhen(fieldElement.getAttribute("use-when")); this.encodeOutput = !"false".equals(fieldElement.getAttribute("encode-output")); @@ -285,7 +285,7 @@ if (UtilValidate.isNotEmpty(overrideFormField.titleAreaStyle)) this.titleAreaStyle = overrideFormField.titleAreaStyle; if (UtilValidate.isNotEmpty(overrideFormField.widgetAreaStyle)) - this.widgetAreaStyle = overrideFormField.widgetAreaStyle; + this.widgetAreaStyle = overrideFormField.widgetAreaStyle; if (UtilValidate.isNotEmpty(overrideFormField.titleStyle)) this.titleStyle = overrideFormField.titleStyle; if (UtilValidate.isNotEmpty(overrideFormField.widgetStyle)) @@ -669,14 +669,14 @@ public String getEntry(Map<String, Object> context , String defaultValue) { Boolean isError = (Boolean) context.get("isError"); Boolean useRequestParameters = (Boolean) context.get("useRequestParameters"); - + Locale locale = (Locale) context.get("locale"); if (locale == null) locale = Locale.getDefault(); TimeZone timeZone = (TimeZone) context.get("timeZone"); if (timeZone == null) timeZone = TimeZone.getDefault(); - + String returnValue; - + // if useRequestParameters is TRUE then parameters will always be used, if FALSE then parameters will never be used // if isError is TRUE and useRequestParameters is not FALSE (ie is null or TRUE) then parameters will be used if ((Boolean.TRUE.equals(isError) && !Boolean.FALSE.equals(useRequestParameters)) || (Boolean.TRUE.equals(useRequestParameters))) { @@ -705,7 +705,7 @@ dataMapIsContext = true; } Object retVal = null; - if (this.entryAcsr != null && !this.entryAcsr.isEmpty()) { + if (this.entryAcsr != null && !this.entryAcsr.isEmpty()) { //Debug.logInfo("Getting entry, using entryAcsr for field " + this.getName() + " of form " + this.modelForm.getName(), module); if (dataMap instanceof GenericEntity) { GenericEntity genEnt = (GenericEntity) dataMap; @@ -722,7 +722,7 @@ // if no entry name was specified, use the field's name retVal = dataMap.get(this.name); } - + // this is a special case to fill in fields during a create by default from parameters passed in if (dataMapIsContext && retVal == null && !Boolean.FALSE.equals(useRequestParameters)) { Map<String, ? extends Object> parameters = UtilGenerics.checkMap(context.get("parameters")); @@ -760,7 +760,7 @@ returnValue = defaultValue; } } - + if (this.getEncodeOutput() && returnValue != null) { StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); if (simpleEncoder != null) { @@ -994,7 +994,7 @@ // this should never happen, ie name is required return ""; } - + // search for a localized label for the field's name Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap")); if (uiLabelMap != null) { @@ -1006,7 +1006,7 @@ } else { Debug.logWarning("Could not find uiLabelMap in context while rendering form " + this.modelForm.getName(), module); } - + // create a title from the name of this field; expecting a Java method/field style name, ie productName or productCategoryId StringBuffer autoTitlewriter = new StringBuffer(); @@ -1049,25 +1049,25 @@ return this.modelForm.getDefaultRequiredFieldStyle(); } } - + public String getSortFieldStyle() { if (UtilValidate.isNotEmpty(this.sortFieldStyle)) { return this.sortFieldStyle; - } + } return this.modelForm.getDefaultSortFieldStyle(); } - + public String getSortFieldStyleAsc() { if (UtilValidate.isNotEmpty(this.sortFieldAscStyle)) { return this.sortFieldAscStyle; - } + } return this.modelForm.getDefaultSortFieldAscStyle(); } - + public String getSortFieldStyleDesc() { if (UtilValidate.isNotEmpty(this.sortFieldDescStyle)) { return this.sortFieldDescStyle; - } + } return this.modelForm.getDefaultSortFieldDescStyle(); } @@ -1086,7 +1086,7 @@ return ""; } } - + public boolean getEncodeOutput() { return this.encodeOutput; } @@ -1098,15 +1098,15 @@ return this.modelForm.getName() + "_" + this.getFieldName(); } } - + public String getHeaderLink() { return headerLink; } - + public String getHeaderLinkStyle() { return headerLinkStyle; } - + /** * @param string @@ -1306,7 +1306,7 @@ public void setUseWhen(String string) { this.useWhen = FlexibleStringExpander.getInstance(string); } - + public void setEncodeOutput(boolean encodeOutput) { this.encodeOutput = encodeOutput; } @@ -1317,7 +1317,7 @@ public void setWidgetAreaStyle(String string) { this.widgetAreaStyle = string; } - + /** * @param string */ @@ -1342,37 +1342,37 @@ public void setHeaderLink(String string) { this.headerLink = string; } - + /** * @param string */ public void setHeaderLinkStyle(String string) { this.headerLinkStyle = string; } - - + + public boolean getRequiredField() { return this.requiredField != null ? this.requiredField : false; } - + /** * @param boolean */ public void setRequiredField(boolean required) { this.requiredField = required; } - + public boolean isSortField() { return this.sortField != null ? this.sortField.booleanValue() : false; } - + /** * @param boolean */ public void setSortField(boolean sort) { this.sortField = Boolean.valueOf(sort); - } - + } + /** * @param ModelForm */ @@ -1551,7 +1551,7 @@ return this.noCurrentSelectedKey.expandString(context); } - public void setNoCurrentSelectedKey(String string) { + public void setNoCurrentSelectedKey(String string) { this.noCurrentSelectedKey = FlexibleStringExpander.getInstance(string); } @@ -1705,10 +1705,10 @@ } findCondition = EntityCondition.makeCondition(expandedConditionList); } - + try { Locale locale = UtilMisc.ensureLocale(context.get("locale")); - + List<GenericValue> values = null; values = delegator.findList(this.entityName, findCondition, null, this.orderByList, null, this.cache); @@ -1730,7 +1730,7 @@ // expand with the new localContext, which is locale aware String optionDesc = this.description.expandString(localContext, locale); - + Object keyFieldObject = value.get(this.getKeyFieldName()); if (keyFieldObject == null) { throw new IllegalArgumentException("The value found for key-name [" + this.getKeyFieldName() + "], may not be a valid key field name."); @@ -1770,7 +1770,7 @@ protected String rows; protected String cols; protected Map<FlexibleMapAccessor<Object>, Object> fieldMap; - + public InPlaceEditor (Element element) { this.setUrl(element.getAttribute("url")); this.cancelControl = element.getAttribute("cancel-control"); @@ -1794,11 +1794,11 @@ this.textAfterControls = element.getAttribute("text-after-controls"); this.textBetweenControls = element.getAttribute("text-between-controls"); this.updateAfterRequestCall = element.getAttribute("update-after-request-call"); - + Element simpleElement = UtilXml.firstChildElement(element, "simple-editor"); this.rows = simpleElement.getAttribute("rows"); this.cols = simpleElement.getAttribute("cols"); - + this.fieldMap = EntityFinderUtil.makeFieldMap(element); } @@ -1823,7 +1823,7 @@ } public String getFieldPostCreation() { - return this.fieldPostCreation; + return this.fieldPostCreation; } public String getFormClassName() { @@ -2008,7 +2008,7 @@ this.fieldMap = fieldMap; } } - + public static class DisplayField extends FieldInfo { protected boolean alsoHidden = true; protected FlexibleStringExpander description; @@ -2036,7 +2036,7 @@ this.setDescription(element.getAttribute("description")); this.setDate(element.getAttribute("date")); this.alsoHidden = !"false".equals(element.getAttribute("also-hidden")); - + Element inPlaceEditorElement = UtilXml.firstChildElement(element, "in-place-editor"); if (inPlaceEditorElement != null) { this.inPlaceEditor = new InPlaceEditor(inPlaceEditorElement); @@ -2075,13 +2075,13 @@ String errMsg = "Error formatting currency value [" + retVal + "]: " + e.toString(); Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); - } + } } else if ("date".equals(type) && retVal.length() > 10) { retVal = retVal.substring(0,10); } return retVal; } - + public InPlaceEditor getInPlaceEditor() { return this.inPlaceEditor; } @@ -2099,7 +2099,7 @@ public void setDescription(String string) { description = FlexibleStringExpander.getInstance(string); } - + /** * @param string */ @@ -2112,7 +2112,7 @@ public void setDate(String string) { date = FlexibleStringExpander.getInstance(string); } - + public void setInPlaceEditor(InPlaceEditor newInPlaceEditor) { this.inPlaceEditor = newInPlaceEditor; } @@ -2157,7 +2157,7 @@ public String getDescription(Map<String, Object> context) { Locale locale = UtilMisc.ensureLocale(context.get("locale")); - + // rather than using the context to expand the string, lookup the given entity and use it to expand the string GenericValue value = null; String fieldKey = this.keyFieldName; @@ -2173,7 +2173,7 @@ Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } - + String retVal = null; if (value != null) { // expanding ${} stuff, passing locale explicitly to expand value string because it won't be found in the Entity @@ -2200,7 +2200,7 @@ this.subHyperlink = newSubHyperlink; } } - + public static class HyperlinkField extends FieldInfo { public static String DEFAULT_TARGET_TYPE = "intra-app"; @@ -2235,7 +2235,7 @@ this.targetType = element.getAttribute("target-type"); this.targetWindowExdr = FlexibleStringExpander.getInstance(element.getAttribute("target-window")); this.image = element.getAttribute("image-location"); - + List<? extends Element> parameterElementList = UtilXml.childElementList(element, "parameter"); for (Element parameterElement: parameterElementList) { this.parameterList.add(new WidgetWorker.Parameter(parameterElement)); @@ -2253,7 +2253,7 @@ public String getLinkType() { return this.linkType; } - + public String getTargetType() { if (UtilValidate.isNotEmpty(this.targetType)) { return this.targetType; @@ -2266,7 +2266,7 @@ String targetWindow = this.targetWindowExdr.expandString(context); return targetWindow; } - + public String getDescription(Map<String, Object> context) { return this.description.expandString(context); } @@ -2274,11 +2274,11 @@ public String getTarget(Map<String, Object> context) { return this.target.expandString(context); } - + public List<WidgetWorker.Parameter> getParameterList() { return this.parameterList; } - + public String getImage() { return this.image; } @@ -2331,12 +2331,12 @@ this.linkStyle = element.getAttribute("link-style"); this.targetType = element.getAttribute("target-type"); this.targetWindowExdr = FlexibleStringExpander.getInstance(element.getAttribute("target-window")); - + List<? extends Element> parameterElementList = UtilXml.childElementList(element, "parameter"); for (Element parameterElement: parameterElementList) { this.parameterList.add(new WidgetWorker.Parameter(parameterElement)); } - + this.modelFormField = modelFormField; } @@ -2364,7 +2364,7 @@ String targetWindow = this.targetWindowExdr.expandString(context); return targetWindow; } - + public String getTarget(Map<String, Object> context) { if (this.target != null) { return this.target.expandString(context); @@ -2372,11 +2372,11 @@ return ""; } } - + public String getLinkType() { return this.linkType; } - + public List<WidgetWorker.Parameter> getParameterList() { return this.parameterList; } @@ -2388,7 +2388,7 @@ return ""; } } - + public ModelFormField getModelFormField() { return this.modelFormField; } @@ -2458,7 +2458,7 @@ this.useWhen = FlexibleStringExpander.getInstance(string); } } - + public static class AutoComplete { protected String autoSelect; protected String frequency; @@ -2468,7 +2468,7 @@ protected String partialChars; protected String ignoreCase; protected String fullSearch; - + public AutoComplete(Element element) { this.autoSelect = element.getAttribute("auto-select"); this.frequency = element.getAttribute("frequency"); @@ -2479,67 +2479,67 @@ this.ignoreCase = element.getAttribute("ignore-case"); this.fullSearch = element.getAttribute("full-search"); } - + public String getAutoSelect() { return this.autoSelect; } - + public String getFrequency() { return this.frequency; } - + public String getMinChars() { return this.minChars; } - + public String getChoices() { return this.choices; } - + public String getPartialSearch() { return this.partialSearch; } - + public String getPartialChars() { return this.partialChars; } - + public String getIgnoreCase() { return this.ignoreCase; } - + public String getFullSearch() { return this.fullSearch; } - + public void setAutoSelect(String string) { this.autoSelect = string; } - + public void setFrequency(String string) { this.frequency = string; } - + public void setMinChars(String string) { this.minChars = string; } - + public void setChoices(String string) { this.choices = string; } - + public void setPartialSearch(String string) { this.partialSearch = string; } - + public void setPartialChars(String string) { this.partialChars = string; } - + public void setIgnoreCase(String string) { this.ignoreCase = string; } - + public void setFullSearch(String string) { this.fullSearch = string; } @@ -2552,7 +2552,7 @@ protected SubHyperlink subHyperlink; protected boolean disabled; protected boolean clientAutocompleteField; - + protected TextField() { super(); } @@ -2587,7 +2587,7 @@ Debug.logError("Could not parse the max-length value of the text element: [" + maxlengthStr + "], setting to null; default of no maxlength will be used", module); } } - + this.disabled = "true".equals(element.getAttribute("disabled")); this.clientAutocompleteField = !"false".equals(element.getAttribute("client-autocomplete-field")); @@ -2609,21 +2609,21 @@ public int getSize() { return size; } - + public boolean getDisabled() { return this.disabled; } - + public void setDisabled(boolean b) { - this.disabled = b; + this.disabled = b; } public boolean getClientAutocompleteField() { return this.clientAutocompleteField; } - + public void setClientAutocompleteField(boolean b) { - this.clientAutocompleteField = b; + this.clientAutocompleteField = b; } public String getDefaultValue(Map<String, Object> context) { @@ -2686,7 +2686,7 @@ public TextareaField(Element element, ModelFormField modelFormField) { super(element, modelFormField); this.setDefaultValue(element.getAttribute("default-value")); - + visualEditorEnable = "true".equals(element.getAttribute("visual-editor-enable")); visualEditorButtons = FlexibleStringExpander.getInstance(element.getAttribute("visual-editor-buttons")); readOnly = "true".equals(element.getAttribute("read-only")); @@ -2741,7 +2741,7 @@ public boolean isReadOnly() { return readOnly; } - + /** * @param r */ @@ -2927,7 +2927,7 @@ if (subHyperlinkElement != null) { this.subHyperlink = new SubHyperlink(subHyperlinkElement, this.getModelFormField()); } - + Element autoCompleteElement = UtilXml.firstChildElement(element, "auto-complete"); if (autoCompleteElement != null) { this.autoComplete = new AutoComplete(autoCompleteElement); @@ -2979,23 +2979,23 @@ public void setSubHyperlink(SubHyperlink newSubHyperlink) { this.subHyperlink = newSubHyperlink; } - + public AutoComplete getAutoComplete() { return this.autoComplete; } - + public void setAutoComplete(AutoComplete newAutoComplete) { this.autoComplete = newAutoComplete; } - + public int getOtherFieldSize() { - return this.otherFieldSize; + return this.otherFieldSize; } public String getSize() { return this.size; } - + /** * Get the name to use for the parameter for this field in the form interpreter. * For HTML forms this is the request parameter name. @@ -3009,7 +3009,7 @@ } else { baseName = this.modelFormField.name; } - + baseName += "_OTHER"; Integer itemIndex = (Integer) context.get("itemIndex"); if (itemIndex != null && "multi".equals(this.modelFormField.modelForm.getType())) { @@ -3067,7 +3067,7 @@ public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { formStringRenderer.renderCheckField(writer, context, this); } - + public Boolean isAllChecked(Map<String, Object> context) { String allCheckedStr = this.allChecked.expandString(context); if (UtilValidate.isNotEmpty(allCheckedStr)) { @@ -3127,7 +3127,7 @@ public void setImageLocation(String string) { imageLocation = string; } - + public String getBackgroundSubmitRefreshTarget(Map<String, Object> context) { return this.backgroundSubmitRefreshTargetExdr.expandString(context); } @@ -3246,11 +3246,11 @@ public String getDefaultOption() { return this.defaultOption; } - + public boolean getHideIgnoreCase() { return this.hideIgnoreCase; } - + public boolean getHideOptions() { return this.hideOptions; } @@ -3319,7 +3319,7 @@ protected String descriptionFieldName; protected String targetParameter; protected SubHyperlink subHyperlink; - + public LookupField(Element element, ModelFormField modelFormField) { super(element, modelFormField); this.formName = FlexibleStringExpander.getInstance(element.getAttribute("target-form-name")); @@ -3358,7 +3358,7 @@ public void setFormName(String str) { this.formName = FlexibleStringExpander.getInstance(str); } - + public String getDescriptionFieldName() { return this.descriptionFieldName; } @@ -3366,7 +3366,7 @@ public void setDescriptionFieldName(String str) { this.descriptionFieldName = str; } - + public SubHyperlink getSubHyperlink() { return this.subHyperlink; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -76,7 +76,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRenderer { public static final String module = HtmlFormRenderer.class.getName(); - + protected HttpServletRequest request; protected HttpServletResponse response; protected RequestHandler rh; @@ -131,17 +131,17 @@ } public void addAsterisks(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { - + boolean requiredField = modelFormField.getRequiredField(); if (requiredField) { String requiredStyle = modelFormField.getRequiredFieldStyle(); - + if (UtilValidate.isEmpty(requiredStyle)) { writer.append("*"); } } } - + public void appendClassNames(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { String className = modelFormField.getWidgetStyle(); if (UtilValidate.isNotEmpty(className) || modelFormField.shouldBeRed(context)) { @@ -154,7 +154,7 @@ writer.append('"'); } } - + /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderDisplayField(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelFormField.DisplayField) */ @@ -163,7 +163,7 @@ ModelForm modelForm = modelFormField.getModelForm(); StringBuffer str = new StringBuffer(); - + String idName = modelFormField.getIdName(); if (UtilValidate.isNotEmpty(idName) && ("list".equals(modelForm.getType()) || "multi".equals(modelForm.getType()))) { idName += "_" + modelForm.getRowCount(); @@ -201,10 +201,10 @@ if (str.length() > 0) { writer.append("</span>"); } - + ModelFormField.InPlaceEditor inPlaceEditor = displayField.getInPlaceEditor(); boolean ajaxEnabled = inPlaceEditor != null && this.javaScriptEnabled; - + if (ajaxEnabled) { writer.append("<script language=\"JavaScript\" type=\"text/javascript\">"); String url = inPlaceEditor.getUrl(context); @@ -324,7 +324,7 @@ if (displayField instanceof DisplayEntityField) { this.makeHyperlinkString(writer, ((DisplayEntityField) displayField).getSubHyperlink(), context); } - + this.appendTooltip(writer, context, modelFormField); //appendWhitespace(writer); @@ -336,11 +336,11 @@ public void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField) throws IOException { this.request.setAttribute("image", hyperlinkField.getImage()); ModelFormField modelFormField = hyperlinkField.getModelFormField(); - - WidgetWorker.makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), hyperlinkField.getTargetType(), hyperlinkField.getTarget(context), - hyperlinkField.getParameterList(), hyperlinkField.getDescription(context), hyperlinkField.getTargetWindow(context), modelFormField, + + WidgetWorker.makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), hyperlinkField.getTargetType(), hyperlinkField.getTarget(context), + hyperlinkField.getParameterList(), hyperlinkField.getDescription(context), hyperlinkField.getTargetWindow(context), modelFormField, this.request, this.response, context); - + this.appendTooltip(writer, context, modelFormField); //appendWhitespace(writer); } @@ -351,8 +351,8 @@ } if (subHyperlink.shouldUse(context)) { writer.append(' '); - WidgetWorker.makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), subHyperlink.getTargetType(), subHyperlink.getTarget(context), - subHyperlink.getParameterList(), subHyperlink.getDescription(context), subHyperlink.getTargetWindow(context), subHyperlink.getModelFormField(), + WidgetWorker.makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), subHyperlink.getTargetType(), subHyperlink.getTarget(context), + subHyperlink.getParameterList(), subHyperlink.getDescription(context), subHyperlink.getTargetWindow(context), subHyperlink.getModelFormField(), this.request, this.response, context); } } @@ -413,7 +413,7 @@ } writer.append("/>"); - + this.addAsterisks(writer, context, modelFormField); this.makeHyperlinkString(writer, textField.getSubHyperlink(), context); @@ -476,11 +476,11 @@ } writer.append("</textarea>"); - + if (textareaField.getVisualEditorEnable()) { writer.append("<script language=\"javascript\" src=\"/images/htmledit/whizzywig.js\" type=\"text/javascript\"></script>"); writer.append("<script language=\"javascript\" type=\"text/javascript\"> buttonPath = \"/images/htmledit/\"; cssFile=\"/images/htmledit/simple.css\";makeWhizzyWig(\""); - if (UtilValidate.isNotEmpty(idName)) { + if (UtilValidate.isNotEmpty(idName)) { writer.append(idName); } else { writer.append("htmlEditArea"); @@ -509,7 +509,7 @@ ModelFormField modelFormField = dateTimeField.getModelFormField(); String paramName = modelFormField.getParameterName(context); String defaultDateTimeString = dateTimeField.getDefaultDateTimeString(context); - + Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap")); if (uiLabelMap == null) { Debug.logWarning("Could not find uiLabelMap in context", module); @@ -553,7 +553,7 @@ writer.append(" title=\""); writer.append(localizedInputTitle); writer.append('"'); - + String value = modelFormField.getEntry(context, dateTimeField.getDefaultValue(context)); if (UtilValidate.isNotEmpty(value)) { if (value.length() > maxlength) { @@ -563,7 +563,7 @@ writer.append(value); writer.append('"'); } - + writer.append(" size=\""); writer.append(Integer.toString(size)); writer.append('"'); @@ -603,7 +603,7 @@ writer.append(",'"); writer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, defaultDateTimeString))); writer.append("');\">"); - + writer.append("<img src=\""); this.appendContentUrl(writer, "/images/cal.gif"); writer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\""); @@ -612,9 +612,9 @@ writer.append(localizedIconTitle); writer.append("\"/></a>"); } - + // if we have an input method of time-dropdown, then render two dropdowns - if ("time-dropdown".equals(dateTimeField.getInputMethod())) { + if ("time-dropdown".equals(dateTimeField.getInputMethod())) { String className = modelFormField.getWidgetStyle(); String classString = (className != null ? " class=\"" + className + "\" " : ""); boolean isTwelveHour = "12".equals(dateTimeField.getClock()); @@ -626,7 +626,7 @@ cal = Calendar.getInstance(); cal.setTime(defaultTimestamp); } catch (IllegalArgumentException e) { - Debug.logWarning("Form widget field [" + paramName + "] with input-method=\"time-dropdown\" was not able to understand the default time [" + Debug.logWarning("Form widget field [" + paramName + "] with input-method=\"time-dropdown\" was not able to understand the default time [" + defaultDateTimeString + "]. The parsing error was: " + e.getMessage(), module); } @@ -638,7 +638,7 @@ if (isTwelveHour) { for (int i = 1; i <= 12; i++) { writer.append("<option value=\"" + Integer.toString(i) + "\""); - if (cal != null) { + if (cal != null) { int hour = cal.get(Calendar.HOUR_OF_DAY); if (hour == 0) hour = 12; if (hour > 12) hour -= 12; @@ -655,7 +655,7 @@ writer.append(">" + Integer.toString(i) + "</option>"); } } - + // write the select for minutes writer.append("</select>:<select name=\""); writer.append(UtilHttp.makeCompositeParam(paramName, "minutes") + "\""); @@ -705,7 +705,7 @@ String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); - + String currentValue = modelFormField.getEntry(context); // Get the current value's description from the option value. If there // is a localized version it will be there. @@ -731,7 +731,7 @@ writer.append(modelFormField.getParameterName(context)); String idName = modelFormField.getIdName(); - + if (ajaxEnabled) { writer.append("_description\""); @@ -742,7 +742,7 @@ writer.append(textFieldIdName); writer.append('"'); } - + if (UtilValidate.isNotEmpty(currentValue)) { writer.append(" value=\""); String explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context)); @@ -754,7 +754,7 @@ writer.append('"'); } writer.append("/>"); - + appendWhitespace(writer); writer.append("<input type=\"hidden\""); writer.append(" name=\""); @@ -765,14 +765,14 @@ writer.append(idName); writer.append('"'); } - + if (UtilValidate.isNotEmpty(currentValue)) { writer.append(" value=\""); //String explicitDescription = dropDownField.getCurrentDescription(context); writer.append(currentValue); writer.append('"'); } - + writer.append("/>"); appendWhitespace(writer); @@ -790,10 +790,10 @@ } writer.append("};"); appendWhitespace(writer); - writer.append("ajaxAutoCompleteDropDown('" + textFieldIdName + "', '" + idName + "', data, {autoSelect: " + - autoComplete.getAutoSelect() + ", frequency: " + autoComplete.getFrequency() + ", minChars: " + autoComplete.getMinChars() + - ", choices: " + autoComplete.getChoices() + ", partialSearch: " + autoComplete.getPartialSearch() + - ", partialChars: " + autoComplete.getPartialChars() + ", ignoreCase: " + autoComplete.getIgnoreCase() + + writer.append("ajaxAutoCompleteDropDown('" + textFieldIdName + "', '" + idName + "', data, {autoSelect: " + + autoComplete.getAutoSelect() + ", frequency: " + autoComplete.getFrequency() + ", minChars: " + autoComplete.getMinChars() + + ", choices: " + autoComplete.getChoices() + ", partialSearch: " + autoComplete.getPartialSearch() + + ", partialChars: " + autoComplete.getPartialChars() + ", ignoreCase: " + autoComplete.getIgnoreCase() + ", fullSearch: " + autoComplete.getFullSearch() + "});"); appendWhitespace(writer); writer.append("</script>"); @@ -809,7 +809,7 @@ if (dropDownField.isAllowMultiple()) { writer.append(" multiple=\"multiple\""); } - + int otherFieldSize = dropDownField.getOtherFieldSize(); String otherFieldName = dropDownField.getParameterNameOther(context); if (otherFieldSize > 0) { @@ -819,7 +819,7 @@ writer.append(modelForm.getName()); writer.append("."); writer.append(otherFieldName); - writer.append(")\" "); + writer.append(")\" "); } @@ -879,12 +879,12 @@ } writer.append("</select>"); - + // Adapted from work by Yucca Korpela // http://www.cs.tut.fi/~jkorpela/forms/combo.html if (otherFieldSize > 0) { - + String fieldName = modelFormField.getParameterName(context); Map<String, Object> dataMap = UtilGenerics.checkMap(modelFormField.getMap(context)); if (dataMap == null) { @@ -892,7 +892,7 @@ } Object otherValueObj = dataMap.get(otherFieldName); String otherValue = (otherValueObj == null) ? "" : otherValueObj.toString(); - + writer.append("<noscript>"); writer.append("<input type='text' name='"); writer.append(otherFieldName); @@ -927,7 +927,7 @@ writer.append("\n//--></script>"); } } - + this.makeHyperlinkString(writer, dropDownField.getSubHyperlink(), context); this.appendTooltip(writer, context, modelFormField); @@ -943,7 +943,7 @@ ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); Boolean allChecked = checkField.isAllChecked(context); - + List<ModelFormField.OptionValue> allOptionValues = checkField.getAllOptionValues(context, modelForm.getDelegator(context)); String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); @@ -956,7 +956,7 @@ writer.append("<input type=\"checkbox\""); appendClassNames(writer, context, modelFormField); - + // if current value should be selected in the list, select it if (Boolean.TRUE.equals(allChecked)) { writer.append(" checked=\"checked\""); @@ -979,7 +979,7 @@ writer.append(action); writer.append('"'); } - + writer.append("/>"); writer.append(optionValue.getDescription()); @@ -1011,7 +1011,7 @@ appendClassNames(writer, context, modelFormField); writer.append("><input type=\"radio\""); - + // if current value should be selected in the list, select it String noCurrentSelectedKey = radioField.getNoCurrentSelectedKey(context); if (UtilValidate.isNotEmpty(currentValue) && currentValue.equals(optionValue.getKey())) { @@ -1033,7 +1033,7 @@ writer.append(action); writer.append('"'); } - + writer.append("/>"); writer.append(optionValue.getDescription()); @@ -1052,7 +1052,7 @@ ModelFormField modelFormField = submitField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); String event = null; - String action = null; + String action = null; if ("text-link".equals(submitField.getButtonType())) { writer.append("<a"); @@ -1085,7 +1085,7 @@ writer.append(" src=\""); this.appendContentUrl(writer, submitField.getImageLocation()); writer.append('"'); - + event = modelFormField.getEvent(); action = modelFormField.getAction(context); if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) { @@ -1095,7 +1095,7 @@ writer.append(action); writer.append('"'); } - + writer.append("/>"); } else { // default to "button" @@ -1132,7 +1132,7 @@ writer.append('"'); } - + event = modelFormField.getEvent(); action = modelFormField.getAction(context); if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) { @@ -1145,7 +1145,7 @@ //add single click JS onclick // disabling for now, using form onSubmit action instead: writer.append(singleClickAction); } - + if (ajaxEnabled) { writer.append(" onclick=\""); writer.append("ajaxSubmitFormUpdateAreas('"); @@ -1153,7 +1153,7 @@ writer.append("', '" + createAjaxParamsFromUpdateAreas(updateAreas, null, context)); writer.append("')\""); } - + writer.append("/>"); } @@ -1229,7 +1229,7 @@ public void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { String tempTitleText = modelFormField.getTitle(context); String titleText = UtilHttp.encodeAmpersands(tempTitleText); - + if (UtilValidate.isNotEmpty(titleText)) { if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) { writer.append("<span class=\""); @@ -1258,18 +1258,18 @@ public void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { boolean requiredField = modelFormField.getRequiredField(); if (requiredField) { - + String requiredStyle = modelFormField.getRequiredFieldStyle(); if (UtilValidate.isEmpty(requiredStyle)) { requiredStyle = modelFormField.getTitleStyle(); } - + if (UtilValidate.isNotEmpty(requiredStyle)) { writer.append("<span class=\""); writer.append(requiredStyle); writer.append("\">"); } - renderHyperlinkTitle(writer, context, modelFormField, modelFormField.getTitle(context)); + renderHyperlinkTitle(writer, context, modelFormField, modelFormField.getTitle(context)); if (UtilValidate.isNotEmpty(requiredStyle)) { writer.append("</span>"); } @@ -1324,7 +1324,7 @@ writer.append("basic-form"); } writer.append("\""); - + writer.append(" onSubmit=\"javascript:submitFormDisableSubmits(this)\""); if (!modelForm.getClientAutocompleteFields()) { @@ -1373,7 +1373,7 @@ // Threw this in that as a hack to keep the submit button from expanding the first field // Needs a more rugged solution - // WARNING: this method (renderMultiFormClose) must be called after the + // WARNING: this method (renderMultiFormClose) must be called after the // table that contains the list has been closed (to avoid validation errors) so // we cannot call here the methods renderFormatItemRowCell*: for this reason // they are now commented. @@ -1391,7 +1391,7 @@ } writer.append("</form>"); appendWhitespace(writer); - + // see if there is anything that needs to be added outside of the multi-form Map<String, Object> wholeFormContext = UtilGenerics.checkMap(context.get("wholeFormContext")); Appendable postMultiFormWriter = wholeFormContext != null ? (Appendable) wholeFormContext.get("postMultiFormWriter") : null; @@ -1399,7 +1399,7 @@ writer.append(postMultiFormWriter.toString()); appendWhitespace(writer); } - + renderEndingBoundaryComment(writer, "Form Widget - Form Element (Multi)", modelForm); } @@ -1518,7 +1518,7 @@ * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatHeaderRowFormCellTitleSeparator(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelForm, boolean) */ public void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException { - + String titleStyle = modelFormField.getTitleStyle(); if (UtilValidate.isNotEmpty(titleStyle)) { writer.append("<span class=\""); @@ -1539,11 +1539,11 @@ * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatItemRowOpen(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelForm) */ public void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - Integer itemIndex = (Integer)context.get("itemIndex"); - + Integer itemIndex = (Integer)context.get("itemIndex"); + writer.append(" <tr"); if (itemIndex!=null) { - + String altRowStyles = modelForm.getStyleAltRowStyle(context); if (itemIndex.intValue() % 2 == 0) { String evenRowStyle = modelForm.getEvenRowStyle(); @@ -1722,8 +1722,8 @@ writer.append(" <td"); if (positionSpan > 0) { writer.append(" colspan=\""); - // do a span of 1 for this column, plus 3 columns for each spanned - //position or each blank position that this will be filling in + // do a span of 1 for this column, plus 3 columns for each spanned + //position or each blank position that this will be filling in writer.append(Integer.toString(1 + (positionSpan * 3))); writer.append("\""); } @@ -1756,7 +1756,7 @@ public void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField) throws IOException { ModelFormField modelFormField = textFindField.getModelFormField(); - + String defaultOption = textFindField.getDefaultOption(); Locale locale = (Locale)context.get("locale"); if (!textFindField.getHideOptions()) { @@ -1779,7 +1779,7 @@ writer.append(modelFormField.getParameterName(context)); writer.append("_op\" value=\"" + defaultOption + "\"/>"); } - + writer.append("<input type=\"text\""); appendClassNames(writer, context, modelFormField); @@ -1831,7 +1831,7 @@ writer.append(modelFormField.getParameterName(context)); writer.append("_ic\" value=\"" + (ignCase ? "Y" : "") + "\"/>"); } - + if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) { writer.append("</span>"); } @@ -1964,7 +1964,7 @@ String opEquals = UtilProperties.getMessage("conditional", "equals", locale); String opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale); String opSameDay = UtilProperties.getMessage("conditional", "same_day", locale); - String opGreaterThanFromDayStart = UtilProperties.getMessage("conditional", + String opGreaterThanFromDayStart = UtilProperties.getMessage("conditional", "greater_than_from_day_start", locale); String opLessThan = UtilProperties.getMessage("conditional", "less_than", locale); String opUpToDay = UtilProperties.getMessage("conditional", "up_to_day", locale); @@ -2031,14 +2031,14 @@ // search for a localized label for the icon if (uiLabelMap != null) { localizedIconTitle = (String) uiLabelMap.get("CommonViewCalendar"); - } + } // add calendar pop-up button and seed data IF this is not a "time" type date-find if (!"time".equals(dateFindField.getType())) { if ("date".equals(dateFindField.getType())) { writer.append("<a href=\"javascript:call_cal_notime(document."); } else { - writer.append("<a href=\"javascript:call_cal(document."); + writer.append("<a href=\"javascript:call_cal(document."); } writer.append(modelFormField.getModelForm().getCurrentFormName(context)); writer.append('.'); @@ -2115,7 +2115,7 @@ if ("date".equals(dateFindField.getType())) { writer.append("<a href=\"javascript:call_cal_notime(document."); } else { - writer.append("<a href=\"javascript:call_cal(document."); + writer.append("<a href=\"javascript:call_cal(document."); } writer.append(modelFormField.getModelForm().getCurrentFormName(context)); writer.append('.'); @@ -2204,8 +2204,8 @@ } writer.append("/>"); - - // add lookup pop-up button + + // add lookup pop-up button String descriptionFieldName = lookupField.getDescriptionFieldName(); if (UtilValidate.isNotEmpty(descriptionFieldName)) { writer.append("<a href=\"javascript:call_fieldlookup3(document."); @@ -2239,7 +2239,7 @@ writer.append("\" width=\"15\" height=\"14\" border=\"0\" alt=\"Lookup\"/></a>"); this.addAsterisks(writer, context, modelFormField); - + this.makeHyperlinkString(writer, lookupField.getSubHyperlink(), context); this.appendTooltip(writer, context, modelFormField); @@ -2282,7 +2282,7 @@ } if (UtilValidate.isEmpty(targetService) && updateAreas == null) { Debug.logWarning("Cannot paginate because TargetService is empty for the form: " + modelForm.getName(), module); - return; + return; } // get the parameterized pagination index and size fields @@ -2309,8 +2309,8 @@ Debug.logWarning("Could not find uiLabelMap in context", module); } else { pageLabel = (String) uiLabelMap.get("CommonPage"); - Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", Integer.valueOf(lowIndex + 1), "highCount", Integer.valueOf(lowIndex + actualPageSize), "total", Integer.valueOf(listSize)); - commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale")); + Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", Integer.valueOf(lowIndex + 1), "highCount", Integer.valueOf(lowIndex + actualPageSize), "total", Integer.valueOf(listSize)); + commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale")); } // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" and "viewIndex" @@ -2434,7 +2434,7 @@ writer.append(commonDisplaying); writer.append("</li>"); appendWhitespace(writer); - + // Next button writer.append(" <li class=\"" + modelForm.getPaginateNextStyle()); if (highIndex < listSize) { @@ -2492,13 +2492,13 @@ } if (UtilValidate.isEmpty(targetService) && updateAreas == null) { Debug.logWarning("Cannot sort because TargetService is empty for the form: " + modelForm.getName(), module); - return; + return; } String str = (String) context.get("_QBESTRING_"); String oldSortField = modelForm.getSortField(context); String sortFieldStyle = modelFormField.getSortFieldStyle(); - + // if the entry-name is defined use this instead of field name String columnField = modelFormField.getEntryName(); if (UtilValidate.isEmpty(columnField)) { @@ -2520,7 +2520,7 @@ // strip sortField param from the query string HashSet<String> paramName = new HashSet<String>(); paramName.add("sortField"); - String queryString = UtilHttp.stripNamedParamsFromQueryString(str, paramName); + String queryString = UtilHttp.stripNamedParamsFromQueryString(str, paramName); String urlPath = UtilHttp.removeQueryStringFromTarget(targetService); String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService); if (prepLinkText == null) { @@ -2535,7 +2535,7 @@ prepLinkText += queryString + "&"; } prepLinkText += "sortField" + "=" + newSortField; - if (ajaxEnabled) { + if (ajaxEnabled) { prepLinkText = prepLinkText.replace("?", ""); prepLinkText = prepLinkText.replace("&", "&"); } @@ -2543,19 +2543,19 @@ writer.append("<a"); if (UtilValidate.isNotEmpty(sortFieldStyle)) { writer.append(" class=\""); - writer.append(sortFieldStyle); + writer.append(sortFieldStyle); writer.append("\""); } - writer.append(" href=\""); + writer.append(" href=\""); if (ajaxEnabled) { writer.append("javascript:ajaxUpdateAreas('" + createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText, context) + "')"); } else { writer.append(rh.makeLink(this.request, this.response, urlPath + prepLinkText)); } writer.append("\">" + titleText + "</a>"); - } - + } + /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderFileField(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelFormField.FileField) */ @@ -2710,11 +2710,11 @@ //appendWhitespace(writer); } - + public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException { String style = fieldGroup.getStyle(); String id = fieldGroup.getId(); - FlexibleStringExpander titleNotExpanded = FlexibleStringExpander.getInstance(fieldGroup.getTitle()); + FlexibleStringExpander titleNotExpanded = FlexibleStringExpander.getInstance(fieldGroup.getTitle()); String title = titleNotExpanded.expandString(context); Boolean collapsed = fieldGroup.initiallyCollapsed(); String collapsibleAreaId = fieldGroup.getId() + "_body"; @@ -2765,7 +2765,7 @@ writer.append(title); writer.append("</div>"); } - + writer.append("</td></tr></table></div>"); writer.append("<div id=\"" + collapsibleAreaId + "\" class=\"fieldgroup-body\""); @@ -2775,7 +2775,7 @@ writer.append(">"); } } - + public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException { String style = fieldGroup.getStyle(); String id = fieldGroup.getId(); @@ -2785,7 +2785,7 @@ writer.append("</div>"); } } - + // TODO: Remove embedded styling public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException { writer.append(" <table width=\"100%\"> <tr>"); @@ -2794,7 +2794,7 @@ if (UtilValidate.isEmpty(leftStyle)) leftStyle = style; String rightStyle = banner.getRightTextStyle(context); if (UtilValidate.isEmpty(rightStyle)) rightStyle = style; - + String leftText = banner.getLeftText(context); if (UtilValidate.isNotEmpty(leftText)) { writer.append(" <td align=\"left\">"); @@ -2811,7 +2811,7 @@ } writer.append("</td>"); } - + String text = banner.getText(context); if (UtilValidate.isNotEmpty(text)) { writer.append(" <td align=\"center\">"); @@ -2828,7 +2828,7 @@ } writer.append("</td>"); } - + String rightText = banner.getRightText(context); if (UtilValidate.isNotEmpty(rightText)) { writer.append(" <td align=\"right\">"); @@ -2847,7 +2847,7 @@ } writer.append("</tr> </table>"); } - + /** * Renders a link for the column header fields when there is a header-link="" specified in the <field > tag, using * style from header-link-style="". Also renders a selectAll checkbox in multi forms. @@ -2859,7 +2859,7 @@ public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException { if (UtilValidate.isNotEmpty(modelFormField.getHeaderLink())) { StringBuffer targetBuffer = new StringBuffer(); - FlexibleStringExpander target = FlexibleStringExpander.getInstance(modelFormField.getHeaderLink()); + FlexibleStringExpander target = FlexibleStringExpander.getInstance(modelFormField.getHeaderLink()); String fullTarget = target.expandString(context); targetBuffer.append(fullTarget); String targetType = HyperlinkField.DEFAULT_TARGET_TYPE; @@ -2868,7 +2868,7 @@ } WidgetWorker.makeHyperlinkString(writer, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), null, titleText, modelFormField, this.request, this.response, null, null); } else if (modelFormField.isSortField()) { - renderSortField (writer, context, modelFormField, titleText); + renderSortField (writer, context, modelFormField, titleText); } else if (modelFormField.isRowSubmit()) { if (UtilValidate.isNotEmpty(titleText)) writer.append(titleText + "<br/>"); writer.append("<input type=\"checkbox\" name=\"selectAll\" value=\"Y\" onclick=\"javascript:toggleAll(this, '"); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -43,9 +43,9 @@ * Widget Library - HTML Form Wrapper class - makes it easy to do the setup and render of a form */ public class HtmlFormWrapper { - + public static final String module = HtmlFormWrapper.class.getName(); - + protected String resourceName; protected String formName; protected HttpServletRequest request; @@ -56,13 +56,13 @@ protected HtmlFormWrapper() {} - public HtmlFormWrapper(String resourceName, String formName, HttpServletRequest request, HttpServletResponse response) + public HtmlFormWrapper(String resourceName, String formName, HttpServletRequest request, HttpServletResponse response) throws IOException, SAXException, ParserConfigurationException { this.resourceName = resourceName; this.formName = formName; this.request = request; this.response = response; - + try { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); @@ -73,35 +73,35 @@ } this.renderer = new HtmlFormRenderer(request, response); - + this.context = new HashMap<String, Object>(); Map parameterMap = UtilHttp.getParameterMap(request); context.put("parameters", parameterMap); - + //make sure the locale is in the context context.put("locale", UtilHttp.getLocale(request)); //make sure the timeZone is in the context context.put("timeZone", UtilHttp.getTimeZone(request)); - + // if there was an error message, this is an error if (UtilValidate.isNotEmpty((String) request.getAttribute("_ERROR_MESSAGE_"))) { context.put("isError", Boolean.TRUE); } else { context.put("isError", Boolean.FALSE); } - + // if a parameter was passed saying this is an error, it is an error if ("true".equals((String) parameterMap.get("isError"))) { context.put("isError", Boolean.TRUE); } - + Map uiLabelMap = (Map) request.getAttribute("uiLabelMap"); if (uiLabelMap != null && uiLabelMap.size() > 0 && context.get("uiLabelMap") == null) { Debug.logInfo("Got uiLabelMap: " + uiLabelMap, module); context.put("uiLabelMap", uiLabelMap); } } - + @SuppressWarnings("unchecked") public StringWriter renderFormString(Object contextStack) throws IOException { if (contextStack instanceof MapStack) { @@ -125,17 +125,17 @@ return buffer; } - /** + /** * Tells the form library whether this is a response to an error or not. * Defaults on initialization according to the presense of an errorMessage - * in the request or if an isError parameter was passed to the page with + * in the request or if an isError parameter was passed to the page with * the value "true". If true then the prefilled values will come from the - * parameters Map instead of the value Map. + * parameters Map instead of the value Map. */ public void setIsError(boolean isError) { this.context.put("isError", Boolean.valueOf(isError)); } - + public boolean getIsError() { Boolean isErrorBoolean = (Boolean) this.context.get("isError"); if (isErrorBoolean == null) { @@ -144,20 +144,20 @@ return isErrorBoolean.booleanValue(); } } - + /** * The "useRequestParameters" value in the form context tells the form library * to use the request parameters to fill in values instead of the value map. * This is generally used when it is an empty form to pre-set inital values. * This is automatically set to false for list and multi forms. For related * functionality see the setIsError method. - * + * * @param useRequestParameters */ public void setUseRequestParameters(boolean useRequestParameters) { this.context.put("useRequestParameters", Boolean.valueOf(useRequestParameters)); } - + public boolean getUseRequestParameters() { Boolean useRequestParametersBoolean = (Boolean) this.context.get("useRequestParameters"); if (useRequestParametersBoolean == null) { @@ -166,19 +166,19 @@ return useRequestParametersBoolean.booleanValue(); } } - + public void setFormOverrideName(String formName) { this.context.put("formName", formName); } - + public void putInContext(String name, Object value) { this.context.put(name, value); } - + public Object getFromContext(String name) { return this.context.get(name); } - + public ModelForm getModelForm() { return modelForm; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -141,7 +141,7 @@ } public void renderMenuItem(Appendable writer, Map<String, Object> context, ModelMenuItem menuItem) throws IOException { - + //Debug.logInfo("in renderMenuItem, menuItem:" + menuItem.getName() + " context:" + context ,""); boolean hideThisItem = isHideIfSelected(menuItem, context); //if (Debug.infoOn()) Debug.logInfo("in HtmlMenuRendererImage, hideThisItem:" + hideThisItem,""); @@ -149,18 +149,18 @@ return; String style = null; - + if (menuItem.isSelected(context)) { style = menuItem.getSelectedStyle(); if (UtilValidate.isEmpty(style)) { style = "selected"; } } - + if (menuItem.getDisabled()) { style = menuItem.getDisabledTitleStyle(); } - + writer.append(" <li"); String alignStyle = menuItem.getAlignStyle(); if (UtilValidate.isNotEmpty(style) || UtilValidate.isNotEmpty(alignStyle)) { @@ -178,15 +178,15 @@ writer.append(" title=\"" + toolTip + "\""); } writer.append(">"); - + Link link = menuItem.getLink(); //if (Debug.infoOn()) Debug.logInfo("in HtmlMenuRendererImage, link(0):" + link,""); if (link != null) { renderLink(writer, context, link); - } + } writer.append("</li>"); - + appendWhitespace(writer); } @@ -249,7 +249,7 @@ } appendWhitespace(writer); writer.append(" <ul>"); - + appendWhitespace(writer); } @@ -273,8 +273,8 @@ writer.append("</div>"); appendWhitespace(writer); renderEndingBoundaryComment(writer, "Menu Widget", modelMenu); - - userLoginIdHasChanged = userLoginIdHasChanged(); + + userLoginIdHasChanged = userLoginIdHasChanged(); GenericValue userLogin = (GenericValue)request.getSession().getAttribute("userLogin"); if (userLogin != null) { String userLoginId = userLogin.getString("userLoginId"); @@ -368,7 +368,7 @@ if (menuItem.getDisabled()) { target = null; } - + if (UtilValidate.isNotEmpty(target)) { HttpServletResponse response = (HttpServletResponse) context.get("response"); HttpServletRequest request = (HttpServletRequest) context.get("request"); @@ -381,7 +381,7 @@ writer.append("<form method=\"post\""); writer.append(" action=\""); // note that this passes null for the parameterList on purpose so they won't be put into the URL - WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), null, link.getPrefix(context), + WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), null, link.getPrefix(context), link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context); writer.append("\""); @@ -404,10 +404,10 @@ writer.append(parameter.getValue(context)); writer.append("\" type=\"hidden\"/>"); } - + writer.append("</form>"); } - + writer.append("<a"); String id = link.getId(context); if (UtilValidate.isNotEmpty(id)) { @@ -415,7 +415,7 @@ writer.append(id); writer.append("\""); } - + String style = link.getStyle(context); if (UtilValidate.isNotEmpty(style)) { writer.append(" class=\""); @@ -440,12 +440,12 @@ writer.append(uniqueItemName); writer.append(".submit()"); } else { - WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterList(), link.getPrefix(context), + WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterList(), link.getPrefix(context), link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context); } writer.append("\">"); } - + // the text Image img = link.getImage(); if (img == null) { @@ -453,31 +453,31 @@ } else { renderImage(writer, context, img); } - + if (UtilValidate.isNotEmpty(target)) { // close tag writer.append("</a>"); } - + /* NOTE DEJ20090316: This was here as a comment and not sure what it is for or if it is useful... can probably be safely removed in the future if still not used/needed boolean isSelected = menuItem.isSelected(context); - + String style = null; - + if (isSelected) { style = menuItem.getSelectedStyle(); } else { style = link.getStyle(context); - if (UtilValidate.isEmpty(style)) + if (UtilValidate.isEmpty(style)) style = menuItem.getTitleStyle(); - if (UtilValidate.isEmpty(style)) + if (UtilValidate.isEmpty(style)) style = menuItem.getWidgetStyle(); } - + if (menuItem.getDisabled()) { style = menuItem.getDisabledTitleStyle(); } - + if (UtilValidate.isNotEmpty(style)) { writer.append(" class=\""); writer.append(style); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -71,9 +71,9 @@ String cellWidth = menuItem.getCellWidth(); imgStr += "\""; String widthStr = ""; - if (UtilValidate.isNotEmpty(cellWidth)) + if (UtilValidate.isNotEmpty(cellWidth)) widthStr = " width=\"" + cellWidth + "\" "; - + imgStr += widthStr; imgStr += " border=\"0\" />"; return imgStr; Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapper.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapper.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapper.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -45,9 +45,9 @@ * Widget Library - HTML Menu Wrapper class - makes it easy to do the setup and render of a menu */ public class HtmlMenuWrapper { - + public static final String module = HtmlMenuWrapper.class.getName(); - + protected String resourceName; protected String menuName; protected HttpServletRequest request; @@ -58,22 +58,22 @@ protected HtmlMenuWrapper() {} - public HtmlMenuWrapper(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response) + public HtmlMenuWrapper(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response) throws IOException, SAXException, ParserConfigurationException { init(resourceName, menuName, request, response); } - public void init(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response) + public void init(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response) throws IOException, SAXException, ParserConfigurationException { this.resourceName = resourceName; this.menuName = menuName; this.request = request; this.response = response; - + this.modelMenu = MenuFactory.getMenuFromWebappContext(resourceName, menuName, request); this.renderer = getMenuRenderer(); - + this.context = new HashMap<String, Object>(); Map parameterMap = UtilHttp.getParameterMap(request); context.put("parameters", parameterMap); @@ -81,17 +81,17 @@ HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); context.put("userLogin", userLogin); - + //make sure the locale is in the context context.put("locale", UtilHttp.getLocale(request)); - + // if there was an error message, this is an error if (UtilValidate.isNotEmpty((String) request.getAttribute("_ERROR_MESSAGE_"))) { context.put("isError", Boolean.TRUE); } else { context.put("isError", Boolean.FALSE); } - + // if a parameter was passed saying this is an error, it is an error if ("true".equals((String) parameterMap.get("isError"))) { context.put("isError", Boolean.TRUE); @@ -101,7 +101,7 @@ public MenuStringRenderer getMenuRenderer() { return new HtmlMenuRenderer(request, response); } - + public String renderMenuString() throws IOException { HttpServletRequest req = ((HtmlMenuRenderer)renderer).request; ServletContext ctx = (ServletContext) req.getAttribute("servletContext"); @@ -121,17 +121,17 @@ return writer.toString(); } - /** + /** * Tells the menu library whether this is a response to an error or not. * Defaults on initialization according to the presense of an errorMessage - * in the request or if an isError parameter was passed to the page with + * in the request or if an isError parameter was passed to the page with * the value "true". If true then the prefilled values will come from the - * parameters Map instead of the value Map. + * parameters Map instead of the value Map. */ public void setIsError(boolean isError) { this.context.put("isError", Boolean.valueOf(isError)); } - + public boolean getIsError() { Boolean isErrorBoolean = (Boolean) this.context.get("isError"); if (isErrorBoolean == null) { @@ -140,15 +140,15 @@ return isErrorBoolean.booleanValue(); } } - + public void setMenuOverrideName(String menuName) { this.context.put("menuName", menuName); } - + public void putInContext(String name, Object value) { this.context.put(name, value); } - + public void putInContext(String menuItemName, String valueName, Object value) { Map<String, Object> valueMap = UtilGenerics.toMap(context.get(menuItemName)); if (valueMap == null) { @@ -157,11 +157,11 @@ } valueMap.put(valueName, value); } - + public Object getFromContext(String name) { return this.context.get(name); } - + public Object getFromContext(String menuItemName, String valueName) { Map<String, Object> valueMap = UtilGenerics.toMap(context.get(menuItemName)); if (valueMap == null) { @@ -170,7 +170,7 @@ } return valueMap.get(valueName); } - + public ModelMenu getModelMenu() { return modelMenu; } @@ -202,9 +202,9 @@ } public static HtmlMenuWrapper getMenuWrapper(HttpServletRequest request, HttpServletResponse response, HttpSession session, String menuDefFile, String menuName, String menuWrapperClassName ) { - + HtmlMenuWrapper menuWrapper = null; - + String menuSig = menuDefFile + "__" + menuName; if (session != null) { menuWrapper = (HtmlMenuWrapper)session.getAttribute(menuSig); @@ -229,14 +229,14 @@ throw new RuntimeException(e6.getMessage()); } } else { - menuWrapper.setRequest(request); - menuWrapper.setResponse(response); + menuWrapper.setRequest(request); + menuWrapper.setResponse(response); Map parameterMap = UtilHttp.getParameterMap(request); menuWrapper.setParameters( parameterMap); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); menuWrapper.putInContext("userLogin", userLogin); - + } if (session != null) { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapperImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapperImage.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapperImage.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapperImage.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -40,12 +40,12 @@ * Widget Library - HTML Menu Wrapper class - makes it easy to do the setup and render of a menu */ public class HtmlMenuWrapperImage extends HtmlMenuWrapper { - + public static final String module = HtmlMenuWrapperImage.class.getName(); protected HtmlMenuWrapperImage() {} - public HtmlMenuWrapperImage(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response) + public HtmlMenuWrapperImage(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response) throws IOException, SAXException, ParserConfigurationException { super(resourceName, menuName, request, response); } @@ -53,10 +53,10 @@ public MenuStringRenderer getMenuRenderer() { return new HtmlMenuRendererImage(request, response); } - - public void init(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response) + + public void init(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response) throws IOException, SAXException, ParserConfigurationException { - + super.init(resourceName, menuName, request, response); //String pubPt = (String)request.getAttribute("pubPt"); //if (Debug.infoOn()) Debug.logInfo("in init, pubPt:" + pubPt, module); |
Free forum by Nabble | Edit this page |