svn commit: r929157 - in /ofbiz/trunk/framework/widget: dtd/ src/org/ofbiz/widget/form/ templates/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r929157 - in /ofbiz/trunk/framework/widget: dtd/ src/org/ofbiz/widget/form/ templates/

erwan
Author: erwan
Date: Tue Mar 30 14:45:45 2010
New Revision: 929157

URL: http://svn.apache.org/viewvc?rev=929157&view=rev
Log:
Adding title for images in hyperlink field or in a field displaying an image. Use the description if exists otherwise takes the title.

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/csvFormMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.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=929157&r1=929156&r2=929157&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Tue Mar 30 14:45:45 2010
@@ -839,6 +839,9 @@ under the License.
         <xs:attribute type="xs:string" name="alternate">
             <xs:annotation><xs:documentation>Alternate text if the image is not found at image-location</xs:documentation></xs:annotation>
         </xs:attribute>
+        <xs:attribute type="xs:string" name="image-title">
+            <xs:annotation><xs:documentation>Use as a title for the HTML img tag</xs:documentation></xs:annotation>
+        </xs:attribute>
         <xs:attribute type="xs:string" name="image-location"/>
         <xs:attribute name="request-confirmation" default="false">
             <xs:annotation><xs:documentation>If true then the user is presented with a dialog box, if confirmation-message is empty, use default</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=929157&r1=929156&r2=929157&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 Tue Mar 30 14:45:45 2010
@@ -333,7 +333,9 @@ public class MacroFormRenderer implement
         ModelFormField modelFormField = hyperlinkField.getModelFormField();
 
         String encodedAlternate = encode(hyperlinkField.getAlternate(context), modelFormField, context);
+        String encodedImageTitle = encode(hyperlinkField.getImageTitle(context), modelFormField, context);
         this.request.setAttribute("alternate", encodedAlternate);
+        this.request.setAttribute("imageTitle", encodedImageTitle);
         makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), hyperlinkField.getTargetType(), hyperlinkField.getTarget(context),
                 hyperlinkField.getParameterList(), hyperlinkField.getDescription(context), hyperlinkField.getTargetWindow(context), hyperlinkField.getConfirmation(context), modelFormField,
                 this.request, this.response, context);
