A few enhancements, including some fixes and enhancements for the loopkup field type to support the sub-hyperlink which was already in the xsd, the asterisk for required fields, and the on event stuff for the ajax auto-complete and other such things; also changed all fields to have a default id with formName_fieldName so that it doesn't always have to be explicitly declared but also won't conflict form multiform screens
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@733486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1089,9 +1089,9 @@ under the License.
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute type="xs:double" name="frequency" default="0.4"/>
|
||||
<xs:attribute type="xs:positiveInteger" name="min-chars" default="1"/>
|
||||
<xs:attribute type="xs:positiveInteger" name="choices" default="10"/>
|
||||
<xs:attribute name="frequency" type="xs:double" default="0.4"/>
|
||||
<xs:attribute name="min-chars" type="xs:positiveInteger" default="1"/>
|
||||
<xs:attribute name="choices" type="xs:positiveInteger" default="10"/>
|
||||
<xs:attribute name="partial-search" default="true">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:token">
|
||||
@@ -1100,7 +1100,7 @@ under the License.
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute type="xs:positiveInteger" name="partial-chars" default="2"/>
|
||||
<xs:attribute name="partial-chars" type="xs:positiveInteger" default="1"/>
|
||||
<xs:attribute name="ignore-case" default="true">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:token">
|
||||
@@ -1109,7 +1109,7 @@ under the License.
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="full-search" default="false">
|
||||
<xs:attribute name="full-search" default="true">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:token">
|
||||
<xs:enumeration value="true"/>
|
||||
|
||||
@@ -1076,7 +1076,11 @@ public class ModelFormField {
|
||||
}
|
||||
|
||||
public String getIdName() {
|
||||
return idName;
|
||||
if (UtilValidate.isNotEmpty(idName)) {
|
||||
return idName;
|
||||
} else {
|
||||
return this.modelForm.getName() + "_" + this.getFieldName();
|
||||
}
|
||||
}
|
||||
|
||||
public String getHeaderLink() {
|
||||
@@ -3257,12 +3261,18 @@ public class ModelFormField {
|
||||
protected FlexibleStringExpander formName;
|
||||
protected String descriptionFieldName;
|
||||
protected String targetParameter;
|
||||
protected SubHyperlink subHyperlink;
|
||||
|
||||
public LookupField(Element element, ModelFormField modelFormField) {
|
||||
super(element, modelFormField);
|
||||
this.formName = FlexibleStringExpander.getInstance(element.getAttribute("target-form-name"));
|
||||
this.descriptionFieldName = element.getAttribute("description-field-name");
|
||||
this.targetParameter = element.getAttribute("target-parameter");
|
||||
|
||||
Element subHyperlinkElement = UtilXml.firstChildElement(element, "sub-hyperlink");
|
||||
if (subHyperlinkElement != null) {
|
||||
this.subHyperlink = new SubHyperlink(subHyperlinkElement);
|
||||
}
|
||||
}
|
||||
|
||||
public LookupField(int fieldSource, ModelFormField modelFormField) {
|
||||
@@ -3299,6 +3309,10 @@ public class ModelFormField {
|
||||
public void setDescriptionFieldName(String str) {
|
||||
this.descriptionFieldName = str;
|
||||
}
|
||||
|
||||
public SubHyperlink getSubHyperlink() {
|
||||
return this.subHyperlink;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FileField extends TextField {
|
||||
|
||||
@@ -711,7 +711,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
|
||||
ModelForm modelForm = modelFormField.getModelForm();
|
||||
ModelFormField.AutoComplete autoComplete = dropDownField.getAutoComplete();
|
||||
boolean ajaxEnabled = autoComplete != null && this.javaScriptEnabled;
|
||||
List allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator(context));
|
||||
List<ModelFormField.OptionValue> allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator(context));
|
||||
|
||||
String event = modelFormField.getEvent();
|
||||
String action = modelFormField.getAction(context);
|
||||
@@ -767,7 +767,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
|
||||
|
||||
if (UtilValidate.isNotEmpty(currentValue)) {
|
||||
writer.append(" value=\"");
|
||||
String explicitDescription = dropDownField.getCurrentDescription(context);
|
||||
//String explicitDescription = dropDownField.getCurrentDescription(context);
|
||||
writer.append(currentValue);
|
||||
writer.append('"');
|
||||
}
|
||||
@@ -778,20 +778,22 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
|
||||
writer.append("<script language=\"JavaScript\" type=\"text/javascript\">");
|
||||
appendWhitespace(writer);
|
||||
writer.append("var data = {");
|
||||
Iterator optionValueIter = allOptionValues.iterator();
|
||||
int count = 0;
|
||||
while (optionValueIter.hasNext()) {
|
||||
for (ModelFormField.OptionValue optionValue: allOptionValues) {
|
||||
count++;
|
||||
ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next();
|
||||
writer.append(""+optionValue.getKey()+": ");
|
||||
writer.append(" '"+optionValue.getDescription()+"'");
|
||||
writer.append("" + optionValue.getKey() + ": ");
|
||||
writer.append(" '" + optionValue.getDescription() + "'");
|
||||
if (count != allOptionValues.size()) {
|
||||
writer.append(", ");
|
||||
}
|
||||
}
|
||||
writer.append("};");
|
||||
appendWhitespace(writer);
|
||||
writer.append("ajaxAutoCompleteDropDown('"+textFieldIdName+"', '"+idName+"', data, {autoSelect: "+autoComplete.getAutoSelect()+", frequency: "+autoComplete.getFrequency()+", minChars: "+autoComplete.getMinChars()+", choices: "+autoComplete.getChoices()+", partialSearch: "+autoComplete.getPartialSearch()+", partialChars: "+autoComplete.getPartialChars()+", ignoreCase: "+autoComplete.getIgnoreCase()+", fullSearch: "+autoComplete.getFullSearch()+"});");
|
||||
writer.append("ajaxAutoCompleteDropDown('" + textFieldIdName + "', '" + idName + "', data, {autoSelect: " +
|
||||
autoComplete.getAutoSelect() + ", frequency: " + autoComplete.getFrequency() + ", minChars: " + autoComplete.getMinChars() +
|
||||
", choices: " + autoComplete.getChoices() + ", partialSearch: " + autoComplete.getPartialSearch() +
|
||||
", partialChars: " + autoComplete.getPartialChars() + ", ignoreCase: " + autoComplete.getIgnoreCase() +
|
||||
", fullSearch: " + autoComplete.getFullSearch() + "});");
|
||||
appendWhitespace(writer);
|
||||
writer.append("</script>");
|
||||
} else {
|
||||
@@ -2178,14 +2180,39 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
|
||||
writer.append('"');
|
||||
}
|
||||
|
||||
if (!lookupField.getClientAutocompleteField()) {
|
||||
String idName = modelFormField.getIdName();
|
||||
if (UtilValidate.isNotEmpty(idName)) {
|
||||
writer.append(" id=\"");
|
||||
writer.append(idName);
|
||||
writer.append('"');
|
||||
}
|
||||
|
||||
List<ModelForm.UpdateArea> updateAreas = modelFormField.getOnChangeUpdateAreas();
|
||||
boolean ajaxEnabled = updateAreas != null && this.javaScriptEnabled;
|
||||
if (!lookupField.getClientAutocompleteField() || ajaxEnabled) {
|
||||
writer.append(" autocomplete=\"off\"");
|
||||
}
|
||||
|
||||
writer.append("/>");
|
||||
|
||||
this.addAsterisks(writer, context, modelFormField);
|
||||
|
||||
this.makeHyperlinkString(writer, lookupField.getSubHyperlink(), context);
|
||||
|
||||
this.appendTooltip(writer, context, modelFormField);
|
||||
|
||||
if (ajaxEnabled) {
|
||||
appendWhitespace(writer);
|
||||
writer.append("<script language=\"JavaScript\" type=\"text/javascript\">");
|
||||
appendWhitespace(writer);
|
||||
writer.append("ajaxAutoCompleter('" + createAjaxParamsFromUpdateAreas(updateAreas, null, context) + "');");
|
||||
appendWhitespace(writer);
|
||||
writer.append("</script>");
|
||||
}
|
||||
appendWhitespace(writer);
|
||||
|
||||
String descriptionFieldName = lookupField.getDescriptionFieldName();
|
||||
// add lookup pop-up button
|
||||
String descriptionFieldName = lookupField.getDescriptionFieldName();
|
||||
if (UtilValidate.isNotEmpty(descriptionFieldName)) {
|
||||
writer.append("<a href=\"javascript:call_fieldlookup3(document.");
|
||||
writer.append(modelFormField.getModelForm().getCurrentFormName(context));
|
||||
|
||||
Reference in New Issue
Block a user