You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by bu...@apache.org on 2010/09/03 21:55:08 UTC
svn commit: r992441 - in /ofbiz/trunk/framework/widget: dtd/widget-form.xsd
src/org/ofbiz/widget/form/ModelFormField.java
Author: buscob
Date: Fri Sep 3 19:55:08 2010
New Revision: 992441
URL: http://svn.apache.org/viewvc?rev=992441&view=rev
Log:
Added the "default-value" attribute to the "display" tag.
This allows to specify a string to be shown in a display field when it is empty.
Modified:
ofbiz/trunk/framework/widget/dtd/widget-form.xsd
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=992441&r1=992440&r2=992441&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Fri Sep 3 19:55:08 2010
@@ -688,6 +688,9 @@ under the License.
<xs:attribute type="xs:string" name="image-location">
<xs:annotation><xs:documentation>Specifies the image to display.</xs:documentation></xs:annotation>
</xs:attribute>
+ <xs:attribute type="xs:string" name="default-value">
+ <xs:annotation><xs:documentation>Specifies a string to be displayed if the field is empty.</xs:documentation></xs:annotation>
+ </xs:attribute>
</xs:attributeGroup>
<xs:element name="display-entity" substitutionGroup="AllFields">
<xs:annotation><xs:documentation>This is just like display but looks up a description using the Entity Engine; note that if also-hidden is true then it uses the key as the value, not the shown description.</xs:documentation></xs:annotation>
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=992441&r1=992440&r2=992441&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Fri Sep 3 19:55:08 2010
@@ -2052,6 +2052,7 @@ public class ModelFormField {
protected FlexibleStringExpander currency;
protected FlexibleStringExpander date;
protected InPlaceEditor inPlaceEditor;
+ protected FlexibleStringExpander defaultValue;
protected DisplayField() {
super();
@@ -2074,6 +2075,7 @@ public class ModelFormField {
this.setDescription(element.getAttribute("description"));
this.setDate(element.getAttribute("date"));
this.alsoHidden = !"false".equals(element.getAttribute("also-hidden"));
+ this.setDefaultValue(element.getAttribute("default-value"));
Element inPlaceEditorElement = UtilXml.firstChildElement(element, "in-place-editor");
if (inPlaceEditorElement != null) {
@@ -2118,7 +2120,7 @@ public class ModelFormField {
retVal = this.modelFormField.getEntry(context);
}
if (UtilValidate.isEmpty(retVal)) {
- retVal = "";
+ retVal = this.getDefaultValue(context);
} else if ("currency".equals(type)) {
retVal = retVal.replaceAll(" ", " "); // FIXME : encoding currency is a problem for some locale, we should not have any in retVal other case may arise in future...
Locale locale = (Locale) context.get("locale");
@@ -2192,6 +2194,21 @@ public class ModelFormField {
public void setInPlaceEditor(InPlaceEditor newInPlaceEditor) {
this.inPlaceEditor = newInPlaceEditor;
}
+
+ /**
+ * @param str
+ */
+ public void setDefaultValue(String str) {
+ this.defaultValue = FlexibleStringExpander.getInstance(str);
+ }
+
+ public String getDefaultValue(Map<String, Object> context) {
+ if (this.defaultValue != null) {
+ return this.defaultValue.expandString(context);
+ } else {
+ return "";
+ }
+ }
}
public static class DisplayEntityField extends DisplayField {