@Test public void dropDownMacroRendered(@Mocked ModelFormField.DropDownField dropDownField) throws IOException { final List<ModelFormField.OptionValue> optionValues = ImmutableList.of( new ModelFormField.OptionValue("KEY1", "DESC1"), new ModelFormField.OptionValue("KEY2", "DESC2")); new Expectations() { { modelFormField.getEntry(withNotNull()); result = "KEY2"; dropDownField.getAllOptionValues(withNotNull(), (Delegator) any); result = optionValues; modelFormField.getTooltip(withNotNull()); result = ""; } }; macroFormRenderer.renderDropDownField(appendable, ImmutableMap.of(), dropDownField); assertAndGetMacroString("renderDropDownField", ImmutableMap.of( "currentValue", "KEY2", "options", ImmutableList.of("{'key':'KEY1','description':'DESC1'}", "{'key':'KEY2','description':'DESC2'}"))); }
@Override public void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField) throws IOException { ModelFormField modelFormField = dropDownField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); String conditionGroup = modelFormField.getConditionGroup(); boolean disabled = modelFormField.getDisabled(); List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete(); String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); Integer textSize = 0; 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); } if (textSize > 0 && UtilValidate.isNotEmpty(currentValue) && currentValue.length() > textSize) { currentValue = currentValue.substring(0, textSize - 8) + "..." + currentValue.substring(currentValue.length() - 5); } } boolean ajaxEnabled = autoComplete != null && this.javaScriptEnabled; String className = ""; String alert = "false"; String name = modelFormField.getParameterName(context); String id = modelFormField.getCurrentContainerId(context); String multiple = dropDownField.getAllowMultiple() ? "multiple" : ""; String otherFieldName = ""; String formName = modelForm.getName(); String size = dropDownField.getSize(); String dDFCurrent = dropDownField.getCurrent(); String firstInList = ""; String explicitDescription = ""; String allowEmpty = ""; StringBuilder options = new StringBuilder(); StringBuilder ajaxOptions = new StringBuilder(); if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) { className = modelFormField.getWidgetStyle(); if (modelFormField.shouldBeRed(context)) { alert = "true"; } } 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; } } String currentDescription = null; if (UtilValidate.isNotEmpty(currentValue)) { for (ModelFormField.OptionValue optionValue : allOptionValues) { if (optionValue.getKey().equals(currentValue)) { currentDescription = optionValue.getDescription(); break; } } } int otherFieldSize = dropDownField.getOtherFieldSize(); if (otherFieldSize > 0) { otherFieldName = dropDownField.getParameterNameOther(context); } if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) { firstInList = "first-in-list"; } explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context)); if (UtilValidate.isEmpty(explicitDescription)) { explicitDescription = (FieldInfoWithOptions.getDescriptionForOptionKey(currentValue, allOptionValues)); } if (textSize > 0 && UtilValidate.isNotEmpty(explicitDescription) && explicitDescription.length() > textSize) { explicitDescription = explicitDescription.substring(0, textSize - 8) + "..." + explicitDescription.substring(explicitDescription.length() - 5); } explicitDescription = encode(explicitDescription, modelFormField, context); if (dropDownField.getAllowEmpty()) { allowEmpty = "Y"; } List<String> currentValueList = null; if (UtilValidate.isNotEmpty(currentValue) && dropDownField.getAllowMultiple()) { if (currentValue.startsWith("[")) { currentValueList = StringUtil.toList(currentValue); } else { currentValueList = UtilMisc.toList(currentValue); } } options.append("["); Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator(); int count = 0; while (optionValueIter.hasNext()) { ModelFormField.OptionValue optionValue = optionValueIter.next(); if (options.length() > 1) { options.append(","); } options.append("{'key':'"); String key = encode(optionValue.getKey(), modelFormField, context); options.append(key); options.append("'"); options.append(",'description':'"); String description = optionValue.getDescription(); if (textSize > 0 && description.length() > textSize) { description = description.substring(0, textSize - 8) + "..." + description.substring(description.length() - 5); } options.append(encode(description.replaceAll("'", "\\\\\'"), modelFormField, context)); if (UtilValidate.isNotEmpty(currentValueList)) { options.append("'"); options.append(",'selected':'"); if (currentValueList.contains(optionValue.getKey())) { options.append("selected"); } else { options.append(""); } } options.append("'}"); if (ajaxEnabled) { count++; ajaxOptions.append(optionValue.getKey()).append(": "); ajaxOptions.append(" '").append(optionValue.getDescription()).append("'"); if (count != allOptionValues.size()) { ajaxOptions.append(", "); } } } options.append("]"); String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context); String otherValue = ""; String fieldName = ""; if (otherFieldSize > 0) { fieldName = modelFormField.getParameterName(context); Map<String, ? extends Object> dataMap = modelFormField.getMap(context); if (dataMap == null) { dataMap = context; } Object otherValueObj = dataMap.get(otherFieldName); otherValue = (otherValueObj == null) ? "" : otherValueObj.toString(); } String frequency = ""; String minChars = ""; String choices = ""; String autoSelect = ""; String partialSearch = ""; String partialChars = ""; String ignoreCase = ""; String fullSearch = ""; if (ajaxEnabled) { frequency = autoComplete.getFrequency(); minChars = autoComplete.getMinChars(); choices = autoComplete.getChoices(); autoSelect = autoComplete.getAutoSelect(); partialSearch = autoComplete.getPartialSearch(); partialChars = autoComplete.getPartialChars(); ignoreCase = autoComplete.getIgnoreCase(); fullSearch = autoComplete.getFullSearch(); } String tabindex = modelFormField.getTabindex(); StringWriter sr = new StringWriter(); sr.append("<@renderDropDownField "); sr.append("name=\""); sr.append(name); sr.append("\" className=\""); sr.append(className); sr.append("\" alert=\""); sr.append(alert); sr.append("\" id=\""); sr.append(id); sr.append("\" multiple=\""); sr.append(multiple); sr.append("\" formName=\""); sr.append(formName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" event=\""); if (event != null) { sr.append(event); } sr.append("\" action=\""); if (action != null) { sr.append(action); } sr.append("\" size=\""); sr.append(size); sr.append("\" firstInList=\""); sr.append(firstInList); sr.append("\" currentValue=\""); sr.append(currentValue); sr.append("\" explicitDescription=\""); sr.append(explicitDescription); sr.append("\" allowEmpty=\""); sr.append(allowEmpty); sr.append("\" options="); sr.append(options.toString()); sr.append(" fieldName=\""); sr.append(fieldName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" otherValue=\""); sr.append(otherValue); sr.append("\" otherFieldSize="); sr.append(Integer.toString(otherFieldSize)); sr.append(" dDFCurrent=\""); sr.append(dDFCurrent); sr.append("\" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" noCurrentSelectedKey=\""); sr.append(noCurrentSelectedKey); sr.append("\" ajaxOptions=\""); sr.append(ajaxOptions.toString()); sr.append("\" frequency=\""); sr.append(frequency); sr.append("\" minChars=\""); sr.append(minChars); sr.append("\" choices=\""); sr.append(choices); sr.append("\" autoSelect=\""); sr.append(autoSelect); sr.append("\" partialSearch=\""); sr.append(partialSearch); sr.append("\" partialChars=\""); sr.append(partialChars); sr.append("\" ignoreCase=\""); sr.append(ignoreCase); sr.append("\" fullSearch=\""); sr.append(fullSearch); sr.append("\" conditionGroup=\""); sr.append(conditionGroup); sr.append("\" tabindex=\""); sr.append(tabindex); sr.append("\" disabled="); sr.append(Boolean.toString(disabled)); sr.append(" />"); executeMacro(writer, sr.toString()); ModelFormField.SubHyperlink subHyperlink = dropDownField.getSubHyperlink(); if (subHyperlink != null && subHyperlink.shouldUse(context)) { makeHyperlinkString(writer, subHyperlink, context); } this.appendTooltip(writer, context, modelFormField); }
MacroFormRenderer implements FormStringRenderer { @Override public void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField) throws IOException { ModelFormField modelFormField = dropDownField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); String conditionGroup = modelFormField.getConditionGroup(); boolean disabled = modelFormField.getDisabled(); List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete(); String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); Integer textSize = 0; 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); } if (textSize > 0 && UtilValidate.isNotEmpty(currentValue) && currentValue.length() > textSize) { currentValue = currentValue.substring(0, textSize - 8) + "..." + currentValue.substring(currentValue.length() - 5); } } boolean ajaxEnabled = autoComplete != null && this.javaScriptEnabled; String className = ""; String alert = "false"; String name = modelFormField.getParameterName(context); String id = modelFormField.getCurrentContainerId(context); String multiple = dropDownField.getAllowMultiple() ? "multiple" : ""; String otherFieldName = ""; String formName = modelForm.getName(); String size = dropDownField.getSize(); String dDFCurrent = dropDownField.getCurrent(); String firstInList = ""; String explicitDescription = ""; String allowEmpty = ""; StringBuilder options = new StringBuilder(); StringBuilder ajaxOptions = new StringBuilder(); if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) { className = modelFormField.getWidgetStyle(); if (modelFormField.shouldBeRed(context)) { alert = "true"; } } 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; } } String currentDescription = null; if (UtilValidate.isNotEmpty(currentValue)) { for (ModelFormField.OptionValue optionValue : allOptionValues) { if (optionValue.getKey().equals(currentValue)) { currentDescription = optionValue.getDescription(); break; } } } int otherFieldSize = dropDownField.getOtherFieldSize(); if (otherFieldSize > 0) { otherFieldName = dropDownField.getParameterNameOther(context); } if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) { firstInList = "first-in-list"; } explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context)); if (UtilValidate.isEmpty(explicitDescription)) { explicitDescription = (FieldInfoWithOptions.getDescriptionForOptionKey(currentValue, allOptionValues)); } if (textSize > 0 && UtilValidate.isNotEmpty(explicitDescription) && explicitDescription.length() > textSize) { explicitDescription = explicitDescription.substring(0, textSize - 8) + "..." + explicitDescription.substring(explicitDescription.length() - 5); } explicitDescription = encode(explicitDescription, modelFormField, context); if (dropDownField.getAllowEmpty()) { allowEmpty = "Y"; } List<String> currentValueList = null; if (UtilValidate.isNotEmpty(currentValue) && dropDownField.getAllowMultiple()) { if (currentValue.startsWith("[")) { currentValueList = StringUtil.toList(currentValue); } else { currentValueList = UtilMisc.toList(currentValue); } } options.append("["); Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator(); int count = 0; while (optionValueIter.hasNext()) { ModelFormField.OptionValue optionValue = optionValueIter.next(); if (options.length() > 1) { options.append(","); } options.append("{'key':'"); String key = encode(optionValue.getKey(), modelFormField, context); options.append(key); options.append("'"); options.append(",'description':'"); String description = optionValue.getDescription(); if (textSize > 0 && description.length() > textSize) { description = description.substring(0, textSize - 8) + "..." + description.substring(description.length() - 5); } options.append(encode(description.replaceAll("'", "\\\\\'"), modelFormField, context)); if (UtilValidate.isNotEmpty(currentValueList)) { options.append("'"); options.append(",'selected':'"); if (currentValueList.contains(optionValue.getKey())) { options.append("selected"); } else { options.append(""); } } options.append("'}"); if (ajaxEnabled) { count++; ajaxOptions.append(optionValue.getKey()).append(": "); ajaxOptions.append(" '").append(optionValue.getDescription()).append("'"); if (count != allOptionValues.size()) { ajaxOptions.append(", "); } } } options.append("]"); String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context); String otherValue = ""; String fieldName = ""; if (otherFieldSize > 0) { fieldName = modelFormField.getParameterName(context); Map<String, ? extends Object> dataMap = modelFormField.getMap(context); if (dataMap == null) { dataMap = context; } Object otherValueObj = dataMap.get(otherFieldName); otherValue = (otherValueObj == null) ? "" : otherValueObj.toString(); } String frequency = ""; String minChars = ""; String choices = ""; String autoSelect = ""; String partialSearch = ""; String partialChars = ""; String ignoreCase = ""; String fullSearch = ""; if (ajaxEnabled) { frequency = autoComplete.getFrequency(); minChars = autoComplete.getMinChars(); choices = autoComplete.getChoices(); autoSelect = autoComplete.getAutoSelect(); partialSearch = autoComplete.getPartialSearch(); partialChars = autoComplete.getPartialChars(); ignoreCase = autoComplete.getIgnoreCase(); fullSearch = autoComplete.getFullSearch(); } String tabindex = modelFormField.getTabindex(); StringWriter sr = new StringWriter(); sr.append("<@renderDropDownField "); sr.append("name=\""); sr.append(name); sr.append("\" className=\""); sr.append(className); sr.append("\" alert=\""); sr.append(alert); sr.append("\" id=\""); sr.append(id); sr.append("\" multiple=\""); sr.append(multiple); sr.append("\" formName=\""); sr.append(formName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" event=\""); if (event != null) { sr.append(event); } sr.append("\" action=\""); if (action != null) { sr.append(action); } sr.append("\" size=\""); sr.append(size); sr.append("\" firstInList=\""); sr.append(firstInList); sr.append("\" currentValue=\""); sr.append(currentValue); sr.append("\" explicitDescription=\""); sr.append(explicitDescription); sr.append("\" allowEmpty=\""); sr.append(allowEmpty); sr.append("\" options="); sr.append(options.toString()); sr.append(" fieldName=\""); sr.append(fieldName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" otherValue=\""); sr.append(otherValue); sr.append("\" otherFieldSize="); sr.append(Integer.toString(otherFieldSize)); sr.append(" dDFCurrent=\""); sr.append(dDFCurrent); sr.append("\" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" noCurrentSelectedKey=\""); sr.append(noCurrentSelectedKey); sr.append("\" ajaxOptions=\""); sr.append(ajaxOptions.toString()); sr.append("\" frequency=\""); sr.append(frequency); sr.append("\" minChars=\""); sr.append(minChars); sr.append("\" choices=\""); sr.append(choices); sr.append("\" autoSelect=\""); sr.append(autoSelect); sr.append("\" partialSearch=\""); sr.append(partialSearch); sr.append("\" partialChars=\""); sr.append(partialChars); sr.append("\" ignoreCase=\""); sr.append(ignoreCase); sr.append("\" fullSearch=\""); sr.append(fullSearch); sr.append("\" conditionGroup=\""); sr.append(conditionGroup); sr.append("\" tabindex=\""); sr.append(tabindex); sr.append("\" disabled="); sr.append(Boolean.toString(disabled)); sr.append(" />"); executeMacro(writer, sr.toString()); ModelFormField.SubHyperlink subHyperlink = dropDownField.getSubHyperlink(); if (subHyperlink != null && subHyperlink.shouldUse(context)) { makeHyperlinkString(writer, subHyperlink, context); } this.appendTooltip(writer, context, modelFormField); } }
MacroFormRenderer implements FormStringRenderer { @Override public void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField) throws IOException { ModelFormField modelFormField = dropDownField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); String conditionGroup = modelFormField.getConditionGroup(); boolean disabled = modelFormField.getDisabled(); List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete(); String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); Integer textSize = 0; 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); } if (textSize > 0 && UtilValidate.isNotEmpty(currentValue) && currentValue.length() > textSize) { currentValue = currentValue.substring(0, textSize - 8) + "..." + currentValue.substring(currentValue.length() - 5); } } boolean ajaxEnabled = autoComplete != null && this.javaScriptEnabled; String className = ""; String alert = "false"; String name = modelFormField.getParameterName(context); String id = modelFormField.getCurrentContainerId(context); String multiple = dropDownField.getAllowMultiple() ? "multiple" : ""; String otherFieldName = ""; String formName = modelForm.getName(); String size = dropDownField.getSize(); String dDFCurrent = dropDownField.getCurrent(); String firstInList = ""; String explicitDescription = ""; String allowEmpty = ""; StringBuilder options = new StringBuilder(); StringBuilder ajaxOptions = new StringBuilder(); if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) { className = modelFormField.getWidgetStyle(); if (modelFormField.shouldBeRed(context)) { alert = "true"; } } 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; } } String currentDescription = null; if (UtilValidate.isNotEmpty(currentValue)) { for (ModelFormField.OptionValue optionValue : allOptionValues) { if (optionValue.getKey().equals(currentValue)) { currentDescription = optionValue.getDescription(); break; } } } int otherFieldSize = dropDownField.getOtherFieldSize(); if (otherFieldSize > 0) { otherFieldName = dropDownField.getParameterNameOther(context); } if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) { firstInList = "first-in-list"; } explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context)); if (UtilValidate.isEmpty(explicitDescription)) { explicitDescription = (FieldInfoWithOptions.getDescriptionForOptionKey(currentValue, allOptionValues)); } if (textSize > 0 && UtilValidate.isNotEmpty(explicitDescription) && explicitDescription.length() > textSize) { explicitDescription = explicitDescription.substring(0, textSize - 8) + "..." + explicitDescription.substring(explicitDescription.length() - 5); } explicitDescription = encode(explicitDescription, modelFormField, context); if (dropDownField.getAllowEmpty()) { allowEmpty = "Y"; } List<String> currentValueList = null; if (UtilValidate.isNotEmpty(currentValue) && dropDownField.getAllowMultiple()) { if (currentValue.startsWith("[")) { currentValueList = StringUtil.toList(currentValue); } else { currentValueList = UtilMisc.toList(currentValue); } } options.append("["); Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator(); int count = 0; while (optionValueIter.hasNext()) { ModelFormField.OptionValue optionValue = optionValueIter.next(); if (options.length() > 1) { options.append(","); } options.append("{'key':'"); String key = encode(optionValue.getKey(), modelFormField, context); options.append(key); options.append("'"); options.append(",'description':'"); String description = optionValue.getDescription(); if (textSize > 0 && description.length() > textSize) { description = description.substring(0, textSize - 8) + "..." + description.substring(description.length() - 5); } options.append(encode(description.replaceAll("'", "\\\\\'"), modelFormField, context)); if (UtilValidate.isNotEmpty(currentValueList)) { options.append("'"); options.append(",'selected':'"); if (currentValueList.contains(optionValue.getKey())) { options.append("selected"); } else { options.append(""); } } options.append("'}"); if (ajaxEnabled) { count++; ajaxOptions.append(optionValue.getKey()).append(": "); ajaxOptions.append(" '").append(optionValue.getDescription()).append("'"); if (count != allOptionValues.size()) { ajaxOptions.append(", "); } } } options.append("]"); String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context); String otherValue = ""; String fieldName = ""; if (otherFieldSize > 0) { fieldName = modelFormField.getParameterName(context); Map<String, ? extends Object> dataMap = modelFormField.getMap(context); if (dataMap == null) { dataMap = context; } Object otherValueObj = dataMap.get(otherFieldName); otherValue = (otherValueObj == null) ? "" : otherValueObj.toString(); } String frequency = ""; String minChars = ""; String choices = ""; String autoSelect = ""; String partialSearch = ""; String partialChars = ""; String ignoreCase = ""; String fullSearch = ""; if (ajaxEnabled) { frequency = autoComplete.getFrequency(); minChars = autoComplete.getMinChars(); choices = autoComplete.getChoices(); autoSelect = autoComplete.getAutoSelect(); partialSearch = autoComplete.getPartialSearch(); partialChars = autoComplete.getPartialChars(); ignoreCase = autoComplete.getIgnoreCase(); fullSearch = autoComplete.getFullSearch(); } String tabindex = modelFormField.getTabindex(); StringWriter sr = new StringWriter(); sr.append("<@renderDropDownField "); sr.append("name=\""); sr.append(name); sr.append("\" className=\""); sr.append(className); sr.append("\" alert=\""); sr.append(alert); sr.append("\" id=\""); sr.append(id); sr.append("\" multiple=\""); sr.append(multiple); sr.append("\" formName=\""); sr.append(formName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" event=\""); if (event != null) { sr.append(event); } sr.append("\" action=\""); if (action != null) { sr.append(action); } sr.append("\" size=\""); sr.append(size); sr.append("\" firstInList=\""); sr.append(firstInList); sr.append("\" currentValue=\""); sr.append(currentValue); sr.append("\" explicitDescription=\""); sr.append(explicitDescription); sr.append("\" allowEmpty=\""); sr.append(allowEmpty); sr.append("\" options="); sr.append(options.toString()); sr.append(" fieldName=\""); sr.append(fieldName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" otherValue=\""); sr.append(otherValue); sr.append("\" otherFieldSize="); sr.append(Integer.toString(otherFieldSize)); sr.append(" dDFCurrent=\""); sr.append(dDFCurrent); sr.append("\" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" noCurrentSelectedKey=\""); sr.append(noCurrentSelectedKey); sr.append("\" ajaxOptions=\""); sr.append(ajaxOptions.toString()); sr.append("\" frequency=\""); sr.append(frequency); sr.append("\" minChars=\""); sr.append(minChars); sr.append("\" choices=\""); sr.append(choices); sr.append("\" autoSelect=\""); sr.append(autoSelect); sr.append("\" partialSearch=\""); sr.append(partialSearch); sr.append("\" partialChars=\""); sr.append(partialChars); sr.append("\" ignoreCase=\""); sr.append(ignoreCase); sr.append("\" fullSearch=\""); sr.append(fullSearch); sr.append("\" conditionGroup=\""); sr.append(conditionGroup); sr.append("\" tabindex=\""); sr.append(tabindex); sr.append("\" disabled="); sr.append(Boolean.toString(disabled)); sr.append(" />"); executeMacro(writer, sr.toString()); ModelFormField.SubHyperlink subHyperlink = dropDownField.getSubHyperlink(); if (subHyperlink != null && subHyperlink.shouldUse(context)) { makeHyperlinkString(writer, subHyperlink, context); } this.appendTooltip(writer, context, modelFormField); } MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response);  MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response,
                             FtlWriter ftlWriter); @Deprecated  MacroFormRenderer(String macroLibraryPath, Appendable writer, HttpServletRequest request, HttpServletResponse response); }
