Author: nbelaevski
Date: 2010-11-29 15:14:12 -0500 (Mon, 29 Nov 2010)
New Revision: 20212
Modified:
trunk/examples/output-demo/src/main/java/org/richfaces/ProgressBarBean.java
trunk/examples/output-demo/src/main/webapp/examples/progressbar.xhtml
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarState.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarStateEncoder.java
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.ecss
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.js
trunk/ui/output/ui/src/main/templates/progressBar.template.xml
Log:
Small progress bar fixes:
- Incorrect state displayed when no 'initial' or 'finish' facet was
provided
- rf-pb class was not encoded
- Incorrect alignment in IE7
Modified: trunk/examples/output-demo/src/main/java/org/richfaces/ProgressBarBean.java
===================================================================
--- trunk/examples/output-demo/src/main/java/org/richfaces/ProgressBarBean.java 2010-11-29
18:38:41 UTC (rev 20211)
+++ trunk/examples/output-demo/src/main/java/org/richfaces/ProgressBarBean.java 2010-11-29
20:14:12 UTC (rev 20212)
@@ -31,7 +31,11 @@
private boolean childrenRendered = false;
private boolean enabled = false;
-
+
+ private boolean initialFacetRendered = true;
+
+ private boolean finishFacetRendered = true;
+
public boolean isEnabled() {
return enabled;
}
@@ -80,6 +84,22 @@
this.childrenRendered = childrenRendered;
}
+ public boolean isInitialFacetRendered() {
+ return initialFacetRendered;
+ }
+
+ public void setInitialFacetRendered(boolean renderInitialFacet) {
+ this.initialFacetRendered = renderInitialFacet;
+ }
+
+ public boolean isFinishFacetRendered() {
+ return finishFacetRendered;
+ }
+
+ public void setFinishFacetRendered(boolean renderFinishFacet) {
+ this.finishFacetRendered = renderFinishFacet;
+ }
+
public void decreaseValueByFive() {
value -= 5;
}
Modified: trunk/examples/output-demo/src/main/webapp/examples/progressbar.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/progressbar.xhtml 2010-11-29
18:38:41 UTC (rev 20211)
+++ trunk/examples/output-demo/src/main/webapp/examples/progressbar.xhtml 2010-11-29
20:14:12 UTC (rev 20212)
@@ -41,6 +41,14 @@
<br />
+ 'initial' facet rendered: <h:selectBooleanCheckbox
value="#{progressBarBean.initialFacetRendered}" onclick="submit()"
/>
+
+ <br />
+
+ 'finish' facet rendered: <h:selectBooleanCheckbox
value="#{progressBarBean.finishFacetRendered}" onclick="submit()"
/>
+
+ <br />
+
Enabled: <h:selectBooleanCheckbox value="#{progressBarBean.enabled}"
onclick="submit()" />
</h:form>
@@ -54,11 +62,15 @@
<h:outputText value="child + "
rendered="#{progressBarBean.childrenRendered}" />
<f:facet name="initial">
- <h:outputText value="In initial state" />
+ <h:panelGroup rendered="#{progressBarBean.initialFacetRendered}">
+ <h:outputText value="In initial state" />
+ </h:panelGroup>
</f:facet>
<f:facet name="finish">
- <h:outputText value="Finished progress" />
+ <h:panelGroup rendered="#{progressBarBean.finishFacetRendered}">
+ <h:outputText value="Finished progress" />
+ </h:panelGroup>
</f:facet>
</rich:progressBar>
@@ -78,11 +90,15 @@
<h:outputText value="child + "
rendered="#{progressBarBean.childrenRendered}" />
<f:facet name="initial">
- <h:outputText value="initial ~ #{progressBarBean.currentTimeAsString}"
/>
+ <h:panelGroup rendered="#{progressBarBean.initialFacetRendered}">
+ <h:outputText value="initial ~ #{progressBarBean.currentTimeAsString}"
/>
+ </h:panelGroup>
</f:facet>
<f:facet name="finish">
- <h:outputText value="finish ~ #{progressBarBean.currentTimeAsString}"
/>
+ <h:panelGroup rendered="#{progressBarBean.finishFacetRendered}">
+ <h:outputText value="finish ~ #{progressBarBean.currentTimeAsString}"
/>
+ </h:panelGroup>
</f:facet>
</rich:progressBar>
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java 2010-11-29
18:38:41 UTC (rev 20211)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java 2010-11-29
20:14:12 UTC (rev 20212)
@@ -107,13 +107,24 @@
Number minValue =
NumberUtils.getNumber(component.getAttributes().get("minValue"));
Number maxValue =
NumberUtils.getNumber(component.getAttributes().get("maxValue"));
Number value =
NumberUtils.getNumber(component.getAttributes().get("value"));
+
+ ProgressBarState result;
+
if (value.doubleValue() <= minValue.doubleValue()) {
- return ProgressBarState.initialState;
+ result = ProgressBarState.initialState;
} else if (value.doubleValue() > maxValue.doubleValue()) {
- return ProgressBarState.finishState;
+ result = ProgressBarState.finishState;
} else {
- return ProgressBarState.progressState;
+ result = ProgressBarState.progressState;
}
+
+ if (result == ProgressBarState.initialState || result ==
ProgressBarState.finishState) {
+ if (!result.hasContent(context, component)) {
+ result = ProgressBarState.progressState;
+ }
+ }
+
+ return result;
}
protected String getStateDisplayStyle(String currentState, String state) {
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarState.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarState.java 2010-11-29
18:38:41 UTC (rev 20211)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarState.java 2010-11-29
20:14:12 UTC (rev 20212)
@@ -43,13 +43,16 @@
@Override
public void encodeContent(FacesContext context, UIComponent component) throws
IOException {
- UIComponent facet = component.getFacet("initial");
- if (facet != null) {
- facet.encodeAll(context);
- }
+ component.getFacet("initial").encodeAll(context);
}
@Override
+ public boolean hasContent(FacesContext context, UIComponent component) {
+ UIComponent facet = component.getFacet("initial");
+ return facet != null && facet.isRendered();
+ }
+
+ @Override
public void encodeStateForMetaComponent(FacesContext context, UIComponent
component,
ProgressBarStateEncoder encoder) throws IOException {
@@ -87,6 +90,11 @@
}
@Override
+ public boolean hasContent(FacesContext context, UIComponent component) {
+ return true;
+ }
+
+ @Override
public void encodeStateForMetaComponent(FacesContext context, UIComponent
component,
ProgressBarStateEncoder encoder) throws IOException {
@@ -114,6 +122,12 @@
}
@Override
+ public boolean hasContent(FacesContext context, UIComponent component) {
+ UIComponent facet = component.getFacet("finish");
+ return facet != null && facet.isRendered();
+ }
+
+ @Override
public void encodeStateForMetaComponent(FacesContext context, UIComponent
component,
ProgressBarStateEncoder encoder) throws IOException {
@@ -127,5 +141,7 @@
public abstract void encodeContent(FacesContext context, UIComponent component)
throws IOException;
+ public abstract boolean hasContent(FacesContext context, UIComponent component);
+
public abstract void encodeStateForMetaComponent(FacesContext context, UIComponent
component, ProgressBarStateEncoder encoder) throws IOException;
}
\ No newline at end of file
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarStateEncoder.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarStateEncoder.java 2010-11-29
18:38:41 UTC (rev 20211)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarStateEncoder.java 2010-11-29
20:14:12 UTC (rev 20212)
@@ -50,6 +50,11 @@
private void encodeStateFacet(FacesContext context, UIComponent component,
ProgressBarState state,
ProgressBarState currentState) throws IOException {
+
+ if (!state.hasContent(context, component)) {
+ return;
+ }
+
String clientId = state.getStateClientId(context, component);
ResponseWriter responseWriter = context.getResponseWriter();
@@ -103,6 +108,11 @@
public void encodeProgressStateContent(FacesContext context, UIComponent component,
ProgressBarState currentState)
throws IOException {
+
+ if (!ProgressBarState.progressState.hasContent(context, component)) {
+ return;
+ }
+
ResponseWriter responseWriter = context.getResponseWriter();
String stateClientId = ProgressBarState.progressState.getStateClientId(context,
component);
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.ecss
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.ecss 2010-11-29
18:38:41 UTC (rev 20211)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.ecss 2010-11-29
20:14:12 UTC (rev 20212)
@@ -15,7 +15,6 @@
font-size: '#{richSkin.generalSizeFont}';
font-weight: bold;
- text-align: center;
text-color: '#{richSkin.controlTextColor}';
background-color: '#{richSkin.controlBackgroundColor}';
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.js 2010-11-29
18:38:41 UTC (rev 20211)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.js 2010-11-29
20:14:12 UTC (rev 20212)
@@ -110,6 +110,11 @@
__showState: function (state) {
var stateElt = $(stateSelectors[state], this.__elt);
+
+ if (stateElt.length == 0 && (state == 'initial' || state ==
'finish')) {
+ stateElt = $(stateSelectors['progress'], this.__elt)
+ }
+
stateElt.show().siblings().hide();
},
@@ -125,19 +130,24 @@
if (this.__isInitialState()) {
this.__showState("initial");
} else if (this.__isFinishState()) {
- rf.Event.callHandler(this.__elt, "finish");
this.__showState("finish");
} else {
this.__showState("progress");
-
- var p = this.__calculatePercent(this.value);
- $(".rf-pb-prgs", this.__elt).css('width', p + "%");
}
+
+ var p = this.__calculatePercent(this.value);
+ $(".rf-pb-prgs", this.__elt).css('width', p + "%");
},
setValue: function(val) {
+ var wasInFinishState = this.__isFinishState();
+
this.__setValue(val);
this.__updateVisualState();
+
+ if (!wasInFinishState && this.__isFinishState()) {
+ rf.Event.callHandler(this.__elt, "finish");
+ }
},
getMaxValue: function() {
Modified: trunk/ui/output/ui/src/main/templates/progressBar.template.xml
===================================================================
--- trunk/ui/output/ui/src/main/templates/progressBar.template.xml 2010-11-29 18:38:41 UTC
(rev 20211)
+++ trunk/ui/output/ui/src/main/templates/progressBar.template.xml 2010-11-29 20:14:12 UTC
(rev 20212)
@@ -16,7 +16,7 @@
<cc:implementation>
- <div id="#{clientId}" cdk:passThroughWithExclusions="">
+ <div id="#{clientId}" cdk:passThroughWithExclusions=""
class="#{concatClasses('rf-pb',
component.attributes['styleClass'])}">
<cdk:object name="encoder"
value="#{getEncoder(facesContext, component)}"
type="ProgressBarStateEncoder" />
<cdk:object name="currentState"
value="#{getCurrentState(facesContext, component)}"
type="ProgressBarState" />