📄 htmlformrenderer.java
字号:
// Adapted from work by Yucca Korpela // http://www.cs.tut.fi/~jkorpela/forms/combo.html if (otherFieldSize > 0) { String fieldName = modelFormField.getParameterName(context); Map dataMap = modelFormField.getMap(context); if (dataMap == null) { dataMap = context; } Object otherValueObj = dataMap.get(otherFieldName); String otherValue = (otherValueObj == null) ? "" : otherValueObj.toString(); buffer.append("<noscript>"); buffer.append("<input type='text' name='"); buffer.append(otherFieldName); buffer.append("'/> "); buffer.append("</noscript>"); buffer.append("\n<script type='text/javascript' language='JavaScript'><!--"); buffer.append("\ndisa = ' disabled';"); buffer.append("\nif(other_choice(document."); buffer.append(modelForm.getName()); buffer.append("."); buffer.append(fieldName); buffer.append(")) disa = '';"); buffer.append("\ndocument.write(\"<input type="); buffer.append("'text' name='"); buffer.append(otherFieldName); buffer.append("' value='"); buffer.append(otherValue); buffer.append("' size='"); buffer.append(otherFieldSize); buffer.append("' "); buffer.append("\" +disa+ \" onfocus='check_choice(document."); buffer.append(modelForm.getName()); buffer.append("."); buffer.append(fieldName); buffer.append(")'/>\");"); buffer.append("\nif(disa && document.styleSheets)"); buffer.append(" document."); buffer.append(modelForm.getName()); buffer.append("."); buffer.append(otherFieldName); buffer.append(".style.visibility = 'hidden';"); buffer.append("\n//--></script>"); } this.makeHyperlinkString(buffer, dropDownField.getSubHyperlink(), context); this.appendTooltip(buffer, context, modelFormField); this.appendWhitespace(buffer); } /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderCheckField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.CheckField) */ public void renderCheckField(StringBuffer buffer, Map context, CheckField checkField) { // well, I don't know if this will be very useful... but here it is ModelFormField modelFormField = checkField.getModelFormField(); // never used: ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); buffer.append("<span"); String className = modelFormField.getWidgetStyle(); if (UtilValidate.isNotEmpty(className)) { buffer.append(" class=\""); buffer.append(className); buffer.append('"'); } buffer.append(">"); buffer.append("<input type=\""); buffer.append("checkbox"); buffer.append('"'); // if current value should be selected in the list, select it if ("Y".equals(currentValue) || "T".equals(currentValue)) { buffer.append(" checked=\"checked\""); } buffer.append(" name=\""); buffer.append(modelFormField.getParameterName(context)); buffer.append('"'); buffer.append(" value=\"Y\"/>"); // any description by it? buffer.append("</span>"); this.appendTooltip(buffer, context, modelFormField); this.appendWhitespace(buffer); } /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderRadioField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.RadioField) */ public void renderRadioField(StringBuffer buffer, Map context, RadioField radioField) { ModelFormField modelFormField = radioField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); List allOptionValues = radioField.getAllOptionValues(context, modelForm.getDelegator()); String currentValue = modelFormField.getEntry(context); String event = modelFormField.getEvent(); String action = modelFormField.getAction(); // list out all options according to the option list Iterator optionValueIter = allOptionValues.iterator(); while (optionValueIter.hasNext()) { ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next(); String className = modelFormField.getWidgetStyle(); buffer.append("<div"); if (UtilValidate.isNotEmpty(className)) { buffer.append(" class=\""); buffer.append(className); buffer.append('"'); } buffer.append(">"); buffer.append("<input type=\""); buffer.append("radio"); buffer.append('"'); // if current value should be selected in the list, select it String noCurrentSelectedKey = radioField.getNoCurrentSelectedKey(context); if (UtilValidate.isNotEmpty(currentValue) && currentValue.equals(optionValue.getKey())) { buffer.append(" checked=\"checked\""); } else if (UtilValidate.isEmpty(currentValue) && noCurrentSelectedKey != null && noCurrentSelectedKey.equals(optionValue.getKey())) { buffer.append(" checked=\"checked\""); } buffer.append(" name=\""); buffer.append(modelFormField.getParameterName(context)); buffer.append('"'); buffer.append(" value=\""); buffer.append(optionValue.getKey()); buffer.append("\""); if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) { buffer.append(" "); buffer.append(event); buffer.append("=\""); buffer.append(action); buffer.append('"'); } buffer.append("/>"); buffer.append(optionValue.getDescription()); buffer.append("</div>"); } this.appendTooltip(buffer, context, modelFormField); this.appendWhitespace(buffer); } /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderSubmitField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.SubmitField) */ public void renderSubmitField(StringBuffer buffer, Map context, SubmitField submitField) { ModelFormField modelFormField = submitField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); String singleClickAction = " onClick=\"javascript:submitFormDisableButton(this)\" "; if ("text-link".equals(submitField.getButtonType())) { buffer.append("<a"); String className = modelFormField.getWidgetStyle(); if (UtilValidate.isNotEmpty(className)) { buffer.append(" class=\""); buffer.append(className); buffer.append('"'); } buffer.append(" href=\"javascript:document."); buffer.append(modelForm.getCurrentFormName(context)); buffer.append(".submit()\">"); buffer.append(modelFormField.getTitle(context)); buffer.append("</a>"); } else if ("image".equals(submitField.getButtonType())) { buffer.append("<input type=\"image\""); String className = modelFormField.getWidgetStyle(); if (UtilValidate.isNotEmpty(className)) { buffer.append(" class=\""); buffer.append(className); buffer.append('"'); } buffer.append(" name=\""); buffer.append(modelFormField.getParameterName(context)); buffer.append('"'); String title = modelFormField.getTitle(context); if (UtilValidate.isNotEmpty(title)) { buffer.append(" alt=\""); buffer.append(title); buffer.append('"'); } buffer.append(" src=\""); this.appendContentUrl(buffer, submitField.getImageLocation()); buffer.append('"'); buffer.append(singleClickAction); buffer.append("/>"); } else { // default to "button" buffer.append("<input type=\"submit\""); String className = modelFormField.getWidgetStyle(); if (UtilValidate.isNotEmpty(className)) { buffer.append(" class=\""); buffer.append(className); buffer.append('"'); } buffer.append(" name=\""); buffer.append(modelFormField.getParameterName(context)); buffer.append('"'); String title = modelFormField.getTitle(context); if (UtilValidate.isNotEmpty(title)) { buffer.append(" value=\""); buffer.append(title); buffer.append('"'); } // add single click JS onclick buffer.append(singleClickAction); buffer.append("/>"); } this.appendTooltip(buffer, context, modelFormField); this.appendWhitespace(buffer); } /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderResetField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.ResetField) */ public void renderResetField(StringBuffer buffer, Map context, ResetField resetField) { ModelFormField modelFormField = resetField.getModelFormField(); buffer.append("<input type=\"reset\""); String className = modelFormField.getWidgetStyle(); if (UtilValidate.isNotEmpty(className)) { buffer.append(" class=\""); buffer.append(className); buffer.append('"'); } buffer.append(" name=\""); buffer.append(modelFormField.getParameterName(context)); buffer.append('"'); String title = modelFormField.getTitle(context); if (UtilValidate.isNotEmpty(title)) { buffer.append(" value=\""); buffer.append(title); buffer.append('"'); } buffer.append("/>"); this.appendTooltip(buffer, context, modelFormField); this.appendWhitespace(buffer); } /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderHiddenField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.HiddenField) */ public void renderHiddenField(StringBuffer buffer, Map context, HiddenField hiddenField) { ModelFormField modelFormField = hiddenField.getModelFormField(); String value = hiddenField.getValue(context); this.renderHiddenField(buffer, context, modelFormField, value); } public void renderHiddenField(StringBuffer buffer, Map context, ModelFormField modelFormField, String value) { buffer.append("<input type=\"hidden\""); buffer.append(" name=\""); buffer.append(modelFormField.getParameterName(context)); buffer.append('"'); if (UtilValidate.isNotEmpty(value)) { buffer.append(" value=\""); buffer.append(value); buffer.append('"'); } buffer.append("/>"); this.appendWhitespace(buffer); } /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderIgnoredField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.IgnoredField) */ public void renderIgnoredField(StringBuffer buffer, Map context, IgnoredField ignoredField) { // do nothing, it's an ignored field; could add a comment or something if we wanted to } /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderFieldTitle(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField) */ public void renderFieldTitle(StringBuffer buffer, Map context, ModelFormField modelFormField) { String tempTitleText = modelFormField.getTitle(context); String titleText = UtilHttp.encodeAmpersands(tempTitleText);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -