Author: erwan
Date: Thu Feb 11 09:27:01 2010
New Revision: 908894
URL: http://svn.apache.org/viewvc?rev=908894&view=rev
Log:
Adding a new field type in forms' display so we can display an image and keep a
list's consistency
Example :
<field name="displayProduct" use-when="!"foo".equals(productId)">
<hyperlink target="EditProduct" image-location="/images/next.gif"
also-hidden="false"/>
</field>
<field name="displayProduct" use-when=""Cap".equals(productId)">
<display type="image" image-location="/images/ofbiz.ico"/>
</field>
Modified:
ofbiz/trunk/framework/widget/dtd/widget-form.xsd
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=908894&r1=908893&r2=908894&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Thu Feb 11 09:27:01 2010
@@ -664,12 +664,18 @@
<xs:enumeration value="date-time">
<xs:annotation><xs:documentation>Display only the date
and hours:minutes part of a timestamp field</xs:documentation></xs:annotation>
</xs:enumeration>
+ <xs:enumeration value="image">
+ <xs:annotation><xs:documentation>Display the image
specified in image-location</xs:documentation></xs:annotation>
+ </xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute type="xs:string" name="currency">
<xs:annotation><xs:documentation>Specifies the currency uom ID
used to format context value, should generally use the ${} syntax to retrieve
value.</xs:documentation></xs:annotation>
</xs:attribute>
+ <xs:attribute type="xs:string" name="image-location">
+ <xs:annotation><xs:documentation>Specifies the image to
display.</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/MacroFormRenderer.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=908894&r1=908893&r2=908894&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
Thu Feb 11 09:27:01 2010
@@ -180,6 +180,8 @@
idName += "_" + modelForm.getRowCount();
}
String description = displayField.getDescription(context);
+ String type = displayField.getType();
+ String imageLocation = displayField.getImageLocation();
description = encode(description, modelFormField, context);
ModelFormField.InPlaceEditor inPlaceEditor =
displayField.getInPlaceEditor();
@@ -187,7 +189,11 @@
StringWriter sr = new StringWriter();
sr.append("<@renderDisplayField ");
- sr.append("idName=\"");
+ sr.append("type=\"");
+ sr.append(type);
+ sr.append("\" imageLocation=\"");
+ sr.append(imageLocation);
+ sr.append("\" idName=\"");
sr.append(idName);
sr.append("\" description=\"");
sr.append(description);
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=908894&r1=908893&r2=908894&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
Thu Feb 11 09:27:01 2010
@@ -2035,6 +2035,7 @@
protected boolean alsoHidden = true;
protected FlexibleStringExpander description;
protected String type; // matches type of field, currently text or
currency
+ protected String imageLocation;
protected FlexibleStringExpander currency;
protected FlexibleStringExpander date;
protected InPlaceEditor inPlaceEditor;
@@ -2054,6 +2055,7 @@
public DisplayField(Element element, ModelFormField modelFormField) {
super(element, modelFormField);
this.type = element.getAttribute("type");
+ this.imageLocation = element.getAttribute("image-location");
this.setCurrency(element.getAttribute("currency"));
this.setDescription(element.getAttribute("description"));
this.setDate(element.getAttribute("date"));
@@ -2073,6 +2075,13 @@
public boolean getAlsoHidden() {
return alsoHidden;
}
+ public String getType(){
+ return this.type;
+ }
+
+ public String getImageLocation(){
+ return this.imageLocation;
+ }
public String getDescription(Map<String, Object> context) {
String retVal = null;
Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=908894&r1=908893&r2=908894&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Thu Feb 11
09:27:01 2010
@@ -23,22 +23,27 @@
</#if>
</#macro>
-<#macro renderDisplayField idName description class alert inPlaceEditorUrl=""
inPlaceEditorParams="">
- <#if inPlaceEditorUrl?has_content || class?has_content || alert=="true">
- <span <#if idName?has_content>id="${idName}"</#if> <@renderClass class
alert />><#t/>
- </#if>
- <#if description?has_content>
- ${description?replace("\n", "<br/>")}<#t/>
+<#macro renderDisplayField type imageLocation idName description class alert
inPlaceEditorUrl="" inPlaceEditorParams="">
+ <#if type?has_content && type=="image">
+ <img src="${imageLocation}"><#lt/>
<#else>
- <#t/>
- </#if>
- <#if inPlaceEditorUrl?has_content || class?has_content || alert=="true">
- </span><#lt/>
- </#if>
- <#if inPlaceEditorUrl?has_content && idName?has_content>
- <script language="JavaScript" type="text/javascript"><#lt/>
- ajaxInPlaceEditDisplayField('${idName}', '${inPlaceEditorUrl}',
${inPlaceEditorParams});<#lt/>
- </script><#lt/>
+ <#if inPlaceEditorUrl?has_content || class?has_content ||
alert=="true">
+ <span <#if idName?has_content>id="${idName}"</#if> <@renderClass
class alert />><#t/>
+ </#if>
+
+ <#if description?has_content>
+ ${description?replace("\n", "<br/>")}<#t/>
+ <#else>
+ <#t/>
+ </#if>
+ <#if inPlaceEditorUrl?has_content || class?has_content ||
alert=="true">
+ </span><#lt/>
+ </#if>
+ <#if inPlaceEditorUrl?has_content && idName?has_content>
+ <script language="JavaScript" type="text/javascript"><#lt/>
+ ajaxInPlaceEditDisplayField('${idName}', '${inPlaceEditorUrl}',
${inPlaceEditorParams});<#lt/>
+ </script><#lt/>
+ </#if>
</#if>
</#macro>
<#macro renderHyperlinkField></#macro>