You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2013/05/28 09:11:39 UTC
svn commit: r1486784 -
/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
Author: adrianc
Date: Tue May 28 07:11:39 2013
New Revision: 1486784
URL: http://svn.apache.org/r1486784
Log:
Clean up code formatting in MacroFormRenderer. No functional change.
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1486784&r1=1486783&r2=1486784&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Tue May 28 07:11:39 2013
@@ -28,9 +28,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.WeakHashMap;
+import java.util.Map.Entry;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -157,7 +157,7 @@ public class MacroFormRenderer implement
if (UtilValidate.isEmpty(value)) {
return value;
}
- StringUtil.SimpleEncoder encoder = (StringUtil.SimpleEncoder)context.get("simpleEncoder");
+ StringUtil.SimpleEncoder encoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder");
if (modelFormField.getEncodeOutput() && encoder != null) {
value = encoder.encode(value);
} else {
@@ -165,6 +165,7 @@ public class MacroFormRenderer implement
}
return value;
}
+
public void renderLabel(Appendable writer, Map<String, Object> context, ModelScreenWidget.Label label) throws IOException {
String labelText = label.getText(context);
if (UtilValidate.isEmpty(labelText)) {
@@ -183,30 +184,24 @@ public class MacroFormRenderer implement
public void renderDisplayField(Appendable writer, Map<String, Object> context, DisplayField displayField) throws IOException {
ModelFormField modelFormField = displayField.getModelFormField();
String idName = modelFormField.getCurrentContainerId(context);
-
String description = displayField.getDescription(context);
String type = displayField.getType();
String imageLocation = displayField.getImageLocation(context);
Integer size = Integer.valueOf("0");
String title = "";
-
if (UtilValidate.isNotEmpty(displayField.getSize())) {
try {
size = Integer.parseInt(displayField.getSize());
- }
- catch(NumberFormatException nfe) {
- Debug.logError(nfe, "Error reading size of a field fieldName=" + displayField.getModelFormField().getFieldName()
- + " FormName= " + displayField.getModelFormField().getModelForm().getName(), module);
+ } catch (NumberFormatException nfe) {
+ Debug.logError(nfe, "Error reading size of a field fieldName=" + displayField.getModelFormField().getFieldName() + " FormName= " + displayField.getModelFormField().getModelForm().getName(), module);
}
}
-
ModelFormField.InPlaceEditor inPlaceEditor = displayField.getInPlaceEditor();
boolean ajaxEnabled = inPlaceEditor != null && this.javaScriptEnabled;
- if (UtilValidate.isNotEmpty(description) && size > 0 && description.length() > size ) {
+ if (UtilValidate.isNotEmpty(description) && size > 0 && description.length() > size) {
title = description;
description = description.substring(0, size - 8) + "..." + description.substring(description.length() - 5);
}
-
StringWriter sr = new StringWriter();
sr.append("<@renderDisplayField ");
sr.append("type=\"");
@@ -222,8 +217,7 @@ public class MacroFormRenderer implement
sr.append("\" class=\"");
sr.append(modelFormField.getWidgetStyle());
sr.append("\" alert=\"");
- sr.append(modelFormField.shouldBeRed(context)? "true": "false");
-
+ sr.append(modelFormField.shouldBeRed(context) ? "true" : "false");
if (ajaxEnabled) {
String url = inPlaceEditor.getUrl(context);
String extraParameter = "{";
@@ -259,22 +253,21 @@ public class MacroFormRenderer implement
inPlaceEditorParams.append(", type: 'textarea'");
inPlaceEditorParams.append(", select: 'true'");
inPlaceEditorParams.append(", onreset: function(){jQuery('#cc_" + idName + "').css('background-color', 'transparent');}");
-
if (UtilValidate.isNotEmpty(inPlaceEditor.getCancelText())) {
- inPlaceEditorParams.append(", cancel: '" +inPlaceEditor.getCancelText()+ "'");
+ inPlaceEditorParams.append(", cancel: '" + inPlaceEditor.getCancelText() + "'");
} else {
inPlaceEditorParams.append(", cancel: 'Cancel'");
}
if (UtilValidate.isNotEmpty(inPlaceEditor.getClickToEditText())) {
- inPlaceEditorParams.append(", tooltip: '" +inPlaceEditor.getClickToEditText()+ "'");
+ inPlaceEditorParams.append(", tooltip: '" + inPlaceEditor.getClickToEditText() + "'");
}
if (UtilValidate.isNotEmpty(inPlaceEditor.getFormClassName())) {
- inPlaceEditorParams.append(", cssclass: '" + inPlaceEditor.getFormClassName()+ "'");
+ inPlaceEditorParams.append(", cssclass: '" + inPlaceEditor.getFormClassName() + "'");
} else {
inPlaceEditorParams.append(", cssclass: 'inplaceeditor-form'");
}
if (UtilValidate.isNotEmpty(inPlaceEditor.getLoadingText())) {
- inPlaceEditorParams.append(", indicator: '" +inPlaceEditor.getLoadingText()+ "'");
+ inPlaceEditorParams.append(", indicator: '" + inPlaceEditor.getLoadingText() + "'");
}
if (UtilValidate.isNotEmpty(inPlaceEditor.getOkControl())) {
inPlaceEditorParams.append(", submit: ");
@@ -289,19 +282,18 @@ public class MacroFormRenderer implement
inPlaceEditorParams.append(", submit: 'OK'");
}
if (UtilValidate.isNotEmpty(inPlaceEditor.getRows())) {
- inPlaceEditorParams.append(", rows: '" +inPlaceEditor.getRows()+ "'");
+ inPlaceEditorParams.append(", rows: '" + inPlaceEditor.getRows() + "'");
}
if (UtilValidate.isNotEmpty(inPlaceEditor.getCols())) {
- inPlaceEditorParams.append(", cols: '" +inPlaceEditor.getCols()+ "'");
+ inPlaceEditorParams.append(", cols: '" + inPlaceEditor.getCols() + "'");
}
inPlaceEditorParams.append("}");
sr.append(inPlaceEditorParams.toString());
}
-
sr.append("\" />");
executeMacro(writer, sr.toString());
if (displayField instanceof DisplayEntityField) {
- makeHyperlinkString(writer,((DisplayEntityField) displayField).getSubHyperlink(),context);
+ makeHyperlinkString(writer, ((DisplayEntityField) displayField).getSubHyperlink(), context);
}
this.appendTooltip(writer, context, modelFormField);
}
@@ -309,16 +301,13 @@ public class MacroFormRenderer implement
public void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField) throws IOException {
this.request.setAttribute("image", hyperlinkField.getImageLocation(context));
ModelFormField modelFormField = hyperlinkField.getModelFormField();
-
String encodedAlternate = encode(hyperlinkField.getAlternate(context), modelFormField, context);
String encodedImageTitle = encode(hyperlinkField.getImageTitle(context), modelFormField, context);
this.request.setAttribute("alternate", encodedAlternate);
this.request.setAttribute("imageTitle", encodedImageTitle);
this.request.setAttribute("descriptionSize", hyperlinkField.getSize());
- makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), hyperlinkField.getTargetType(), hyperlinkField.getTarget(context),
- hyperlinkField.getParameterMap(context), hyperlinkField.getDescription(context), hyperlinkField.getTargetWindow(context), hyperlinkField.getConfirmation(context), modelFormField,
- this.request, this.response, context);
-
+ makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), hyperlinkField.getTargetType(), hyperlinkField.getTarget(context), hyperlinkField.getParameterMap(context), hyperlinkField.getDescription(context), hyperlinkField.getTargetWindow(context),
+ hyperlinkField.getConfirmation(context), modelFormField, this.request, this.response, context);
this.appendTooltip(writer, context, modelFormField);
this.request.removeAttribute("image");
this.request.removeAttribute("descriptionSize");
@@ -336,7 +325,6 @@ public class MacroFormRenderer implement
alert = "true";
}
}
-
String value = modelFormField.getEntry(context, textField.getDefaultValue(context));
String textSize = Integer.toString(textField.getSize());
String maxlength = "";
@@ -347,28 +335,26 @@ public class MacroFormRenderer implement
String action = modelFormField.getAction(context);
String id = modelFormField.getCurrentContainerId(context);
String clientAutocomplete = "false";
-
//check for required field style on single forms
if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
String requiredStyle = modelFormField.getRequiredFieldStyle();
- if (UtilValidate.isEmpty(requiredStyle)) requiredStyle = "required";
- if (UtilValidate.isEmpty(className)) className = requiredStyle;
- else className = requiredStyle + " " + className;
+ if (UtilValidate.isEmpty(requiredStyle))
+ requiredStyle = "required";
+ if (UtilValidate.isEmpty(className))
+ className = requiredStyle;
+ else
+ className = requiredStyle + " " + className;
}
-
List<ModelForm.UpdateArea> updateAreas = modelFormField.getOnChangeUpdateAreas();
boolean ajaxEnabled = updateAreas != null && this.javaScriptEnabled;
if (textField.getClientAutocompleteField() || ajaxEnabled) {
clientAutocomplete = "true";
}
-
if (UtilValidate.isNotEmpty(textField.getMask())) {
mask = textField.getMask();
}
-
String ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context);
boolean disabled = textField.disabled;
-
StringWriter sr = new StringWriter();
sr.append("<@renderTextField ");
sr.append("name=\"");
@@ -395,7 +381,6 @@ public class MacroFormRenderer implement
}
sr.append("\" disabled=");
sr.append(Boolean.toString(disabled));
-
sr.append(" clientAutocomplete=\"");
sr.append(clientAutocomplete);
sr.append("\" ajaxUrl=\"");
@@ -406,10 +391,9 @@ public class MacroFormRenderer implement
sr.append(mask);
sr.append("\" />");
executeMacro(writer, sr.toString());
-
ModelFormField.SubHyperlink subHyperlink = textField.getSubHyperlink();
if (subHyperlink != null && subHyperlink.shouldUse(context)) {
- makeHyperlinkString(writer,subHyperlink,context);
+ makeHyperlinkString(writer, subHyperlink, context);
}
this.addAsterisks(writer, context, modelFormField);
this.appendTooltip(writer, context, modelFormField);
@@ -429,15 +413,16 @@ public class MacroFormRenderer implement
alert = "true";
}
}
-
//check for required field style on single forms
if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
String requiredStyle = modelFormField.getRequiredFieldStyle();
- if (UtilValidate.isEmpty(requiredStyle)) requiredStyle = "required";
- if (UtilValidate.isEmpty(className)) className = requiredStyle;
- else className = requiredStyle + " " + className;
+ if (UtilValidate.isEmpty(requiredStyle))
+ requiredStyle = "required";
+ if (UtilValidate.isEmpty(className))
+ className = requiredStyle;
+ else
+ className = requiredStyle + " " + className;
}
-
String visualEditorEnable = "";
String buttons = "";
if (textareaField.getVisualEditorEnable()) {
@@ -511,12 +496,11 @@ public class MacroFormRenderer implement
try {
step = Integer.valueOf(stepString).intValue();
} catch (IllegalArgumentException e) {
- Debug.logWarning("Inavalid value for step property for field[" + paramName + "] with input-method=\"time-dropdown\" " +
- " Found Value ["+ stepString + "] " + e.getMessage(), module);
+ Debug.logWarning("Inavalid value for step property for field[" + paramName + "] with input-method=\"time-dropdown\" " + " Found Value [" + stepString + "] " + e.getMessage(), module);
}
timeValues.append("[");
- for(int i =0; i<=59;) {
- if(i != 0) {
+ for (int i = 0; i <= 59;) {
+ if (i != 0) {
timeValues.append(", ");
}
timeValues.append(i);
@@ -529,20 +513,16 @@ public class MacroFormRenderer implement
Debug.logWarning("Could not find uiLabelMap in context", module);
}
String localizedInputTitle = "", localizedIconTitle = "";
-
// whether the date field is short form, yyyy-mm-dd
boolean shortDateInput = ("date".equals(dateTimeField.getType()) || useTimeDropDown ? true : false);
-
if (useTimeDropDown) {
name = UtilHttp.makeCompositeParam(paramName, "date");
} else {
name = paramName;
}
-
// the default values for a timestamp
int size = 25;
int maxlength = 30;
-
if (shortDateInput) {
size = maxlength = 10;
if (uiLabelMap != null) {
@@ -558,7 +538,6 @@ public class MacroFormRenderer implement
localizedInputTitle = uiLabelMap.get("CommonFormatDateTime");
}
}
-
String contextValue = null;
// If time-dropdown deactivate encodingOutput for found hour and minutes
boolean memEncodeOutput = modelFormField.getEncodeOutput();
@@ -570,7 +549,6 @@ public class MacroFormRenderer implement
contextValue = modelFormField.getEntry(context, dateTimeField.getDefaultValue(context));
if (useTimeDropDown)
modelFormField.setEncodeOutput(memEncodeOutput);
-
String value = contextValue;
if (UtilValidate.isNotEmpty(value)) {
if (value.length() > maxlength) {
@@ -582,17 +560,16 @@ public class MacroFormRenderer implement
String timeDropdown = dateTimeField.getInputMethod();
String timeDropdownParamName = "";
String classString = "";
- boolean isTwelveHour = false ;
+ boolean isTwelveHour = false;
String timeHourName = "";
int hour2 = 0, hour1 = 0, minutes = 0;
String timeMinutesName = "";
- String amSelected="", pmSelected="", ampmName="";
+ String amSelected = "", pmSelected = "", ampmName = "";
String compositeType = "";
// search for a localized label for the icon
if (uiLabelMap != null) {
localizedIconTitle = uiLabelMap.get("CommonViewCalendar");
}
-
if (!"time".equals(dateTimeField.getType())) {
String tempParamName;
if (useTimeDropDown) {
@@ -603,14 +580,12 @@ public class MacroFormRenderer implement
timeDropdownParamName = tempParamName;
defaultDateTimeString = UtilHttp.encodeBlanks(modelFormField.getEntry(context, defaultDateTimeString));
}
-
// if we have an input method of time-dropdown, then render two
// dropdowns
if (useTimeDropDown) {
className = modelFormField.getWidgetStyle();
classString = (className != null ? className : "");
isTwelveHour = "12".equals(dateTimeField.getClock());
-
// set the Calendar to the default time of the form or now()
Calendar cal = null;
try {
@@ -618,10 +593,8 @@ public class MacroFormRenderer implement
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 ["
- + defaultDateTimeString + "]. The parsing error was: " + e.getMessage(), module);
+ 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);
}
-
timeHourName = UtilHttp.makeCompositeParam(paramName, "hour");
if (cal != null) {
int hour = cal.get(Calendar.HOUR_OF_DAY);
@@ -636,7 +609,7 @@ public class MacroFormRenderer implement
minutes = cal.get(Calendar.MINUTE);
}
timeMinutesName = UtilHttp.makeCompositeParam(paramName, "minutes");
- compositeType = UtilHttp.makeCompositeParam(paramName,"compositeType");
+ compositeType = UtilHttp.makeCompositeParam(paramName, "compositeType");
// if 12 hour clock, write the AM/PM selector
if (isTwelveHour) {
amSelected = ((cal != null && cal.get(Calendar.AM_PM) == Calendar.AM) ? "selected" : "");
@@ -644,15 +617,16 @@ public class MacroFormRenderer implement
ampmName = UtilHttp.makeCompositeParam(paramName, "ampm");
}
}
-
//check for required field style on single forms
if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
String requiredStyle = modelFormField.getRequiredFieldStyle();
- if (UtilValidate.isEmpty(requiredStyle)) requiredStyle = "required";
- if (UtilValidate.isEmpty(className)) className = requiredStyle;
- else className = requiredStyle + " " + className;
+ if (UtilValidate.isEmpty(requiredStyle))
+ requiredStyle = "required";
+ if (UtilValidate.isEmpty(className))
+ className = requiredStyle;
+ else
+ className = requiredStyle + " " + className;
}
-
String mask = dateTimeField.getMask();
if ("Y".equals(mask)) {
if ("date".equals(dateTimeField.getType())) {
@@ -745,10 +719,8 @@ public class MacroFormRenderer implement
if (UtilValidate.isNotEmpty(dropDownField.getTextSize())) {
try {
textSize = Integer.parseInt(dropDownField.getTextSize());
- }
- catch(NumberFormatException nfe) {
- Debug.logError(nfe, "Error reading size of a field fieldName=" + dropDownField.getModelFormField().getFieldName()
- + " FormName= " + dropDownField.getModelFormField().getModelForm().getName(), module);
+ } catch (NumberFormatException nfe) {
+ Debug.logError(nfe, "Error reading size of a field fieldName=" + dropDownField.getModelFormField().getFieldName() + " FormName= " + dropDownField.getModelFormField().getModelForm().getName(), module);
}
if (textSize > 0 && UtilValidate.isNotEmpty(currentValue) && currentValue.length() > textSize) {
currentValue = currentValue.substring(0, textSize - 8) + "..." + currentValue.substring(currentValue.length() - 5);
@@ -759,10 +731,10 @@ public class MacroFormRenderer implement
String alert = "false";
String name = modelFormField.getParameterName(context);
String id = modelFormField.getCurrentContainerId(context);
- String multiple = dropDownField.isAllowMultiple()? "multiple": "";
+ String multiple = dropDownField.isAllowMultiple() ? "multiple" : "";
String otherFieldName = "";
String formName = modelForm.getName();
- String size = dropDownField.getSize();
+ String size = dropDownField.getSize();
String dDFCurrent = dropDownField.getCurrent();
String firstInList = "";
String explicitDescription = "";
@@ -775,15 +747,16 @@ public class MacroFormRenderer implement
alert = "true";
}
}
-
//check for required field style on single forms
if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
String requiredStyle = modelFormField.getRequiredFieldStyle();
- if (UtilValidate.isEmpty(requiredStyle)) requiredStyle = "required";
- if (UtilValidate.isEmpty(className)) className = requiredStyle;
- else className = requiredStyle + " " + className;
+ if (UtilValidate.isEmpty(requiredStyle))
+ requiredStyle = "required";
+ if (UtilValidate.isEmpty(className))
+ className = requiredStyle;
+ else
+ className = requiredStyle + " " + className;
}
-
String currentDescription = null;
if (UtilValidate.isNotEmpty(currentValue)) {
for (ModelFormField.OptionValue optionValue : allOptionValues) {
@@ -793,7 +766,6 @@ public class MacroFormRenderer implement
}
}
}
-
int otherFieldSize = dropDownField.getOtherFieldSize();
if (otherFieldSize > 0) {
otherFieldName = dropDownField.getParameterNameOther(context);
@@ -806,7 +778,6 @@ public class MacroFormRenderer implement
if (UtilValidate.isEmpty(explicitDescription)) {
explicitDescription = (ModelFormField.FieldInfoWithOptions.getDescriptionForOptionKey(currentValue, allOptionValues));
}
-
if (textSize > 0 && UtilValidate.isNotEmpty(explicitDescription) && explicitDescription.length() > textSize) {
explicitDescription = explicitDescription.substring(0, textSize - 8) + "..." + explicitDescription.substring(explicitDescription.length() - 5);
}
@@ -815,14 +786,12 @@ public class MacroFormRenderer implement
if (dropDownField.isAllowEmpty()) {
allowEmpty = "Y";
}
-
List<String> currentValueList = null;
if (UtilValidate.isNotEmpty(currentValue) && dropDownField.isAllowMultiple()) {
// If currentValue is Array, it will start with [
if (currentValue.startsWith("[")) {
currentValueList = StringUtil.toList(currentValue);
- }
- else {
+ } else {
currentValueList = UtilMisc.toList(currentValue);
}
}
@@ -840,7 +809,7 @@ public class MacroFormRenderer implement
options.append("'");
options.append(",'description':'");
String description = optionValue.getDescription();
- if (textSize > 0 && description.length() > textSize ) {
+ if (textSize > 0 && description.length() > textSize) {
description = description.substring(0, textSize - 8) + "..." + description.substring(description.length() - 5);
}
options.append(encode(description, modelFormField, context));
@@ -859,8 +828,7 @@ public class MacroFormRenderer implement
if (ajaxEnabled) {
count++;
ajaxOptions.append(optionValue.getKey()).append(": ");
- ajaxOptions.append(" '").append(optionValue.getDescription())
- .append("'");
+ ajaxOptions.append(" '").append(optionValue.getDescription()).append("'");
if (count != allOptionValues.size()) {
ajaxOptions.append(", ");
}
@@ -898,7 +866,6 @@ public class MacroFormRenderer implement
ignoreCase = autoComplete.getIgnoreCase();
fullSearch = autoComplete.getFullSearch();
}
-
StringWriter sr = new StringWriter();
sr.append("<@renderDropDownField ");
sr.append("name=\"");
@@ -969,8 +936,7 @@ public class MacroFormRenderer implement
sr.append(fullSearch);
sr.append("\" />");
executeMacro(writer, sr.toString());
- ModelFormField.SubHyperlink subHyperlink = dropDownField
- .getSubHyperlink();
+ ModelFormField.SubHyperlink subHyperlink = dropDownField.getSubHyperlink();
if (subHyperlink != null && subHyperlink.shouldUse(context)) {
makeHyperlinkString(writer, subHyperlink, context);
}
@@ -995,11 +961,10 @@ public class MacroFormRenderer implement
alert = "true";
}
}
-
List<ModelFormField.OptionValue> allOptionValues = checkField.getAllOptionValues(context, WidgetWorker.getDelegator(context));
items.append("[");
for (ModelFormField.OptionValue optionValue : allOptionValues) {
- if (items.length() >1) {
+ if (items.length() > 1) {
items.append(",");
}
items.append("{'value':'");
@@ -1008,7 +973,6 @@ public class MacroFormRenderer implement
items.append("'}");
}
items.append("]");
-
StringWriter sr = new StringWriter();
sr.append("<@renderCheckField ");
sr.append("items=");
@@ -1020,7 +984,7 @@ public class MacroFormRenderer implement
sr.append("\" id=\"");
sr.append(id);
sr.append("\" allChecked=");
- sr.append((allChecked != null? Boolean.toString(allChecked): "\"\""));
+ sr.append((allChecked != null ? Boolean.toString(allChecked) : "\"\""));
sr.append(" currentValue=\"");
sr.append(currentValue);
sr.append("\" name=\"");
@@ -1035,7 +999,6 @@ public class MacroFormRenderer implement
}
sr.append("\" />");
executeMacro(writer, sr.toString());
-
this.appendTooltip(writer, context, modelFormField);
}
@@ -1056,11 +1019,10 @@ public class MacroFormRenderer implement
alert = "true";
}
}
-
String noCurrentSelectedKey = radioField.getNoCurrentSelectedKey(context);
items.append("[");
for (ModelFormField.OptionValue optionValue : allOptionValues) {
- if (items.length() >1) {
+ if (items.length() > 1) {
items.append(",");
}
items.append("{'key':'");
@@ -1069,7 +1031,6 @@ public class MacroFormRenderer implement
items.append("'}");
}
items.append("]");
-
StringWriter sr = new StringWriter();
sr.append("<@renderRadioField ");
sr.append("items=");
@@ -1094,7 +1055,6 @@ public class MacroFormRenderer implement
}
sr.append("\" />");
executeMacro(writer, sr.toString());
-
this.appendTooltip(writer, context, modelFormField);
}
@@ -1105,7 +1065,7 @@ public class MacroFormRenderer implement
String action = modelFormField.getAction(context);
String title = modelFormField.getTitle(context);
String name = modelFormField.getParameterName(context);
- String buttonType = submitField.getButtonType();
+ String buttonType = submitField.getButtonType();
String formName = modelForm.getCurrentFormName(context);
String imgSrc = submitField.getImageLocation(context);
String confirmation = submitField.getConfirmation(context);
@@ -1117,7 +1077,6 @@ public class MacroFormRenderer implement
alert = "true";
}
}
-
String formId = modelForm.getCurrentContainerId(context);
List<ModelForm.UpdateArea> updateAreas = modelForm.getOnSubmitUpdateAreas();
// This is here for backwards compatibility. Use on-event-update-area
@@ -1129,7 +1088,6 @@ public class MacroFormRenderer implement
}
updateAreas.add(new ModelForm.UpdateArea("submit", formId, backgroundSubmitRefreshTarget));
}
-
boolean ajaxEnabled = (updateAreas != null || UtilValidate.isNotEmpty(backgroundSubmitRefreshTarget)) && this.javaScriptEnabled;
String ajaxUrl = "";
if (ajaxEnabled) {
@@ -1164,7 +1122,7 @@ public class MacroFormRenderer implement
sr.append(formId);
}
sr.append("\" confirmation =\"");
- sr.append(confirmation );
+ sr.append(confirmation);
sr.append("\" ajaxUrl=\"");
if (ajaxEnabled) {
sr.append(ajaxUrl);
@@ -1186,7 +1144,6 @@ public class MacroFormRenderer implement
}
}
String title = modelFormField.getTitle(context);
-
StringWriter sr = new StringWriter();
sr.append("<@renderResetField ");
sr.append(" className=\"");
@@ -1199,7 +1156,6 @@ public class MacroFormRenderer implement
sr.append(title);
sr.append("\" />");
executeMacro(writer, sr.toString());
-
this.appendTooltip(writer, context, modelFormField);
}
@@ -1214,7 +1170,6 @@ public class MacroFormRenderer implement
String action = modelFormField.getAction(context);
String event = modelFormField.getEvent();
String id = modelFormField.getCurrentContainerId(context);
-
StringWriter sr = new StringWriter();
sr.append("<@renderHiddenField ");
sr.append(" name=\"");
@@ -1236,7 +1191,7 @@ public class MacroFormRenderer implement
}
public void renderIgnoredField(Appendable writer, Map<String, Object> context, IgnoredField ignoredField) {
- // do nothing, it's an ignored field; could add a comment or something if we wanted to
+ // do nothing, it's an ignored field; could add a comment or something if we wanted to
}
public void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException {
@@ -1244,7 +1199,6 @@ public class MacroFormRenderer implement
String titleText = UtilHttp.encodeAmpersands(tempTitleText);
String style = modelFormField.getTitleStyle();
String id = modelFormField.getCurrentContainerId(context);
-
StringBuilder sb = new StringBuilder();
if (UtilValidate.isNotEmpty(titleText)) {
if (" ".equals(titleText)) {
@@ -1261,11 +1215,10 @@ public class MacroFormRenderer implement
targetBuffer.append(fullTarget);
String targetType = HyperlinkField.DEFAULT_TARGET_TYPE;
if (UtilValidate.isNotEmpty(targetBuffer.toString()) && targetBuffer.toString().toLowerCase().startsWith("javascript:")) {
- targetType="plain";
+ targetType = "plain";
}
StringWriter sr = new StringWriter();
makeHyperlinkString(sr, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), null, titleText, "", modelFormField, this.request, this.response, context, "");
-
String title = sr.toString().replace("\"", "\'");
sr = new StringWriter();
sr.append("<@renderHyperlinkTitle ");
@@ -1291,7 +1244,6 @@ public class MacroFormRenderer implement
}
}
}
-
if (!sb.toString().isEmpty()) {
//check for required field style on single forms
if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
@@ -1300,20 +1252,18 @@ public class MacroFormRenderer implement
style = requiredStyle;
}
}
-
StringWriter sr = new StringWriter();
sr.append("<@renderFieldTitle ");
sr.append(" style=\"");
sr.append(style);
-
String displayHelpText = UtilProperties.getPropertyValue("widget.properties", "widget.form.displayhelpText");
if ("Y".equals(displayHelpText)) {
Delegator delegator = WidgetWorker.getDelegator(context);
- Locale locale = (Locale)context.get("locale");
+ Locale locale = (Locale) context.get("locale");
String entityName = modelFormField.getEntityName();
String fieldName = modelFormField.getFieldName();
String helpText = UtilHelpText.getEntityFieldDescription(entityName, fieldName, delegator, locale);
-
+
sr.append("\" fieldHelpText=\"");
sr.append(FreeMarkerWorker.encodeDoubleQuotes(helpText));
}
@@ -1345,8 +1295,8 @@ public class MacroFormRenderer implement
}
String formType = modelForm.getType();
String targetWindow = modelForm.getTargetWindow(context);
- String containerId = modelForm.getCurrentContainerId(context);
- String containerStyle = modelForm.getContainerStyle();
+ String containerId = modelForm.getCurrentContainerId(context);
+ String containerStyle = modelForm.getContainerStyle();
String autocomplete = "";
String name = modelForm.getCurrentFormName(context);
String viewIndexField = modelForm.getMultiPaginateIndexField(context);
@@ -1419,29 +1369,22 @@ public class MacroFormRenderer implement
while (submitFields.hasNext()) {
ModelFormField submitField = submitFields.next();
if (submitField != null && submitField.shouldUse(context)) {
-
// 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
// 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.
-
// this.renderFormatItemRowCellOpen(writer, context, modelForm, submitField);
// this.renderFormatItemRowCellClose(writer, context, modelForm, submitField);
-
// this.renderFormatItemRowCellOpen(writer, context, modelForm, submitField);
-
submitField.renderFieldString(writer, context, this);
-
// this.renderFormatItemRowCellClose(writer, context, modelForm, submitField);
-
}
}
StringWriter sr = new StringWriter();
sr.append("<@renderMultiFormClose />");
executeMacro(writer, sr.toString());
-
// 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;
@@ -1449,7 +1392,6 @@ public class MacroFormRenderer implement
writer.append(postMultiFormWriter.toString());
appendWhitespace(writer);
}
-
renderEndingBoundaryComment(writer, "Form Widget - Form Element (Multi)", modelForm);
}
@@ -1464,9 +1406,7 @@ public class MacroFormRenderer implement
}
String queryString = UtilHttp.urlEncodeArgs(inputFields);
context.put("_QBESTRING_", queryString);
-
renderBeginningBoundaryComment(writer, "Form Widget", modelForm);
-
if (this.renderPagination) {
this.renderNextPrev(writer, context, modelForm);
}
@@ -1493,7 +1433,6 @@ public class MacroFormRenderer implement
}
columnStyleList = StringUtil.quoteStrList(columnStyleList);
String columnStyleListString = StringUtil.join(columnStyleList, ", ");
-
StringWriter sr = new StringWriter();
sr.append("<@renderFormatListWrapperOpen ");
sr.append(" formName=\"");
@@ -1586,11 +1525,11 @@ public class MacroFormRenderer implement
}
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");
String altRowStyles = "";
String evenRowStyle = "";
String oddRowStyle = "";
- if (itemIndex!=null) {
+ if (itemIndex != null) {
altRowStyles = modelForm.getStyleAltRowStyle(context);
if (itemIndex.intValue() % 2 == 0) {
evenRowStyle = modelForm.getEvenRowStyle();
@@ -1724,7 +1663,6 @@ public class MacroFormRenderer implement
sr.append(areaStyle);
sr.append("\" />");
executeMacro(writer, sr.toString());
-
}
public void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException {
@@ -1741,7 +1679,6 @@ public class MacroFormRenderer implement
public void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField) throws IOException {
ModelFormField modelFormField = textFindField.getModelFormField();
-
String defaultOption = textFindField.getDefaultOption();
String className = "";
String alert = "false";
@@ -1760,7 +1697,7 @@ public class MacroFormRenderer implement
alert = "true";
}
}
- Locale locale = (Locale)context.get("locale");
+ Locale locale = (Locale) context.get("locale");
if (!textFindField.getHideOptions()) {
opEquals = UtilProperties.getMessage("conditional", "equals", locale);
opBeginsWith = UtilProperties.getMessage("conditional", "begins_with", locale);
@@ -1768,16 +1705,13 @@ public class MacroFormRenderer implement
opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
opNotEqual = UtilProperties.getMessage("conditional", "not_equal", locale);
}
-
String value = modelFormField.getEntry(context, textFindField.getDefaultValue(context));
if (value == null) {
value = "";
}
-
if (textFindField.getMaxlength() != null) {
maxlength = textFindField.getMaxlength().toString();
}
-
if (!textFindField.getClientAutocompleteField()) {
autocomplete = "off";
}
@@ -1785,7 +1719,6 @@ public class MacroFormRenderer implement
if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
titleStyle = modelFormField.getTitleStyle();
}
-
String ignoreCase = UtilProperties.getMessage("conditional", "ignore_case", locale);
boolean ignCase = textFindField.getIgnoreCase();
boolean hideIgnoreCase = textFindField.getHideIgnoreCase();
@@ -1827,20 +1760,18 @@ public class MacroFormRenderer implement
sr.append(ignoreCase);
sr.append("\" />");
executeMacro(writer, sr.toString());
-
this.appendTooltip(writer, context, modelFormField);
}
public void renderRangeFindField(Appendable writer, Map<String, Object> context, RangeFindField rangeFindField) throws IOException {
ModelFormField modelFormField = rangeFindField.getModelFormField();
- Locale locale = (Locale)context.get("locale");
+ Locale locale = (Locale) context.get("locale");
String opEquals = UtilProperties.getMessage("conditional", "equals", locale);
String opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale);
String opGreaterThanEquals = UtilProperties.getMessage("conditional", "greater_than_equals", locale);
String opLessThan = UtilProperties.getMessage("conditional", "less_than", locale);
String opLessThanEquals = UtilProperties.getMessage("conditional", "less_than_equals", locale);
//String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
-
String className = "";
String alert = "false";
if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
@@ -1866,15 +1797,12 @@ public class MacroFormRenderer implement
if (titleStyle == null) {
titleStyle = "";
}
-
String defaultOptionFrom = rangeFindField.getDefaultOptionFrom();
-
String value2 = modelFormField.getEntry(context);
if (value2 == null) {
value2 = "";
}
String defaultOptionThru = rangeFindField.getDefaultOptionThru();
-
StringWriter sr = new StringWriter();
sr.append("<@renderRangeFindField ");
sr.append(" className=\"");
@@ -1913,14 +1841,12 @@ public class MacroFormRenderer implement
sr.append(defaultOptionThru);
sr.append("\" />");
executeMacro(writer, sr.toString());
-
this.appendTooltip(writer, context, modelFormField);
}
public void renderDateFindField(Appendable writer, Map<String, Object> context, DateFindField dateFindField) throws IOException {
ModelFormField modelFormField = dateFindField.getModelFormField();
-
- Locale locale = (Locale)context.get("locale");
+ Locale locale = (Locale) context.get("locale");
String opEquals = UtilProperties.getMessage("conditional", "equals", locale);
String opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale);
String opSameDay = UtilProperties.getMessage("conditional", "same_day", locale);
@@ -1929,13 +1855,11 @@ public class MacroFormRenderer implement
String opUpToDay = UtilProperties.getMessage("conditional", "up_to_day", locale);
String opUpThruDay = UtilProperties.getMessage("conditional", "up_thru_day", locale);
String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
-
Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
if (uiLabelMap == null) {
Debug.logWarning("Could not find uiLabelMap in context", module);
}
String localizedInputTitle = "", localizedIconTitle = "";
-
String className = "";
String alert = "false";
if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
@@ -1945,11 +1869,10 @@ public class MacroFormRenderer implement
}
}
String name = modelFormField.getParameterName(context);
-
// the default values for a timestamp
int size = 25;
int maxlength = 30;
- String dateType = dateFindField.getType();
+ String dateType = dateFindField.getType();
if ("date".equals(dateType)) {
size = maxlength = 10;
if (uiLabelMap != null) {
@@ -1965,12 +1888,10 @@ public class MacroFormRenderer implement
localizedInputTitle = uiLabelMap.get("CommonFormatDateTime");
}
}
-
String value = modelFormField.getEntry(context, dateFindField.getDefaultValue(context));
if (value == null) {
value = "";
}
-
// search for a localized label for the icon
if (uiLabelMap != null) {
localizedIconTitle = uiLabelMap.get("CommonViewCalendar");
@@ -1984,7 +1905,6 @@ public class MacroFormRenderer implement
defaultDateTimeString = UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context)));
this.appendContentUrl(imgSrc, "/images/cal.gif");
}
-
String defaultOptionFrom = dateFindField.getDefaultOptionFrom();
String defaultOptionThru = dateFindField.getDefaultOptionThru();
String value2 = modelFormField.getEntry(context);
@@ -1995,7 +1915,6 @@ public class MacroFormRenderer implement
if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
titleStyle = modelFormField.getTitleStyle();
}
-
StringWriter sr = new StringWriter();
sr.append("<@renderDateFindField ");
sr.append(" className=\"");
@@ -2048,7 +1967,6 @@ public class MacroFormRenderer implement
sr.append(opIsEmpty);
sr.append("\" />");
executeMacro(writer, sr.toString());
-
this.appendTooltip(writer, context, modelFormField);
}
@@ -2063,15 +1981,16 @@ public class MacroFormRenderer implement
alert = "true";
}
}
-
//check for required field style on single forms
if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) {
String requiredStyle = modelFormField.getRequiredFieldStyle();
- if (UtilValidate.isEmpty(requiredStyle)) requiredStyle = "required";
- if (UtilValidate.isEmpty(className)) className = requiredStyle;
- else className = requiredStyle + " " + className;
+ if (UtilValidate.isEmpty(requiredStyle))
+ requiredStyle = "required";
+ if (UtilValidate.isEmpty(className))
+ className = requiredStyle;
+ else
+ className = requiredStyle + " " + className;
}
-
String name = modelFormField.getParameterName(context);
String value = modelFormField.getEntry(context, lookupField.getDefaultValue(context));
if (value == null) {
@@ -2080,9 +1999,7 @@ public class MacroFormRenderer implement
String size = Integer.toString(lookupField.getSize());
Integer maxlength = lookupField.getMaxlength();
String id = modelFormField.getCurrentContainerId(context);
-
List<ModelForm.UpdateArea> updateAreas = modelFormField.getOnChangeUpdateAreas();
-
//add default ajax auto completer to all lookup fields
if (UtilValidate.isEmpty(updateAreas) && UtilValidate.isNotEmpty(lookupFieldFormName)) {
String autoCompleterTarget = null;
@@ -2095,17 +2012,14 @@ public class MacroFormRenderer implement
updateAreas = FastList.newInstance();
updateAreas.add(new ModelForm.UpdateArea("change", id, autoCompleterTarget));
}
-
boolean ajaxEnabled = updateAreas != null && this.javaScriptEnabled;
String autocomplete = "";
if (!lookupField.getClientAutocompleteField() || !ajaxEnabled) {
autocomplete = "off";
}
-
String event = modelFormField.getEvent();
String action = modelFormField.getAction(context);
boolean readonly = lookupField.readonly;
-
// add lookup pop-up button
String descriptionFieldName = lookupField.getDescriptionFieldName();
String formName = modelFormField.getModelForm().getCurrentFormName(context);
@@ -2114,8 +2028,8 @@ public class MacroFormRenderer implement
// FIXME: refactor using the StringUtils methods
List<String> targetParameterList = lookupField.getTargetParameterList();
targetParameterIter.append("[");
- for (String targetParameter: targetParameterList) {
- if (targetParameterIter.length()>1) {
+ for (String targetParameter : targetParameterList) {
+ if (targetParameterIter.length() > 1) {
targetParameterIter.append(",");
}
targetParameterIter.append("'");
@@ -2124,49 +2038,39 @@ public class MacroFormRenderer implement
}
targetParameterIter.append("]");
this.appendContentUrl(imgSrc, "/images/fieldlookup.gif");
-
String ajaxUrl = "";
-
if (ajaxEnabled) {
ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context);
}
-
String lookupPresentation = lookupField.getLookupPresentation();
- if(UtilValidate.isEmpty(lookupPresentation)){
+ if (UtilValidate.isEmpty(lookupPresentation)) {
lookupPresentation = "";
}
-
String lookupHeight = lookupField.getLookupHeight();
- if(UtilValidate.isEmpty(lookupHeight)){
+ if (UtilValidate.isEmpty(lookupHeight)) {
lookupHeight = "";
}
-
String lookupWidth = lookupField.getLookupWidth();
- if(UtilValidate.isEmpty(lookupWidth)){
+ if (UtilValidate.isEmpty(lookupWidth)) {
lookupWidth = "";
}
-
String lookupPosition = lookupField.getLookupPosition();
- if(UtilValidate.isEmpty(lookupPosition)){
+ if (UtilValidate.isEmpty(lookupPosition)) {
lookupPosition = "";
}
-
String fadeBackground = lookupField.getFadeBackground();
- if (UtilValidate.isEmpty(fadeBackground)){
+ if (UtilValidate.isEmpty(fadeBackground)) {
fadeBackground = "false";
}
Boolean isInitiallyCollapsed = lookupField.getInitiallyCollapsed();
-
String clearText = "";
- Map<String, Object> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
+ Map<String, Object> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
if (uiLabelMap != null) {
- clearText = (String) uiLabelMap.get("CommonClear");
+ clearText = (String) uiLabelMap.get("CommonClear");
} else {
Debug.logWarning("Could not find uiLabelMap in context", module);
}
-
boolean showDescription = "Y".equals(UtilProperties.getPropertyValue("widget", "widget.lookup.showDescription", "N"));
-
// lastViewName, used by lookup to remember the real last view name
String lastViewName = request.getParameter("_LAST_VIEW_NAME_"); // Try to get it from parameters firstly
if (UtilValidate.isEmpty(lastViewName)) { // get from session
@@ -2188,7 +2092,7 @@ public class MacroFormRenderer implement
sr.append("\" size=\"");
sr.append(size);
sr.append("\" maxlength=\"");
- sr.append((maxlength != null? Integer.toString(maxlength): ""));
+ sr.append((maxlength != null ? Integer.toString(maxlength) : ""));
sr.append("\" id=\"");
sr.append(id);
sr.append("\" event=\"");
@@ -2201,7 +2105,6 @@ public class MacroFormRenderer implement
}
sr.append("\" readonly=");
sr.append(Boolean.toString(readonly));
-
sr.append(" autocomplete=\"");
sr.append(autocomplete);
sr.append("\" descriptionFieldName=\"");
@@ -2228,7 +2131,7 @@ public class MacroFormRenderer implement
sr.append(lookupPosition);
sr.append("\" fadeBackground=\"");
sr.append(fadeBackground);
- sr.append("\" clearText=\"");
+ sr.append("\" clearText=\"");
sr.append(clearText);
sr.append("\" showDescription=\"");
sr.append(Boolean.toString(showDescription));
@@ -2238,9 +2141,7 @@ public class MacroFormRenderer implement
sr.append(lastViewName);
sr.append("\" />");
executeMacro(writer, sr.toString());
-
this.addAsterisks(writer, context, modelFormField);
-
this.makeHyperlinkString(writer, lookupField.getSubHyperlink(), context);
this.appendTooltip(writer, context, modelFormField);
}
@@ -2273,20 +2174,16 @@ public class MacroFormRenderer implement
Debug.logWarning("Cannot paginate because TargetService is empty for the form: " + modelForm.getName(), module);
return;
}
-
// get the parameterized pagination index and size fields
int paginatorNumber = WidgetWorker.getPaginatorNumber(context);
String viewIndexParam = modelForm.getMultiPaginateIndexField(context);
String viewSizeParam = modelForm.getMultiPaginateSizeField(context);
-
int viewIndex = modelForm.getViewIndex(context);
int viewSize = modelForm.getViewSize(context);
int listSize = modelForm.getListSize(context);
-
int lowIndex = modelForm.getLowIndex(context);
int highIndex = modelForm.getHighIndex(context);
int actualPageSize = modelForm.getActualPageSize(context);
-
// needed for the "Page" and "rows" labels
Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
String pageLabel = "";
@@ -2298,36 +2195,31 @@ public class MacroFormRenderer implement
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"
- if (viewIndexParam.equals("viewIndex" + "_" + paginatorNumber)) viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber;
- if (viewSizeParam.equals("viewSize" + "_" + paginatorNumber)) viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber;
-
+ if (viewIndexParam.equals("viewIndex" + "_" + paginatorNumber))
+ viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber;
+ if (viewSizeParam.equals("viewSize" + "_" + paginatorNumber))
+ viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber;
String str = (String) context.get("_QBESTRING_");
-
// strip legacy viewIndex/viewSize params from the query string
String queryString = UtilHttp.stripViewParamsFromQueryString(str, "" + paginatorNumber);
-
// strip parameterized index/size params from the query string
HashSet<String> paramNames = new HashSet<String>();
paramNames.add(viewIndexParam);
paramNames.add(viewSizeParam);
queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames);
-
String anchor = "";
String paginateAnchor = modelForm.getPaginateTargetAnchor();
- if (UtilValidate.isNotEmpty(paginateAnchor)) anchor = "#" + paginateAnchor;
-
+ if (UtilValidate.isNotEmpty(paginateAnchor))
+ anchor = "#" + paginateAnchor;
// Create separate url path String and request parameters String,
// add viewIndex/viewSize parameters to request parameter String
String urlPath = UtilHttp.removeQueryStringFromTarget(targetService);
String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService);
String prepLinkSizeText;
-
if (UtilValidate.isNotEmpty(queryString)) {
queryString = UtilHttp.encodeAmpersands(queryString);
}
-
if (prepLinkText == null) {
prepLinkText = "";
}
@@ -2369,7 +2261,6 @@ public class MacroFormRenderer implement
String paginateLastLabel = modelForm.getPaginateLastLabel(context);
String lastUrl = "";
String ajaxLastUrl = "";
-
if (viewIndex > 0) {
if (ajaxEnabled) {
ajaxFirstUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + 0 + anchor, context);
@@ -2398,7 +2289,6 @@ public class MacroFormRenderer implement
selectUrl = rh.makeLink(this.request, this.response, urlPath + linkText);
}
}
-
// Next button
if (highIndex < listSize) {
if (ajaxEnabled) {
@@ -2408,7 +2298,6 @@ public class MacroFormRenderer implement
nextUrl = rh.makeLink(this.request, this.response, urlPath + linkText);
}
}
-
// Last button
if (highIndex < listSize) {
if (ajaxEnabled) {
@@ -2418,7 +2307,6 @@ public class MacroFormRenderer implement
lastUrl = rh.makeLink(this.request, this.response, urlPath + linkText);
}
}
-
// Page size select dropdown
if (listSize > 0 && this.javaScriptEnabled) {
if (ajaxEnabled) {
@@ -2431,7 +2319,6 @@ public class MacroFormRenderer implement
selectSizeUrl = rh.makeLink(this.request, this.response, urlPath + linkText);
}
}
-
StringWriter sr = new StringWriter();
sr.append("<@renderNextPrev ");
sr.append(" paginateStyle=\"");
@@ -2520,15 +2407,12 @@ public class MacroFormRenderer implement
if (UtilValidate.isEmpty(value)) {
value = "";
}
-
if (textField.getMaxlength() != null) {
maxlength = textField.getMaxlength().toString();
}
-
if (!textField.getClientAutocompleteField()) {
autocomplete = "off";
}
-
StringWriter sr = new StringWriter();
sr.append("<@renderFileField ");
sr.append(" className=\"");
@@ -2547,15 +2431,12 @@ public class MacroFormRenderer implement
sr.append(autocomplete);
sr.append("\" />");
executeMacro(writer, sr.toString());
-
this.makeHyperlinkString(writer, textField.getSubHyperlink(), context);
-
this.appendTooltip(writer, context, modelFormField);
}
public void renderPasswordField(Appendable writer, Map<String, Object> context, PasswordField passwordField) throws IOException {
ModelFormField modelFormField = passwordField.getModelFormField();
-
String className = "";
String alert = "false";
String name = modelFormField.getParameterName(context);
@@ -2569,23 +2450,19 @@ public class MacroFormRenderer implement
alert = "true";
}
}
-
String value = modelFormField.getEntry(context, passwordField.getDefaultValue(context));
if (value == null) {
value = "";
}
-
if (passwordField.getMaxlength() != null) {
maxlength = passwordField.getMaxlength().toString();
}
if (id == null) {
id = "";
}
-
if (!passwordField.getClientAutocompleteField()) {
autocomplete = "off";
}
-
StringWriter sr = new StringWriter();
sr.append("<@renderPasswordField ");
sr.append(" className=\"");
@@ -2606,11 +2483,8 @@ public class MacroFormRenderer implement
sr.append(autocomplete);
sr.append("\" />");
executeMacro(writer, sr.toString());
-
this.addAsterisks(writer, context, modelFormField);
-
this.makeHyperlinkString(writer, passwordField.getSubHyperlink(), context);
-
this.appendTooltip(writer, context, modelFormField);
}
@@ -2620,15 +2494,12 @@ public class MacroFormRenderer implement
String description = imageField.getDescription(context);
String alternate = imageField.getAlternate(context);
String style = imageField.getStyle(context);
-
- if(UtilValidate.isEmpty(description)){
+ if (UtilValidate.isEmpty(description)) {
description = imageField.getModelFormField().getTitle(context);
}
-
- if(UtilValidate.isEmpty(alternate)){
+ if (UtilValidate.isEmpty(alternate)) {
alternate = description;
}
-
if (UtilValidate.isNotEmpty(value)) {
if (!value.startsWith("http")) {
StringBuilder buffer = new StringBuilder();
@@ -2639,10 +2510,8 @@ public class MacroFormRenderer implement
} else if (value == null) {
value = "";
}
-
String event = modelFormField.getEvent();
String action = modelFormField.getAction(context);
-
StringWriter sr = new StringWriter();
sr.append("<@renderImageField ");
sr.append(" value=\"");
@@ -2654,13 +2523,12 @@ public class MacroFormRenderer implement
sr.append("\" style=\"");
sr.append(style);
sr.append("\" event=\"");
- sr.append(event==null?"":event);
+ sr.append(event == null ? "" : event);
sr.append("\" action=\"");
- sr.append(action==null?"":action);
+ sr.append(action == null ? "" : action);
sr.append("\" />");
executeMacro(writer, sr.toString());
this.makeHyperlinkString(writer, imageField.getSubHyperlink(), context);
-
this.appendTooltip(writer, context, modelFormField);
}
@@ -2674,7 +2542,6 @@ public class MacroFormRenderer implement
Boolean collapsible = fieldGroup.collapsible();
String expandToolTip = "";
String collapseToolTip = "";
-
if (UtilValidate.isNotEmpty(style) || UtilValidate.isNotEmpty(id) || UtilValidate.isNotEmpty(title)) {
if (fieldGroup.collapsible()) {
Map<String, Object> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
@@ -2735,25 +2602,23 @@ public class MacroFormRenderer implement
public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException {
String style = banner.getStyle(context);
String leftStyle = banner.getLeftTextStyle(context);
- if (UtilValidate.isEmpty(leftStyle)) leftStyle = style;
+ if (UtilValidate.isEmpty(leftStyle))
+ leftStyle = style;
String rightStyle = banner.getRightTextStyle(context);
- if (UtilValidate.isEmpty(rightStyle)) rightStyle = style;
-
+ if (UtilValidate.isEmpty(rightStyle))
+ rightStyle = style;
String leftText = banner.getLeftText(context);
if (leftText == null) {
leftText = "";
}
-
String text = banner.getText(context);
if (text == null) {
text = "";
}
-
String rightText = banner.getRightText(context);
if (rightText == null) {
rightText = "";
}
-
StringWriter sr = new StringWriter();
sr.append("<@renderBanner ");
sr.append(" style=\"");
@@ -2772,7 +2637,6 @@ public class MacroFormRenderer implement
executeMacro(writer, sr.toString());
}
-
/**
* Renders the beginning boundary comment string.
* @param writer The writer to write to
@@ -2832,17 +2696,14 @@ public class MacroFormRenderer implement
Debug.logWarning("Cannot sort because TargetService is empty for the form: " + modelForm.getName(), module);
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)) {
columnField = modelFormField.getFieldName();
}
-
// switch beetween asc/desc order
String newSortField = columnField;
if (UtilValidate.isNotEmpty(oldSortField)) {
@@ -2854,18 +2715,15 @@ public class MacroFormRenderer implement
sortFieldStyle = modelFormField.getSortFieldStyleAsc();
}
}
-
// strip sortField param from the query string
HashSet<String> paramName = new HashSet<String>();
paramName.add("sortField");
String queryString = UtilHttp.stripNamedParamsFromQueryString(str, paramName);
String urlPath = UtilHttp.removeQueryStringFromTarget(targetService);
String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService);
-
if (UtilValidate.isNotEmpty(queryString)) {
queryString = UtilHttp.encodeAmpersands(queryString);
}
-
if (prepLinkText == null) {
prepLinkText = "";
}
@@ -2888,7 +2746,6 @@ public class MacroFormRenderer implement
} else {
linkUrl = rh.makeLink(this.request, this.response, urlPath + prepLinkText);
}
-
StringWriter sr = new StringWriter();
sr.append("<@renderSortField ");
sr.append(" style=\"");
@@ -2903,6 +2760,7 @@ public class MacroFormRenderer implement
executeMacro(writer, sr.toString());
}
+
/** Create an ajaxXxxx JavaScript CSV string from a list of UpdateArea objects. See
* <code>selectall.js</code>.
* @param updateAreas
@@ -2928,15 +2786,15 @@ public class MacroFormRenderer implement
String targetUrl = updateArea.getAreaTarget(context);
String ajaxParams = getAjaxParamsFromTarget(targetUrl);
//add first parameters from updateArea parameters
- if(UtilValidate.isNotEmpty(parameters)){
- if(UtilValidate.isEmpty(ajaxParams)){
+ if (UtilValidate.isNotEmpty(parameters)) {
+ if (UtilValidate.isEmpty(ajaxParams)) {
ajaxParams = "";
}
for (Map.Entry<String, String> entry : parameters.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
//test if ajax parameters are not already into extraParams, if so do not add it
- if(UtilValidate.isNotEmpty(extraParams) && extraParams.contains(value)){
+ if (UtilValidate.isNotEmpty(extraParams) && extraParams.contains(value)) {
continue;
}
if (ajaxParams.length() > 0 && ajaxParams.indexOf(key) < 0) {
@@ -2961,6 +2819,7 @@ public class MacroFormRenderer implement
Locale locale = UtilMisc.ensureLocale(context.get("locale"));
return FlexibleStringExpander.expandString(ajaxUrl, context, locale);
}
+
/** Extracts parameters from a target URL string, prepares them for an Ajax
* JavaScript call. This method is currently set to return a parameter string
* suitable for the Prototype.js library.
@@ -2973,6 +2832,7 @@ public class MacroFormRenderer implement
targetParams = targetParams.replace("&", "&");
return targetParams;
}
+
public void appendTooltip(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException {
// render the tooltip, in other methods too
String tooltip = modelFormField.getTooltip(context);
@@ -2985,17 +2845,18 @@ public class MacroFormRenderer implement
sr.append("\" />");
executeMacro(writer, sr.toString());
}
+
public void makeHyperlinkString(Appendable writer, ModelFormField.SubHyperlink subHyperlink, Map<String, Object> context) throws IOException {
if (subHyperlink == null) {
return;
}
if (subHyperlink.shouldUse(context)) {
writer.append(' ');
- makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), subHyperlink.getTargetType(), subHyperlink.getTarget(context),
- subHyperlink.getParameterMap(context), subHyperlink.getDescription(context), subHyperlink.getTargetWindow(context), subHyperlink.getConfirmation(context), subHyperlink.getModelFormField(),
- this.request, this.response, context);
+ makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), subHyperlink.getTargetType(), subHyperlink.getTarget(context), subHyperlink.getParameterMap(context), subHyperlink.getDescription(context), subHyperlink.getTargetWindow(context), subHyperlink
+ .getConfirmation(context), subHyperlink.getModelFormField(), this.request, this.response, context);
}
}
+
public void addAsterisks(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException {
String requiredField = "false";
String requiredStyle = "";
@@ -3012,6 +2873,7 @@ public class MacroFormRenderer implement
sr.append("\" />");
executeMacro(writer, sr.toString());
}
+
public void appendContentUrl(Appendable writer, String location) throws IOException {
StringBuilder buffer = new StringBuilder();
ContentUrlTag.appendContentPrefix(this.request, buffer);
@@ -3019,11 +2881,9 @@ public class MacroFormRenderer implement
writer.append(location);
}
- public void makeHyperlinkByType(Appendable writer, String linkType, String linkStyle, String targetType, String target,
- Map<String, String> parameterMap, String description, String targetWindow, String confirmation , ModelFormField modelFormField,
- HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
+ public void makeHyperlinkByType(Appendable writer, String linkType, String linkStyle, String targetType, String target, Map<String, String> parameterMap, String description, String targetWindow, String confirmation, ModelFormField modelFormField, HttpServletRequest request,
+ HttpServletResponse response, Map<String, Object> context) throws IOException {
String realLinkType = WidgetWorker.determineAutoLinkType(linkType, target, targetType, request);
-
String encodedDescription = encode(description, modelFormField, context);
// get the parameterized pagination index and size fields
int paginatorNumber = WidgetWorker.getPaginatorNumber(context);
@@ -3031,7 +2891,6 @@ public class MacroFormRenderer implement
String viewSizeField = modelFormField.modelForm.getMultiPaginateSizeField(context);
int viewIndex = modelFormField.modelForm.getViewIndex(context);
int viewSize = modelFormField.modelForm.getViewSize(context);
-
if (viewIndexField.equals("viewIndex" + "_" + paginatorNumber)) {
viewIndexField = "VIEW_INDEX" + "_" + paginatorNumber;
}
@@ -3042,8 +2901,7 @@ public class MacroFormRenderer implement
parameterMap.put(viewIndexField, Integer.toString(viewIndex));
parameterMap.put(viewSizeField, Integer.toString(viewSize));
if (modelFormField != null && "multi".equals(modelFormField.getModelForm().getType())) {
- WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, encodedDescription, confirmation , modelFormField, request, response, context);
-
+ WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, encodedDescription, confirmation, modelFormField, request, response, context);
// this is a bit trickier, since we can't do a nested form we'll have to put the link to submit the form in place, but put the actual form def elsewhere, ie after the big form is closed
Map<String, Object> wholeFormContext = UtilGenerics.checkMap(context.get("wholeFormContext"));
Appendable postMultiFormWriter = wholeFormContext != null ? (Appendable) wholeFormContext.get("postMultiFormWriter") : null;
@@ -3054,34 +2912,29 @@ public class MacroFormRenderer implement
WidgetWorker.makeHiddenFormLinkForm(postMultiFormWriter, target, targetType, targetWindow, parameterMap, modelFormField, request, response, context);
} else {
WidgetWorker.makeHiddenFormLinkForm(writer, target, targetType, targetWindow, parameterMap, modelFormField, request, response, context);
- WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, encodedDescription, confirmation , modelFormField, request, response, context);
+ WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, encodedDescription, confirmation, modelFormField, request, response, context);
}
} else {
- makeHyperlinkString(writer, linkStyle, targetType, target, parameterMap, encodedDescription, confirmation , modelFormField, request, response, context, targetWindow);
+ makeHyperlinkString(writer, linkStyle, targetType, target, parameterMap, encodedDescription, confirmation, modelFormField, request, response, context, targetWindow);
}
}
- public void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, Map<String, String> parameterMap,
- String description, String confirmation , ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context, String targetWindow)
- throws IOException {
+ public void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, Map<String, String> parameterMap, String description, String confirmation, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context,
+ String targetWindow) throws IOException {
if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) {
StringBuilder linkUrl = new StringBuilder();
-
WidgetWorker.buildHyperlinkUrl(linkUrl, target, targetType, parameterMap, null, false, false, true, request, response, context);
-
String event = "";
String action = "";
String imgSrc = "";
String alt = "";
String imgTitle = "";
String hiddenFormName = WidgetWorker.makeLinkHiddenFormName(context, modelFormField);
-
if (UtilValidate.isNotEmpty(modelFormField.getEvent()) && UtilValidate.isNotEmpty(modelFormField.getAction(context))) {
event = modelFormField.getEvent();
action = modelFormField.getAction(context);
}
-
if (UtilValidate.isNotEmpty(request.getAttribute("image"))) {
imgSrc = request.getAttribute("image").toString();
}
@@ -3092,24 +2945,22 @@ public class MacroFormRenderer implement
imgTitle = request.getAttribute("imageTitle").toString();
}
Integer size = Integer.valueOf("0");
-
if (UtilValidate.isNotEmpty(request.getAttribute("descriptionSize"))) {
size = Integer.valueOf(request.getAttribute("descriptionSize").toString());
}
- if( UtilValidate.isNotEmpty(description) && size > 0 && description.length() > size) {
+ if (UtilValidate.isNotEmpty(description) && size > 0 && description.length() > size) {
imgTitle = description;
description = description.substring(0, size - 8) + "..." + description.substring(description.length() - 5);
}
- if(UtilValidate.isEmpty(imgTitle)){
+ if (UtilValidate.isEmpty(imgTitle)) {
imgTitle = modelFormField.getTitle(context);
}
-
StringWriter sr = new StringWriter();
sr.append("<@makeHyperlinkString ");
sr.append("linkStyle=\"");
- sr.append(linkStyle==null?"":linkStyle);
+ sr.append(linkStyle == null ? "" : linkStyle);
sr.append("\" hiddenFormName=\"");
- sr.append(hiddenFormName==null?"":hiddenFormName);
+ sr.append(hiddenFormName == null ? "" : hiddenFormName);
sr.append("\" event=\"");
sr.append(event);
sr.append("\" action=\"");
@@ -3127,34 +2978,31 @@ public class MacroFormRenderer implement
sr.append("\" description=\"");
sr.append(description);
sr.append("\" confirmation =\"");
- sr.append(confirmation );
+ sr.append(confirmation);
sr.append("\" />");
executeMacro(writer, sr.toString());
}
}
- public void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation , ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
+ public void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) {
String hiddenFormName = WidgetWorker.makeLinkHiddenFormName(context, modelFormField);
String event = "";
String action = "";
String imgSrc = "";
-
if (UtilValidate.isNotEmpty(modelFormField.getEvent()) && UtilValidate.isNotEmpty(modelFormField.getAction(context))) {
event = modelFormField.getEvent();
action = modelFormField.getAction(context);
}
-
if (UtilValidate.isNotEmpty(request.getAttribute("image"))) {
imgSrc = request.getAttribute("image").toString();
}
-
StringWriter sr = new StringWriter();
sr.append("<@makeHiddenFormLinkAnchor ");
sr.append("linkStyle=\"");
- sr.append(linkStyle==null?"":linkStyle);
+ sr.append(linkStyle == null ? "" : linkStyle);
sr.append("\" hiddenFormName=\"");
- sr.append(hiddenFormName==null?"":hiddenFormName);
+ sr.append(hiddenFormName == null ? "" : hiddenFormName);
sr.append("\" event=\"");
sr.append(event);
sr.append("\" action=\"");
@@ -3164,7 +3012,7 @@ public class MacroFormRenderer implement
sr.append("\" description=\"");
sr.append(description);
sr.append("\" confirmation =\"");
- sr.append(confirmation );
+ sr.append(confirmation);
sr.append("\" />");
executeMacro(writer, sr.toString());
}
@@ -3176,19 +3024,18 @@ public class MacroFormRenderer implement
String name = WidgetWorker.makeLinkHiddenFormName(context, modelFormField);
StringBuilder parameters = new StringBuilder();
parameters.append("[");
- for (WidgetWorker.Parameter parameter: parameterList) {
- if (parameters.length() > 1) {
- parameters.append(",");
- }
- parameters.append("{'name':'");
- parameters.append(parameter.getName());
- parameters.append("'");
- parameters.append(",'value':'");
- parameters.append(parameter.getValue(context));
- parameters.append("'}");
+ for (WidgetWorker.Parameter parameter : parameterList) {
+ if (parameters.length() > 1) {
+ parameters.append(",");
+ }
+ parameters.append("{'name':'");
+ parameters.append(parameter.getName());
+ parameters.append("'");
+ parameters.append(",'value':'");
+ parameters.append(parameter.getValue(context));
+ parameters.append("'}");
}
parameters.append("]");
-
StringWriter sr = new StringWriter();
sr.append("<@makeHiddenFormLinkForm ");
sr.append("actionUrl=\"");
@@ -3206,7 +3053,6 @@ public class MacroFormRenderer implement
public void renderContainerFindField(Appendable writer, Map<String, Object> context, ContainerField containerField) throws IOException {
String id = containerField.getModelFormField().getIdName();
String className = UtilFormatOut.checkNull(containerField.getModelFormField().getWidgetStyle());
-
StringWriter sr = new StringWriter();
sr.append("<@renderContainerField ");
sr.append("id=\"");