Author: andrei_exadel
Date: 2008-02-29 09:17:01 -0500 (Fri, 29 Feb 2008)
New Revision: 6453
Modified:
trunk/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java
Log:
some fixs
Modified: trunk/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java
===================================================================
---
trunk/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java 2008-02-29
13:59:55 UTC (rev 6452)
+++
trunk/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java 2008-02-29
14:17:01 UTC (rev 6453)
@@ -26,25 +26,28 @@
import org.ajax4jsf.javascript.JSLiteral;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.renderkit.AbstractProgressBarRenderer;
/**
- * TODO Class description goes here.
+ * Class provides base component class for progress bar
*
* @author "Andrey Markavtsov"
*
*/
-
// TODO add @since declaration
public abstract class UIProgressBar extends UIPoll {
+ /** Component type */
public static final String COMPONENT_TYPE = "org.richfaces.ProgressBar";
+ /** Component family */
public static final String COMPONENT_FAMILY = "org.richfaces.ProgressBar";
/** Request parameter name containing component state to render */
public static final String FORCE_PERCENT_PARAM = "forcePercent";
+ /** Percent param name */
private static final String PERCENT_PARAM = "percent";
/*
@@ -75,7 +78,7 @@
if (!params.containsKey(FORCE_PERCENT_PARAM)
&& params.containsKey(PERCENT_PARAM)) {
- Number value = getNumber(this.getAttributes().get("value"));
+ Number value =
getNumber(this.getAttributes().get(RendererUtils.HTML.value_ATTRIBUTE));
ajaxContext.removeRenderedArea(clientId);
ajaxContext
.setResponseData(getResponseData(value, facesContext));
@@ -110,11 +113,11 @@
.getRenderer(facesContext);
Map<Object, Object> map = new HashMap<Object, Object>();
- map.put("value", value);
+ map.put(RendererUtils.HTML.value_ATTRIBUTE, value);
map.put("interval", this.getInterval());
- if (this.getAttributes().get("style") != null) {
- map.put("style", this.getAttributes().get("style"));
+ if (this.getAttributes().get(RendererUtils.HTML.style_ATTRIBUTE) != null) {
+ map.put(RendererUtils.HTML.style_ATTRIBUTE,
this.getAttributes().get(RendererUtils.HTML.style_ATTRIBUTE));
}
boolean enabled = (Boolean) this.getAttributes().get("enabled");
@@ -145,13 +148,15 @@
private JSLiteral getContext(AbstractProgressBarRenderer renderer,
Number percent) {
StringBuffer buffer = new StringBuffer("{");
+ final String minValueAttr = "minValue";
+ final String maxValueAttr = "maxValue";
buffer.append("value:")
.append(ScriptUtils.toScript(percent.toString())).append(",");
buffer.append("minValue:").append(
- ScriptUtils.toScript(this.getAttributes().get("minValue")
+ ScriptUtils.toScript(this.getAttributes().get(minValueAttr)
.toString())).append(",");
buffer.append("maxValue:").append(
- ScriptUtils.toScript(this.getAttributes().get("maxValue")
+ ScriptUtils.toScript(this.getAttributes().get(maxValueAttr)
.toString()));
String parameters = renderer.getParameters(this);
@@ -210,8 +215,7 @@
/**
* Converts value attr to number value
*
- * @param v -
- * value attr
+ * @param v - value attr
* @return result
*/
public Number getNumber(Object v) {
@@ -222,15 +226,15 @@
result = Double.parseDouble((String) v);
} else {
Number n = (Number) v;
- if (n instanceof BigDecimal || n instanceof Double
- || n instanceof Float) {
+ if ((n instanceof BigDecimal) || (n instanceof Double)
+ || (n instanceof Float)) {
result = n.floatValue();
} else if (n instanceof Integer) {
result = n.intValue();
}
}
} catch (Exception e) {
- // TODO: handle exception
+ e.getMessage();
}
}
return result;