@@ -2433,6 +2435,7 @@ public class MacroFormRenderer implement
     public void renderImageField(Appendable writer, Map<String, Object> context, ImageField imageField) throws IOException {
         ModelFormField modelFormField = imageField.getModelFormField();
 
+        String border = Integer.toString(imageField.getBorder());
         String value = modelFormField.getEntry(context, imageField.getValue(context));
         String width = "";
         String height = "";
@@ -2442,6 +2445,9 @@ public class MacroFormRenderer implement
         if(UtilValidate.isEmpty(description)){
             description = imageField.getModelFormField().getTitle(context);
         }
+        if(UtilValidate.isEmpty(alternate)){
+            alternate = description;
+        }
         if (UtilValidate.isNotEmpty(value)) {
             StringBuilder buffer = new StringBuilder();
             ContentUrlTag.appendContentPrefix(request, buffer);
@@ -2469,9 +2475,9 @@ public class MacroFormRenderer implement
         sr.append("\" description=\"");
         sr.append(encode(description, modelFormField, context));
         sr.append("\" alternate=\"");
-        sr.append(alternate);
-        sr.append("\" border=\"");
         sr.append(encode(alternate, modelFormField, context));
+        sr.append("\" border=\"");
+        sr.append(border);
         sr.append("\" width=\"");
         sr.append(width);
         sr.append("\" height=\"");
@@ -2854,6 +2860,7 @@ public class MacroFormRenderer implement
             String action = "";
             String imgSrc = "";
             String alt = "";
+            String imgTitle = "";
             String hiddenFormName = WidgetWorker.makeLinkHiddenFormName(context, modelFormField);
 
             if (UtilValidate.isNotEmpty(modelFormField.getEvent()) && UtilValidate.isNotEmpty(modelFormField.getAction(context))) {
@@ -2863,7 +2870,11 @@ public class MacroFormRenderer implement
 
             if (UtilValidate.isNotEmpty(request.getAttribute("image"))) {
                 imgSrc = request.getAttribute("image").toString();
-                alt = request.getAttribute("alternate").toString();
+            }
+            alt = request.getAttribute("alternate").toString();
+            imgTitle = request.getAttribute("imageTitle").toString();
+            if(UtilValidate.isEmpty(imgTitle)){
+                imgTitle = modelFormField.getTitle(context);
             }
 
             StringWriter sr = new StringWriter();
@@ -2878,6 +2889,8 @@ public class MacroFormRenderer implement
             sr.append(action);
             sr.append("\" imgSrc=\"");
             sr.append(imgSrc);
+            sr.append("\" title=\"");
+            sr.append(imgTitle);
             sr.append("\" alternate=\"");
             sr.append(alt);
             sr.append("\" linkUrl=\"");

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=929157&r1=929156&r2=929157&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 Tue Mar 30 14:45:45 2010
@@ -2252,6 +2252,7 @@ public class ModelFormField {
         protected FlexibleStringExpander target;
         protected FlexibleStringExpander description;
         protected FlexibleStringExpander alternate;
+        protected FlexibleStringExpander imageTitle;
         protected FlexibleStringExpander targetWindowExdr;
         protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance();
 
@@ -2274,6 +2275,7 @@ public class ModelFormField {
 
             this.setDescription(element.getAttribute("description"));
             this.setAlternate(element.getAttribute("alternate"));
+            this.setImageTitle(element.getAttribute("image-title"));
             this.setTarget(element.getAttribute("target"));
             this.alsoHidden = !"false".equals(element.getAttribute("also-hidden"));
             this.linkType = element.getAttribute("link-type");
@@ -2343,6 +2345,10 @@ public class ModelFormField {
             return this.alternate.expandString(context);
         }
 
+        public String getImageTitle(Map<String, Object> context) {
+            return this.imageTitle.expandString(context);
+        }
+
         public String getTarget(Map<String, Object> context) {
             return this.target.expandString(context);
         }
@@ -2379,6 +2385,13 @@ public class ModelFormField {
         /**
          * @param string
          */
+        public void setImageTitle(String string) {
+            this.imageTitle = FlexibleStringExpander.getInstance(string);
+        }
+
+        /**
+         * @param string
+         */
         public void setAlternate(String string) {
             this.alternate = FlexibleStringExpander.getInstance(string);
         }

Modified: ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl?rev=929157&r1=929156&r2=929157&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl Tue Mar 30 14:45:45 2010
@@ -116,4 +116,4 @@ under the License.
 <#macro renderSortField style title linkUrl ajaxEnabled><@renderFieldTitle style title /></#macro>
 <#macro formatBoundaryComment boundaryType widgetType widgetName></#macro>
 <#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description><@renderField description /></#macro>
-<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc alternate linkUrl targetWindow description confirmation><@renderField description /></#macro>
+<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc title alternate linkUrl targetWindow description confirmation><@renderField description /></#macro>

Modified: ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl?rev=929157&r1=929156&r2=929157&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl Tue Mar 30 14:45:45 2010
@@ -135,6 +135,6 @@ under the License.
 <#macro renderSortField style title linkUrl ajaxEnabled><@renderFieldTitle style title /></#macro>
 <#macro formatBoundaryComment boundaryType widgetType widgetName></#macro>
 <#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description><@renderField description /></#macro>
-<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc alternate linkUrl targetWindow description confirmation><@makeBlock linkStyle description /></#macro>
+<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc title alternate linkUrl targetWindow description confirmation><@makeBlock linkStyle description /></#macro>
 <#macro renderTooltip tooltip tooltipStyle></#macro>
 <#macro renderAsterisks requiredField requiredStyle></#macro>

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=929157&r1=929156&r2=929157&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Tue Mar 30 14:45:45 2010
@@ -527,4 +527,4 @@ ${item.description}</div>
 
 <#macro makeHiddenFormLinkForm actionUrl name parameters targetWindow><form method="post" action="${actionUrl}" <#if targetWindow?has_content>target="${targetWindow}"</#if> onsubmit="javascript:submitFormDisableSubmits(this)" name="${name}"><#list parameters as parameter><input name="${parameter.name}" value="${parameter.value}" type="hidden"/></#list></form></#macro>
 <#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description confirmation><a <#if linkStyle?has_content>class="${linkStyle}"</#if> href="javascript:document.${hiddenFormName}.submit()"<#if action?has_content && event?has_content> ${event}="${action}"</#if><#if confirmation?has_content> onclick="return confirm('${confirmation?js_string}')"</#if>><#if imgSrc?has_content><img src="${imgSrc}"/></#if>${description}</a></#macro>
-<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc alternate linkUrl targetWindow description confirmation><a <#if linkStyle?has_content>class="${linkStyle}"</#if> href="${linkUrl}"<#if targetWindow?has_content> target="${targetWindow}"</#if><#if action?has_content && event?has_content> ${event}="${action}"</#if><#if confirmation?has_content> onclick="return confirm('${confirmation?js_string}')"</#if>><#if imgSrc?has_content><img src="${imgSrc}" alt="${alternate}"/></#if>${description}</a></#macro>
+<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc title alternate linkUrl targetWindow description confirmation><a <#if linkStyle?has_content>class="${linkStyle}"</#if> href="${linkUrl}"<#if targetWindow?has_content> target="${targetWindow}"</#if><#if action?has_content && event?has_content> ${event}="${action}"</#if><#if confirmation?has_content> onclick="return confirm('${confirmation?js_string}')"</#if>><#if imgSrc?has_content><img src="${imgSrc}" alt="${alternate}" title="${title}"/></#if>${description}</a></#macro>

Modified: ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl?rev=929157&r1=929156&r2=929157&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl Tue Mar 30 14:45:45 2010
@@ -109,6 +109,6 @@ under the License.
 <#macro renderSortField style title linkUrl ajaxEnabled></#macro>
 <#macro formatBoundaryComment boundaryType widgetType widgetName></#macro>
 <#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description><@renderField description /></#macro>
-<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc alternate linkUrl targetWindow description confirmation><@renderField description /></#macro>
+<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc title alternate linkUrl targetWindow description confirmation><@renderField description /></#macro>
 <#macro renderTooltip tooltip tooltipStyle></#macro>
 <#macro renderAsterisks requiredField requiredStyle></#macro>