MacroFormRenderer implements FormStringRenderer { @Override public void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField) throws IOException { ModelFormField modelFormField = dropDownField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); String conditionGroup = modelFormField.getConditionGroup(); boolean disabled = modelFormField.getDisabled(); List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete(); String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); Integer textSize = 0; 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); } if (textSize > 0 && UtilValidate.isNotEmpty(currentValue) && currentValue.length() > textSize) { currentValue = currentValue.substring(0, textSize - 8) + "..." + currentValue.substring(currentValue.length() - 5); } } boolean ajaxEnabled = autoComplete != null && this.javaScriptEnabled; String className = ""; String alert = "false"; String name = modelFormField.getParameterName(context); String id = modelFormField.getCurrentContainerId(context); String multiple = dropDownField.getAllowMultiple() ? "multiple" : ""; String otherFieldName = ""; String formName = modelForm.getName(); String size = dropDownField.getSize(); String dDFCurrent = dropDownField.getCurrent(); String firstInList = ""; String explicitDescription = ""; String allowEmpty = ""; StringBuilder options = new StringBuilder(); StringBuilder ajaxOptions = new StringBuilder(); if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) { className = modelFormField.getWidgetStyle(); if (modelFormField.shouldBeRed(context)) { alert = "true"; } } 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; } } String currentDescription = null; if (UtilValidate.isNotEmpty(currentValue)) { for (ModelFormField.OptionValue optionValue : allOptionValues) { if (optionValue.getKey().equals(currentValue)) { currentDescription = optionValue.getDescription(); break; } } } int otherFieldSize = dropDownField.getOtherFieldSize(); if (otherFieldSize > 0) { otherFieldName = dropDownField.getParameterNameOther(context); } if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) { firstInList = "first-in-list"; } explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context)); if (UtilValidate.isEmpty(explicitDescription)) { explicitDescription = (FieldInfoWithOptions.getDescriptionForOptionKey(currentValue, allOptionValues)); } if (textSize > 0 && UtilValidate.isNotEmpty(explicitDescription) && explicitDescription.length() > textSize) { explicitDescription = explicitDescription.substring(0, textSize - 8) + "..." + explicitDescription.substring(explicitDescription.length() - 5); } explicitDescription = encode(explicitDescription, modelFormField, context); if (dropDownField.getAllowEmpty()) { allowEmpty = "Y"; } List<String> currentValueList = null; if (UtilValidate.isNotEmpty(currentValue) && dropDownField.getAllowMultiple()) { if (currentValue.startsWith("[")) { currentValueList = StringUtil.toList(currentValue); } else { currentValueList = UtilMisc.toList(currentValue); } } options.append("["); Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator(); int count = 0; while (optionValueIter.hasNext()) { ModelFormField.OptionValue optionValue = optionValueIter.next(); if (options.length() > 1) { options.append(","); } options.append("{'key':'"); String key = encode(optionValue.getKey(), modelFormField, context); options.append(key); options.append("'"); options.append(",'description':'"); String description = optionValue.getDescription(); if (textSize > 0 && description.length() > textSize) { description = description.substring(0, textSize - 8) + "..." + description.substring(description.length() - 5); } options.append(encode(description.replaceAll("'", "\\\\\'"), modelFormField, context)); if (UtilValidate.isNotEmpty(currentValueList)) { options.append("'"); options.append(",'selected':'"); if (currentValueList.contains(optionValue.getKey())) { options.append("selected"); } else { options.append(""); } } options.append("'}"); if (ajaxEnabled) { count++; ajaxOptions.append(optionValue.getKey()).append(": "); ajaxOptions.append(" '").append(optionValue.getDescription()).append("'"); if (count != allOptionValues.size()) { ajaxOptions.append(", "); } } } options.append("]"); String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context); String otherValue = ""; String fieldName = ""; if (otherFieldSize > 0) { fieldName = modelFormField.getParameterName(context); Map<String, ? extends Object> dataMap = modelFormField.getMap(context); if (dataMap == null) { dataMap = context; } Object otherValueObj = dataMap.get(otherFieldName); otherValue = (otherValueObj == null) ? "" : otherValueObj.toString(); } String frequency = ""; String minChars = ""; String choices = ""; String autoSelect = ""; String partialSearch = ""; String partialChars = ""; String ignoreCase = ""; String fullSearch = ""; if (ajaxEnabled) { frequency = autoComplete.getFrequency(); minChars = autoComplete.getMinChars(); choices = autoComplete.getChoices(); autoSelect = autoComplete.getAutoSelect(); partialSearch = autoComplete.getPartialSearch(); partialChars = autoComplete.getPartialChars(); ignoreCase = autoComplete.getIgnoreCase(); fullSearch = autoComplete.getFullSearch(); } String tabindex = modelFormField.getTabindex(); StringWriter sr = new StringWriter(); sr.append("<@renderDropDownField "); sr.append("name=\""); sr.append(name); sr.append("\" className=\""); sr.append(className); sr.append("\" alert=\""); sr.append(alert); sr.append("\" id=\""); sr.append(id); sr.append("\" multiple=\""); sr.append(multiple); sr.append("\" formName=\""); sr.append(formName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" event=\""); if (event != null) { sr.append(event); } sr.append("\" action=\""); if (action != null) { sr.append(action); } sr.append("\" size=\""); sr.append(size); sr.append("\" firstInList=\""); sr.append(firstInList); sr.append("\" currentValue=\""); sr.append(currentValue); sr.append("\" explicitDescription=\""); sr.append(explicitDescription); sr.append("\" allowEmpty=\""); sr.append(allowEmpty); sr.append("\" options="); sr.append(options.toString()); sr.append(" fieldName=\""); sr.append(fieldName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" otherValue=\""); sr.append(otherValue); sr.append("\" otherFieldSize="); sr.append(Integer.toString(otherFieldSize)); sr.append(" dDFCurrent=\""); sr.append(dDFCurrent); sr.append("\" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" noCurrentSelectedKey=\""); sr.append(noCurrentSelectedKey); sr.append("\" ajaxOptions=\""); sr.append(ajaxOptions.toString()); sr.append("\" frequency=\""); sr.append(frequency); sr.append("\" minChars=\""); sr.append(minChars); sr.append("\" choices=\""); sr.append(choices); sr.append("\" autoSelect=\""); sr.append(autoSelect); sr.append("\" partialSearch=\""); sr.append(partialSearch); sr.append("\" partialChars=\""); sr.append(partialChars); sr.append("\" ignoreCase=\""); sr.append(ignoreCase); sr.append("\" fullSearch=\""); sr.append(fullSearch); sr.append("\" conditionGroup=\""); sr.append(conditionGroup); sr.append("\" tabindex=\""); sr.append(tabindex); sr.append("\" disabled="); sr.append(Boolean.toString(disabled)); sr.append(" />"); executeMacro(writer, sr.toString()); ModelFormField.SubHyperlink subHyperlink = dropDownField.getSubHyperlink(); if (subHyperlink != null && subHyperlink.shouldUse(context)) { makeHyperlinkString(writer, subHyperlink, context); } this.appendTooltip(writer, context, modelFormField); } MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response);  MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response,
                             FtlWriter ftlWriter); @Deprecated  MacroFormRenderer(String macroLibraryPath, Appendable writer, HttpServletRequest request, HttpServletResponse response); static String getAjaxParamsFromTarget(String target); boolean getRenderPagination(); void setRenderPagination(boolean renderPagination); void renderLabel(Appendable writer, Map<String, Object> context, ModelScreenWidget.Label label); @Override void renderDisplayField(Appendable writer, Map<String, Object> context, DisplayField displayField); @Override void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField); @Override void renderMenuField(Appendable writer, Map<String, Object> context, MenuField menuField); @Override void renderTextField(Appendable writer, Map<String, Object> context, TextField textField); @Override void renderTextareaField(Appendable writer, Map<String, Object> context, TextareaField textareaField); @Override void renderDateTimeField(Appendable writer, Map<String, Object> context, DateTimeField dateTimeField); @Override void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField); @Override void renderCheckField(Appendable writer, Map<String, Object> context, CheckField checkField); @Override void renderRadioField(Appendable writer, Map<String, Object> context, RadioField radioField); @Override void renderSubmitField(Appendable writer, Map<String, Object> context, SubmitField submitField); @Override void renderResetField(Appendable writer, Map<String, Object> context, ResetField resetField); @Override void renderHiddenField(Appendable writer, Map<String, Object> context, HiddenField hiddenField); @Override void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String value); @Override void renderIgnoredField(Appendable writer, Map<String, Object> context, IgnoredField ignoredField); @Override void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField,
                                              int positionSpan); @Override void renderFormatHeaderRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField); @Override void renderFormatHeaderRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm,
                                                            ModelFormField modelFormField, boolean isLast); @Override void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField,
                                            int positionSpan); @Override void renderFormatItemRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField); @Override void renderFormatItemRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatSingleWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatSingleWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowTitleCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowTitleCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowSpacerCell(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowWidgetCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions,
                                                   int positionSpan, Integer nextPositionInRow); @Override void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions,
                                                    int positionSpan, Integer nextPositionInRow); @Override void renderFormatEmptySpace(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField); @Override void renderRangeFindField(Appendable writer, Map<String, Object> context, RangeFindField rangeFindField); @Override void renderDateFindField(Appendable writer, Map<String, Object> context, DateFindField dateFindField); @Override void renderLookupField(Appendable writer, Map<String, Object> context, LookupField lookupField); void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFileField(Appendable writer, Map<String, Object> context, FileField textField); @Override void renderPasswordField(Appendable writer, Map<String, Object> context, PasswordField passwordField); @Override void renderImageField(Appendable writer, Map<String, Object> context, ImageField imageField); @Override void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup); @Override void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup); @Override void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner); void renderBeginningBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget); void renderEndingBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget); void renderSortField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText); String createAjaxParamsFromUpdateAreas(List<ModelForm.UpdateArea> updateAreas, String extraParams, Map<String, ? extends Object> context); void appendTooltip(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); void makeHyperlinkString(Appendable writer, ModelFormField.SubHyperlink subHyperlink, Map<String, Object> context); void addAsterisks(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); void appendContentUrl(Appendable writer, String location); 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); 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); void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation, ModelFormField modelFormField,
                                         HttpServletRequest request, HttpServletResponse response, Map<String, Object> context); @Override void renderContainerFindField(Appendable writer, Map<String, Object> context, ContainerField containerField); }
