svn commit: r929173 - in /ofbiz/trunk/framework/widget: src/org/ofbiz/widget/form/ src/org/ofbiz/widget/html/ src/org/ofbiz/widget/menu/ templates/

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

svn commit: r929173 - in /ofbiz/trunk/framework/widget: src/org/ofbiz/widget/form/ src/org/ofbiz/widget/html/ src/org/ofbiz/widget/menu/ templates/

adrianc
Author: adrianc
Date: Tue Mar 30 15:35:28 2010
New Revision: 929173

URL: http://svn.apache.org/viewvc?rev=929173&view=rev
Log:
A patch from Blas Rodriguez Somoza:  XHTML validation errors (framework/widget) - (https://issues.apache.org/jira/browse/OFBIZ-3623).

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
    ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl

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=929173&r1=929172&r2=929173&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 15:35:28 2010
@@ -1928,9 +1928,9 @@ public class MacroFormRenderer implement
             if (lookupFieldFormName.indexOf('?') == -1) {
                 autoCompleterTarget = lookupFieldFormName + "?";
             } else {
-                autoCompleterTarget = lookupFieldFormName + "&";
+                autoCompleterTarget = lookupFieldFormName + "&";
             }
-            autoCompleterTarget = autoCompleterTarget + "ajaxLookup=Y&searchValueField=" + lookupField.getModelFormField().getParameterName(context);
+            autoCompleterTarget = autoCompleterTarget + "ajaxLookup=Y&searchValueField=" + lookupField.getModelFormField().getParameterName(context);
             updateAreas = FastList.newInstance();
             updateAreas.add(new ModelForm.UpdateArea("change", id, autoCompleterTarget));
         }
@@ -2690,6 +2690,9 @@ public class MacroFormRenderer implement
         String queryString = UtilHttp.stripNamedParamsFromQueryString(str, paramName);
         String urlPath = UtilHttp.removeQueryStringFromTarget(targetService);
         String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService);
+
+        queryString = UtilHttp.encodeAmpersands(queryString);
+
         if (prepLinkText == null) {
             prepLinkText = "";
         }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=929173&r1=929172&r2=929173&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Tue Mar 30 15:35:28 2010
@@ -173,16 +173,16 @@ public class HtmlFormRenderer extends Ht
         if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle()) || modelFormField.shouldBeRed(context)) {
             str.append("<span class=\"");
             str.append(modelFormField.getWidgetStyle());
+            // add a style of red if this is a date/time field and redWhen is true
+            if (modelFormField.shouldBeRed(context)) {
+             str.append(" alert");
+            }
             str.append('"');
             if (UtilValidate.isNotEmpty(idName)) {
                 str.append(" id=\"");
                 str.append(idName);
                 str.append('"');
             }
-            // add a style of red if this is a date/time field and redWhen is true
-            if (modelFormField.shouldBeRed(context)) {
-                str.append(" alert");
-            }
             str.append('>');
         }
 

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?rev=929173&r1=929172&r2=929173&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java Tue Mar 30 15:35:28 2010
@@ -262,29 +262,34 @@ public class HtmlMenuRenderer extends Ht
             writer.append("<h2>").append(menuTitle).append("</h2>");
             appendWhitespace(writer);
         }
-        writer.append("<ul>");
-        appendWhitespace(writer);
-        writer.append("<li>");
-        appendWhitespace(writer);
-        writer.append(" <ul>");
-        appendWhitespace(writer);
+        if (modelMenu.renderedMenuItemCount(context) > 0) {
+         writer.append("<ul>");
+         appendWhitespace(writer);
+         writer.append("<li>");
+         appendWhitespace(writer);
+         writer.append(" <ul>");
+         appendWhitespace(writer);
+        }
     }
 
     /* (non-Javadoc)
      * @see org.ofbiz.widget.menu.MenuStringRenderer#renderMenuClose(java.io.Writer, java.util.Map, org.ofbiz.widget.menu.ModelMenu)
      */
     public void renderMenuClose(Appendable writer, Map<String, Object> context, ModelMenu modelMenu) throws IOException {
+     // TODO: div can't be directly inside an UL
         String fillStyle = modelMenu.getFillStyle();
         if (UtilValidate.isNotEmpty(fillStyle)) {
             writer.append("<div class=\"").append(fillStyle).append("\">&nbsp;</div>");
         }
         //String menuContainerStyle = modelMenu.getMenuContainerStyle(context);
-        writer.append(" </ul>");
-        appendWhitespace(writer);
-        writer.append("</li>");
-        appendWhitespace(writer);
-        writer.append("</ul>");
-        appendWhitespace(writer);
+        if (modelMenu.renderedMenuItemCount(context) > 0) {      
+        writer.append(" </ul>");
+        appendWhitespace(writer);
+        writer.append("</li>");
+        appendWhitespace(writer);
+        writer.append("</ul>");
+        appendWhitespace(writer);
+        }
         writer.append(" <br class=\"clear\"/>");
         appendWhitespace(writer);
         writer.append("</div>");

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java?rev=929173&r1=929172&r2=929173&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java Tue Mar 30 15:35:28 2010
@@ -323,6 +323,16 @@ public class ModelMenu extends ModelWidg
             //Debug.logInfo("in ModelMenu, buffer:" + buffer.toString(), module);
     }
 
