myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1416867 - in /myfaces/tobago/branches/tobago-1.5.x: tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/ tobago-example/tobago-example-test/src/main/webapp/tc/progress/ tobago-theme/tobago-theme-scarboro...
Date Tue, 04 Dec 2012 10:23:34 GMT
Author: lofwyr
Date: Tue Dec  4 10:23:34 2012
New Revision: 1416867

URL: http://svn.apache.org/viewvc?rev=1416867&view=rev
Log:
TOBAGO-1218: ArithmeticException: divide by zero
This happens when the range model has min == max

Added:
    myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress-tobago-1218.xhtml
      - copied, changed from r1412140, myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress.xhtml
Modified:
    myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Progress.java
    myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress.xhtml
    myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java

Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Progress.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Progress.java?rev=1416867&r1=1416866&r2=1416867&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Progress.java
(original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/Progress.java
Tue Dec  4 10:23:34 2012
@@ -30,12 +30,18 @@ public class Progress {
   private static final Logger LOG = LoggerFactory.getLogger(Progress.class);
 
   private BoundedRangeModel range;
+  private BoundedRangeModel emptyRange;
 
   public Progress() {
     this.range = new DefaultBoundedRangeModel(60, 0, 0, 100);
+    this.emptyRange = new DefaultBoundedRangeModel(0, 0, 0, 0);
   }
 
   public BoundedRangeModel getRange() {
     return range;
   }
+
+  public BoundedRangeModel getEmptyRange() {
+    return emptyRange;
+  }
 }

Copied: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress-tobago-1218.xhtml
(from r1412140, myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress-tobago-1218.xhtml?p2=myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress-tobago-1218.xhtml&p1=myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress.xhtml&r1=1412140&r2=1416867&rev=1416867&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress.xhtml
(original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress-tobago-1218.xhtml
Tue Dec  4 10:23:34 2012
@@ -18,8 +18,6 @@
 
 <f:view
     xmlns:tc="http://myfaces.apache.org/tobago/component"
-    xmlns:tx="http://myfaces.apache.org/tobago/extension"
-    xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:f="http://java.sun.com/jsf/core">
 
   <tc:page>
@@ -28,7 +26,7 @@
       <tc:gridLayout margin="20px" />
     </f:facet>
 
-    <tc:progress value="#{progress.range}"/>
+    <tc:progress value="#{progress.emptyRange}"/>
 
   </tc:page>
 </f:view>

Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress.xhtml?rev=1416867&r1=1416866&r2=1416867&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress.xhtml
(original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/progress/progress.xhtml
Tue Dec  4 10:23:34 2012
@@ -18,8 +18,6 @@
 
 <f:view
     xmlns:tc="http://myfaces.apache.org/tobago/component"
-    xmlns:tx="http://myfaces.apache.org/tobago/extension"
-    xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:f="http://java.sun.com/jsf/core">
 
   <tc:page>

Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java?rev=1416867&r1=1416866&r2=1416867&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ProgressRenderer.java
Tue Dec  4 10:23:34 2012
@@ -54,15 +54,15 @@ public class ProgressRenderer extends La
       model = new DefaultBoundedRangeModel(0, 1, 0, 100);
     }
 
+    final int diff = model.getMaximum() - model.getMinimum();
     Object title = progress.getAttributes().get(Attributes.TIP);
-    if (title == null) {
-      title = Integer.toString(100 * model.getValue()
-          / (model.getMaximum() - model.getMinimum())) + " %";
+    if (title == null && diff > 0) {
+      title = Integer.toString(100 * model.getValue() / diff) + " %";
     }
 
     final Style style = new Style(facesContext, progress);
     final Measure width = style.getWidth();
-    final Measure valueWidth = width.multiply(model.getValue()).divide(model.getMaximum()
- model.getMinimum());
+    final Measure valueWidth = diff > 0 ? width.multiply(model.getValue()).divide(diff)
: width;
 
     final Style valueStyle = new Style();
     valueStyle.setHeight(style.getHeight());
@@ -74,7 +74,9 @@ public class ProgressRenderer extends La
     writer.writeClassAttribute(Classes.create(progress));
     HtmlRendererUtils.writeDataAttributes(facesContext, writer, progress);
     writer.writeStyleAttribute(style);
-    writer.writeAttribute(HtmlAttributes.TITLE, String.valueOf(title), true);
+    if (title != null) {
+      writer.writeAttribute(HtmlAttributes.TITLE, String.valueOf(title), true);
+    }
 
     writer.startElement(HtmlElements.DIV, null);
     writer.writeClassAttribute(Classes.create(progress, "value"));



Mime
View raw message