MacroFormRenderer implements FormStringRenderer { @Override public void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField) throws IOException { ModelFormField modelFormField = dropDownField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); String conditionGroup = modelFormField.getConditionGroup(); boolean disabled = modelFormField.getDisabled(); List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, WidgetWorker.getDelegator(context)); ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete(); String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); Integer textSize = 0; 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); } if (textSize > 0 && UtilValidate.isNotEmpty(currentValue) && currentValue.length() > textSize) { currentValue = currentValue.substring(0, textSize - 8) + "..." + currentValue.substring(currentValue.length() - 5); } } boolean ajaxEnabled = autoComplete != null && this.javaScriptEnabled; String className = ""; String alert = "false"; String name = modelFormField.getParameterName(context); String id = modelFormField.getCurrentContainerId(context); String multiple = dropDownField.getAllowMultiple() ? "multiple" : ""; String otherFieldName = ""; String formName = modelForm.getName(); String size = dropDownField.getSize(); String dDFCurrent = dropDownField.getCurrent(); String firstInList = ""; String explicitDescription = ""; String allowEmpty = ""; StringBuilder options = new StringBuilder(); StringBuilder ajaxOptions = new StringBuilder(); if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) { className = modelFormField.getWidgetStyle(); if (modelFormField.shouldBeRed(context)) { alert = "true"; } } 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; } } String currentDescription = null; if (UtilValidate.isNotEmpty(currentValue)) { for (ModelFormField.OptionValue optionValue : allOptionValues) { if (optionValue.getKey().equals(currentValue)) { currentDescription = optionValue.getDescription(); break; } } } int otherFieldSize = dropDownField.getOtherFieldSize(); if (otherFieldSize > 0) { otherFieldName = dropDownField.getParameterNameOther(context); } if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) { firstInList = "first-in-list"; } explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context)); if (UtilValidate.isEmpty(explicitDescription)) { explicitDescription = (FieldInfoWithOptions.getDescriptionForOptionKey(currentValue, allOptionValues)); } if (textSize > 0 && UtilValidate.isNotEmpty(explicitDescription) && explicitDescription.length() > textSize) { explicitDescription = explicitDescription.substring(0, textSize - 8) + "..." + explicitDescription.substring(explicitDescription.length() - 5); } explicitDescription = encode(explicitDescription, modelFormField, context); if (dropDownField.getAllowEmpty()) { allowEmpty = "Y"; } List<String> currentValueList = null; if (UtilValidate.isNotEmpty(currentValue) && dropDownField.getAllowMultiple()) { if (currentValue.startsWith("[")) { currentValueList = StringUtil.toList(currentValue); } else { currentValueList = UtilMisc.toList(currentValue); } } options.append("["); Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator(); int count = 0; while (optionValueIter.hasNext()) { ModelFormField.OptionValue optionValue = optionValueIter.next(); if (options.length() > 1) { options.append(","); } options.append("{'key':'"); String key = encode(optionValue.getKey(), modelFormField, context); options.append(key); options.append("'"); options.append(",'description':'"); String description = optionValue.getDescription(); if (textSize > 0 && description.length() > textSize) { description = description.substring(0, textSize - 8) + "..." + description.substring(description.length() - 5); } options.append(encode(description.replaceAll("'", "\\\\\'"), modelFormField, context)); if (UtilValidate.isNotEmpty(currentValueList)) { options.append("'"); options.append(",'selected':'"); if (currentValueList.contains(optionValue.getKey())) { options.append("selected"); } else { options.append(""); } } options.append("'}"); if (ajaxEnabled) { count++; ajaxOptions.append(optionValue.getKey()).append(": "); ajaxOptions.append(" '").append(optionValue.getDescription()).append("'"); if (count != allOptionValues.size()) { ajaxOptions.append(", "); } } } options.append("]"); String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context); String otherValue = ""; String fieldName = ""; if (otherFieldSize > 0) { fieldName = modelFormField.getParameterName(context); Map<String, ? extends Object> dataMap = modelFormField.getMap(context); if (dataMap == null) { dataMap = context; } Object otherValueObj = dataMap.get(otherFieldName); otherValue = (otherValueObj == null) ? "" : otherValueObj.toString(); } String frequency = ""; String minChars = ""; String choices = ""; String autoSelect = ""; String partialSearch = ""; String partialChars = ""; String ignoreCase = ""; String fullSearch = ""; if (ajaxEnabled) { frequency = autoComplete.getFrequency(); minChars = autoComplete.getMinChars(); choices = autoComplete.getChoices(); autoSelect = autoComplete.getAutoSelect(); partialSearch = autoComplete.getPartialSearch(); partialChars = autoComplete.getPartialChars(); ignoreCase = autoComplete.getIgnoreCase(); fullSearch = autoComplete.getFullSearch(); } String tabindex = modelFormField.getTabindex(); StringWriter sr = new StringWriter(); sr.append("<@renderDropDownField "); sr.append("name=\""); sr.append(name); sr.append("\" className=\""); sr.append(className); sr.append("\" alert=\""); sr.append(alert); sr.append("\" id=\""); sr.append(id); sr.append("\" multiple=\""); sr.append(multiple); sr.append("\" formName=\""); sr.append(formName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" event=\""); if (event != null) { sr.append(event); } sr.append("\" action=\""); if (action != null) { sr.append(action); } sr.append("\" size=\""); sr.append(size); sr.append("\" firstInList=\""); sr.append(firstInList); sr.append("\" currentValue=\""); sr.append(currentValue); sr.append("\" explicitDescription=\""); sr.append(explicitDescription); sr.append("\" allowEmpty=\""); sr.append(allowEmpty); sr.append("\" options="); sr.append(options.toString()); sr.append(" fieldName=\""); sr.append(fieldName); sr.append("\" otherFieldName=\""); sr.append(otherFieldName); sr.append("\" otherValue=\""); sr.append(otherValue); sr.append("\" otherFieldSize="); sr.append(Integer.toString(otherFieldSize)); sr.append(" dDFCurrent=\""); sr.append(dDFCurrent); sr.append("\" ajaxEnabled="); sr.append(Boolean.toString(ajaxEnabled)); sr.append(" noCurrentSelectedKey=\""); sr.append(noCurrentSelectedKey); sr.append("\" ajaxOptions=\""); sr.append(ajaxOptions.toString()); sr.append("\" frequency=\""); sr.append(frequency); sr.append("\" minChars=\""); sr.append(minChars); sr.append("\" choices=\""); sr.append(choices); sr.append("\" autoSelect=\""); sr.append(autoSelect); sr.append("\" partialSearch=\""); sr.append(partialSearch); sr.append("\" partialChars=\""); sr.append(partialChars); sr.append("\" ignoreCase=\""); sr.append(ignoreCase); sr.append("\" fullSearch=\""); sr.append(fullSearch); sr.append("\" conditionGroup=\""); sr.append(conditionGroup); sr.append("\" tabindex=\""); sr.append(tabindex); sr.append("\" disabled="); sr.append(Boolean.toString(disabled)); sr.append(" />"); executeMacro(writer, sr.toString()); ModelFormField.SubHyperlink subHyperlink = dropDownField.getSubHyperlink(); if (subHyperlink != null && subHyperlink.shouldUse(context)) { makeHyperlinkString(writer, subHyperlink, context); } this.appendTooltip(writer, context, modelFormField); } MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response);  MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response,
                             FtlWriter ftlWriter); @Deprecated  MacroFormRenderer(String macroLibraryPath, Appendable writer, HttpServletRequest request, HttpServletResponse response); static String getAjaxParamsFromTarget(String target); boolean getRenderPagination(); void setRenderPagination(boolean renderPagination); void renderLabel(Appendable writer, Map<String, Object> context, ModelScreenWidget.Label label); @Override void renderDisplayField(Appendable writer, Map<String, Object> context, DisplayField displayField); @Override void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField); @Override void renderMenuField(Appendable writer, Map<String, Object> context, MenuField menuField); @Override void renderTextField(Appendable writer, Map<String, Object> context, TextField textField); @Override void renderTextareaField(Appendable writer, Map<String, Object> context, TextareaField textareaField); @Override void renderDateTimeField(Appendable writer, Map<String, Object> context, DateTimeField dateTimeField); @Override void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField); @Override void renderCheckField(Appendable writer, Map<String, Object> context, CheckField checkField); @Override void renderRadioField(Appendable writer, Map<String, Object> context, RadioField radioField); @Override void renderSubmitField(Appendable writer, Map<String, Object> context, SubmitField submitField); @Override void renderResetField(Appendable writer, Map<String, Object> context, ResetField resetField); @Override void renderHiddenField(Appendable writer, Map<String, Object> context, HiddenField hiddenField); @Override void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String value); @Override void renderIgnoredField(Appendable writer, Map<String, Object> context, IgnoredField ignoredField); @Override void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField,
                                              int positionSpan); @Override void renderFormatHeaderRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField); @Override void renderFormatHeaderRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm,
                                                            ModelFormField modelFormField, boolean isLast); @Override void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField,
                                            int positionSpan); @Override void renderFormatItemRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField); @Override void renderFormatItemRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatItemRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatSingleWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatSingleWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFormatFieldRowTitleCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowTitleCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowSpacerCell(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); @Override void renderFormatFieldRowWidgetCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions,
                                                   int positionSpan, Integer nextPositionInRow); @Override void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions,
                                                    int positionSpan, Integer nextPositionInRow); @Override void renderFormatEmptySpace(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField); @Override void renderRangeFindField(Appendable writer, Map<String, Object> context, RangeFindField rangeFindField); @Override void renderDateFindField(Appendable writer, Map<String, Object> context, DateFindField dateFindField); @Override void renderLookupField(Appendable writer, Map<String, Object> context, LookupField lookupField); void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm); @Override void renderFileField(Appendable writer, Map<String, Object> context, FileField textField); @Override void renderPasswordField(Appendable writer, Map<String, Object> context, PasswordField passwordField); @Override void renderImageField(Appendable writer, Map<String, Object> context, ImageField imageField); @Override void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup); @Override void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup); @Override void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner); void renderBeginningBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget); void renderEndingBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget); void renderSortField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText); String createAjaxParamsFromUpdateAreas(List<ModelForm.UpdateArea> updateAreas, String extraParams, Map<String, ? extends Object> context); void appendTooltip(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); void makeHyperlinkString(Appendable writer, ModelFormField.SubHyperlink subHyperlink, Map<String, Object> context); void addAsterisks(Appendable writer, Map<String, Object> context, ModelFormField modelFormField); void appendContentUrl(Appendable writer, String location); 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); 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); void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation, ModelFormField modelFormField,
                                         HttpServletRequest request, HttpServletResponse response, Map<String, Object> context); @Override void renderContainerFindField(Appendable writer, Map<String, Object> context, ContainerField containerField);  }