+    public int renderedMenuItemCount(Map<String, Object> context)
+    {
+        int count = 0;    
+        for (ModelMenuItem item : this.menuItemList) {
+            if (item.shouldBeRendered(context))
+             count++;        
+        }
+        return count;
+    }
+    
     public void renderSimpleMenuString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer) throws IOException {
         //Iterator menuItemIter = null;
         //Set alreadyRendered = new TreeSet();

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java?rev=929173&r1=929172&r2=929173&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java Tue Mar 30 15:35:28 2010
@@ -257,6 +257,16 @@ public class ModelMenuItem {
 
     }
 
+    public boolean shouldBeRendered(Map<String, Object> context) {
+        boolean passed = true;
+        if (this.condition != null) {
+            if (!this.condition.eval(context)) {
+                passed = false;
+            }
+        }
+        return passed;
+    }
+    
     public void renderMenuItemString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer) throws IOException {
 
         boolean passed = true;

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=929173&r1=929172&r2=929173&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Tue Mar 30 15:35:28 2010
@@ -330,7 +330,7 @@ ${item.description}</div>
 <#if opEquals?has_content>
 <select <#if name?has_content>name="${name}_op"</#if>    class="selectBox"><#rt/>
 <option value="equals"<#if defaultOption=="equals"> selected="selected"</#if>>${opEquals}</option><#rt/>
-<option value="like"<#if defaultOption=="like"> selected</#if>>${opBeginsWith}</option><#rt/>
+<option value="like"<#if defaultOption=="like"> selected="selected"</#if>>${opBeginsWith}</option><#rt/>
 <option value="contains"<#if defaultOption=="contains"> selected="selected"</#if>>${opContains}</option><#rt/>
 <option value="empty"<#rt/><#if defaultOption=="empty"> selected="selected"</#if>>${opIsEmpty}</option><#rt/>
 <option value="notEqual"<#if defaultOption=="notEqual"> selected="selected"</#if>>${opNotEqual}</option><#rt/>
@@ -449,7 +449,7 @@ ${item.description}</div>
  </#list>
 </#if>
 );">
-<#if ajaxEnabled?has_content && ajaxEnabled><span id="${id}_indicator" style="display: none" class="indicator"><img /></span></#if>
+<#if ajaxEnabled?has_content && ajaxEnabled><span id="${id}_indicator" style="display: none" class="indicator"><img src="" alt=""/></span></#if>
 </a></li><#rt>
 <#if disabled?has_content && disabled><li><a id="${id}_clear" style="background:none;margin-left:-6px;margin-right:15px;" class="clearField" href="javascript:void();" onclick="javascript:document.${formName}.${name}.value='';<#if descriptionFieldName?has_content>document.${formName}.${descriptionFieldName}.value='';</#if>">${clearText}</a></li></#if>
 </ul></div>

Modified: ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl?rev=929173&r1=929172&r2=929173&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlScreenMacroLibrary.ftl Tue Mar 30 15:35:28 2010
@@ -140,7 +140,7 @@ collapsed"><a <#if javaScriptEnabled>onc
 <#else>
 expanded"><a <#if javaScriptEnabled>onclick="javascript:toggleScreenlet(this, '${collapsibleAreaId}', '${saveCollapsed?string}', '${expandToolTip}', '${collapseToolTip}');"<#else>href="${fullUrlString}"</#if><#if expandToolTip?has_content> title="${expandToolTip}"</#if>
 </#if>
->&nbsp</a></li>
+>&nbsp;</a></li>
 </#if>
 <#if !collapsed>
 ${menuString}