Author: Alex.Kolonitsky
Date: 2009-12-04 15:54:42 -0500 (Fri, 04 Dec 2009)
New Revision: 16074
Modified:
root/examples/trunk/richfaces-demo/src/main/java/org/richfaces/demo/push/ChoicesBean.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java
Log:
RFPL-195 - Code style policy
Reformatting
Modified:
root/examples/trunk/richfaces-demo/src/main/java/org/richfaces/demo/push/ChoicesBean.java
===================================================================
---
root/examples/trunk/richfaces-demo/src/main/java/org/richfaces/demo/push/ChoicesBean.java 2009-12-04
20:53:17 UTC (rev 16073)
+++
root/examples/trunk/richfaces-demo/src/main/java/org/richfaces/demo/push/ChoicesBean.java 2009-12-04
20:54:42 UTC (rev 16074)
@@ -15,10 +15,11 @@
@ManagedBean(name = "choicesBean")
@SessionScoped
public class ChoicesBean implements Runnable {
+ PushEventListener listener;
+
private boolean enabled = false;
private List<Choice> choices;
private List<Choice> lastVotes;
- PushEventListener listener;
private Date startDate;
private Thread thread;
private String updateInfo;
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-12-04
20:53:17 UTC (rev 16073)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2009-12-04
20:54:42 UTC (rev 16074)
@@ -111,26 +111,26 @@
}
public void setData(Object data) {
- this.data = data;
- clearInitialState();
+ this.data = data;
+ clearInitialState();
}
-
+
public Object getData() {
- if (this.data != null) {
- return this.data;
- }
-
- ValueExpression ve = getValueExpression(Attributes.data.toString());
-
- if (ve != null) {
+ if (this.data != null) {
+ return this.data;
+ }
+
+ ValueExpression ve = getValueExpression(Attributes.data.toString());
+
+ if (ve != null) {
ELContext elContext = FacesContext.getCurrentInstance().getELContext();
return ve.getValue(elContext);
- }
-
- return this.data;
+ }
+
+ return this.data;
}
-
+
@Override
public void setRender(Collection<String> render) {
this.render = asSet(render);
@@ -266,47 +266,47 @@
Object value = getExpressionLiteralValue(expression);
switch (Attributes.toAttribute(name)) {
- case limitRender :
+ case limitRender:
this.limitRender = value != null ? (Boolean) value : Boolean.FALSE;
break;
- case execute :
+ case execute:
this.execute = value != null ? asSet(value) : null;
break;
- case render :
+ case render:
this.render = value != null ? asSet(value) : null;
break;
- case queueId :
+ case queueId:
this.queueId = value != null ? (String) value : null;
break;
- case status :
+ case status:
this.statusId = value != null ? (String) value : null;
break;
- case similarityGroupingId :
+ case similarityGroupingId:
this.similarityGroupingId = value != null ? (String) value : null;
break;
- case onbeforedomupdate :
+ case onbeforedomupdate:
this.onbeforedomupdate = value != null ? (String) value : null;
break;
- case onbegin :
+ case onbegin:
this.onbegin = value != null ? (String) value : null;
break;
- case oncomplete :
+ case oncomplete:
this.oncomplete = value != null ? (String) value : null;
break;
@@ -316,7 +316,7 @@
break;
- default :
+ default:
break;
}
}
@@ -337,7 +337,7 @@
if (superState == null) {
values = null;
} else {
- values = new Object[] {superState};
+ values = new Object[]{superState};
}
} else {
values = new Object[11];
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2009-12-04
20:53:17 UTC (rev 16073)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2009-12-04
20:54:42 UTC (rev 16074)
@@ -34,116 +34,124 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIAjaxOutputPanel;
-
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:27 $
- *
*/
public class AjaxOutputPanelRenderer extends RendererBase {
-
- private final String[] STYLE_ATTRIBUTES = new
String[]{"style","class"};
- private boolean hasNoneLayout(UIComponent component) {
- //TODO - A1 won't support 'none' layout
- return
false;//"none".equals(component.getAttributes().get("layout"));
- }
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
- //
- UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
- if (hasNoneLayout(panel)) {
- if (component.getChildCount() > 0) {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- boolean ajaxRequest = ajaxContext.isAjaxRequest();
- Set<String> ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
- for (UIComponent child : component.getChildren()) {
- String childId = child.getClientId(context);
- if (child.isRendered()) {
- renderChild(context, child);
- } else {
- // Render "dummy" span.
- ResponseWriter out = context.getResponseWriter();
- out.startElement(HTML.SPAN_ELEM,child);
- out.writeAttribute(HTML.ID_ATTRIBUTE, childId,HTML.ID_ATTRIBUTE);
- out.writeAttribute(HTML.STYLE_ATTRIBUTE, "display:
none;","style");
- out.endElement(HTML.SPAN_ELEM);
- }
- // register child as rendered
- if(ajaxRequest && null != ajaxRenderedAreas) {
- ajaxRenderedAreas.add(childId);
- }
- }
- }
- } else {
- renderChildren(context,component);
- }
- }
+ private static final String[] STYLE_ATTRIBUTES = new String[]{"style",
"class"};
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#getRendersChildren()
- */
- public boolean getRendersChildren() {
- return true;
- }
+ private boolean hasNoneLayout(UIComponent component) {
+ //TODO - A1 won't support 'none' layout
+ return false;
//"none".equals(component.getAttributes().get("layout"));
+ }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class<? extends UIComponent> getComponentClass() {
- return UIAjaxOutputPanel.class;
- }
+ /* (non-Javadoc)
+ * @see
javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ @Override
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ //
+ UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
+ if (hasNoneLayout(panel)) {
+ if (component.getChildCount() > 0) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ boolean ajaxRequest = ajaxContext.isAjaxRequest();
+ Set<String> ajaxRenderedAreas =
ajaxContext.getAjaxRenderedAreas();
+ for (UIComponent child : component.getChildren()) {
+ String childId = child.getClientId(context);
+ if (child.isRendered()) {
+ renderChild(context, child);
+ } else {
+ // Render "dummy" span.
+ ResponseWriter out = context.getResponseWriter();
+ out.startElement(HTML.SPAN_ELEM, child);
+ out.writeAttribute(HTML.ID_ATTRIBUTE, childId,
HTML.ID_ATTRIBUTE);
+ out.writeAttribute(HTML.STYLE_ATTRIBUTE, "display:
none;", "style");
+ out.endElement(HTML.SPAN_ELEM);
+ }
+ // register child as rendered
+ if (ajaxRequest && null != ajaxRenderedAreas) {
+ ajaxRenderedAreas.add(childId);
+ }
+ }
+ }
+ } else {
+ renderChildren(context, component);
+ }
+ }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
- if (!hasNoneLayout(component)) {
- writer.startElement(getTag(panel), panel);
- getUtils().encodeId(context, component);
- getUtils().encodePassThru(context, component, null);
- getUtils().encodeAttributesFromArray(context,component,STYLE_ATTRIBUTES);
- }
- }
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#getRendersChildren()
+ */
+ @Override
+ public boolean getRendersChildren() {
+ return true;
+ }
- /**
- * @param panel
- * @return
- */
- private String getTag(UIAjaxOutputPanel panel) {
- Object layout = panel.getAttributes().get("layout");
- return "block".equals(layout) ? HTML.DIV_ELEM : HTML.SPAN_ELEM;
- }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIAjaxOutputPanel.class;
+ }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
- if (!hasNoneLayout(component)) {
- writer.endElement(getTag(panel));
- }
- if (panel.isKeepTransient()) {
- markNoTransient(component);
- }
- }
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ @Override
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component)
+ throws IOException {
- /**
- * Set "transient" flag to false for component and all its children (
recursive ).
- * @param component
- */
- private void markNoTransient(UIComponent component) {
- for (Iterator<UIComponent> iter = component.getFacetsAndChildren();
iter.hasNext();) {
- UIComponent element = iter.next();
- markNoTransient(element);
- element.setTransient(false);
- }
-
- }
+ UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
+ if (!hasNoneLayout(component)) {
+ writer.startElement(getTag(panel), panel);
+ getUtils().encodeId(context, component);
+ getUtils().encodePassThru(context, component, null);
+ getUtils().encodeAttributesFromArray(context, component, STYLE_ATTRIBUTES);
+ }
+ }
-
+ /**
+ * @param panel
+ * @return
+ */
+ private String getTag(UIAjaxOutputPanel panel) {
+ Object layout = panel.getAttributes().get("layout");
+ return "block".equals(layout) ? HTML.DIV_ELEM : HTML.SPAN_ELEM;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ @Override
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIAjaxOutputPanel panel = (UIAjaxOutputPanel) component;
+ if (!hasNoneLayout(component)) {
+ writer.endElement(getTag(panel));
+ }
+ if (panel.isKeepTransient()) {
+ markNoTransient(component);
+ }
+ }
+
+ /**
+ * Set "transient" flag to false for component and all its children (
recursive ).
+ *
+ * @param component
+ */
+ private void markNoTransient(UIComponent component) {
+ for (Iterator<UIComponent> iter = component.getFacetsAndChildren();
iter.hasNext();) {
+ UIComponent element = iter.next();
+ markNoTransient(element);
+ element.setTransient(false);
+ }
+
+ }
+
}
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2009-12-04
20:53:17 UTC (rev 16073)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2009-12-04
20:54:42 UTC (rev 16074)
@@ -21,17 +21,6 @@
package org.richfaces.renderkit.html;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.event.ActionEvent;
-
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
@@ -44,116 +33,127 @@
import org.richfaces.component.html.HtmlPush;
import org.richfaces.resource.PushResource;
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author shura
- *
*/
@ResourceDependencies(value = {
- @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js")
-})
+ @ResourceDependency(library = "javax.faces", name =
"jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js")
+ })
public class AjaxPushRenderer extends RendererBase {
- public static final String PUSH_INTERVAL_PARAMETER =
"A4J.AJAX.Push.INTERVAL";
+ public static final String PUSH_INTERVAL_PARAMETER =
"A4J.AJAX.Push.INTERVAL";
- public static final String PUSH_WAIT_PARAMETER = "A4J.AJAX.Push.WAIT";
+ public static final String PUSH_WAIT_PARAMETER = "A4J.AJAX.Push.WAIT";
- @Deprecated
- public static final String PUSH_URL_PARAMETER = "A4J.AJAX.Push.URL";
+ @Deprecated
+ public static final String PUSH_URL_PARAMETER = "A4J.AJAX.Push.URL";
- public static final int DEFAULT_PUSH_INTERVAL = 1000;
+ public static final int DEFAULT_PUSH_INTERVAL = 1000;
- public static final int DEFAULT_PUSH_WAIT = Integer.MIN_VALUE;
+ public static final int DEFAULT_PUSH_WAIT = Integer.MIN_VALUE;
- private static final String AJAX_PUSH_FUNCTION = "A4J.AJAX.Push";
+ private static final String AJAX_PUSH_FUNCTION = "A4J.AJAX.Push";
- /* (non-Javadoc)
- * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
- UIPush push = (UIPush) component;
- writer.startElement(HTML.SPAN_ELEM, component);
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "display:none;", null);
- getUtils().encodeId(context, component);
-
- //TODO - ?
- getUtils().encodeBeginFormIfNessesary(context, component);
- // pushing script.
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- StringBuffer script = new StringBuffer("\n");
- if (push.isEnabled()) {
- JSFunction function = new JSFunction("RichFaces.startPush");
- // Set dummy form id, if nessesary.
- Map<String, Object> options = new HashMap<String, Object>();
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIPush push = (UIPush) component;
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "display:none;", null);
+ getUtils().encodeId(context, component);
- int interval = push.getInterval();
- if (!getUtils().shouldRenderAttribute(interval)) {
- String intervalInitParameter =
context.getExternalContext().getInitParameter(PUSH_INTERVAL_PARAMETER);
- if(null != intervalInitParameter){
- interval = Integer.parseInt(intervalInitParameter);
- } else {
- interval = DEFAULT_PUSH_INTERVAL;
- }
- }
+ //TODO - ?
+ getUtils().encodeBeginFormIfNessesary(context, component);
+ // pushing script.
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ StringBuffer script = new StringBuffer("\n");
+ if (push.isEnabled()) {
+ JSFunction function = new JSFunction("RichFaces.startPush");
+ // Set dummy form id, if nessesary.
+ Map<String, Object> options = new HashMap<String, Object>();
- options.put("interval", new Integer(interval));
- options.put("pushResourceUrl", new PushResource().getRequestPath());
- options.put("pushId", push.getListenerId(context));
- options.put("clientId", component.getClientId(context));
-
- HandlersChain handlersChain = new HandlersChain(push);
- handlersChain.addInlineHandlerFromAttribute(context, HtmlPush.ON_DATA_AVAILABLE);
- handlersChain.addBehaviors(context, HtmlPush.DATA_AVAILABLE);
-
- if (!handlersChain.hasSubmittingBehavior()) {
- JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(context, push,
AjaxRendererUtils.AJAX_FUNCTION_NAME);
- AjaxEventOptions eventOptions = AjaxRendererUtils.buildEventOptions(context, push);
- if (!eventOptions.isEmpty()) {
- ajaxFunction.addParameter(eventOptions);
- }
- handlersChain.addInlineHandlerAsValue(context, ajaxFunction.toScript());
- }
-
- String handler = handlersChain.toScript();
-
- if (handler != null) {
- JSFunctionDefinition dataAvailableHandler = new
JSFunctionDefinition(JSReference.EVENT);
- dataAvailableHandler.addToBody(handler);
- options.put(HtmlPush.ON_DATA_AVAILABLE, dataAvailableHandler);
- }
- function.addParameter(options);
- script.append(function.toScript());
- } else {
- script.append("RichFaces.stopPush('").append(push.getListenerId(context)).append("')");
- }
- script.append(";\n");
- writer.writeText(script.toString(),null);
- writer.endElement(HTML.SCRIPT_ELEM);
- getUtils().encodeEndFormIfNessesary(context, component);
- writer.endElement(HTML.SPAN_ELEM);
- }
+ int interval = push.getInterval();
+ if (!getUtils().shouldRenderAttribute(interval)) {
+ String intervalInitParameter =
context.getExternalContext().getInitParameter(PUSH_INTERVAL_PARAMETER);
+ if (null != intervalInitParameter) {
+ interval = Integer.parseInt(intervalInitParameter);
+ } else {
+ interval = DEFAULT_PUSH_INTERVAL;
+ }
+ }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class<? extends UIComponent> getComponentClass() {
- // only push component is allowed.
- return UIPush.class;
- }
-
- @Override
- protected void doDecode(FacesContext context, UIComponent component) {
- super.doDecode(context, component);
-
- UIPush push = (UIPush) component;
- if (push.isEnabled()) {
- Map<String, String> requestParameterMap =
context.getExternalContext().getRequestParameterMap();
- if (requestParameterMap.get(push.getClientId(context)) != null ||
push.isHasActiveBehavior()) {
- new ActionEvent(push).queue();
- }
- }
- }
+ options.put("interval", new Integer(interval));
+ options.put("pushResourceUrl", new
PushResource().getRequestPath());
+ options.put("pushId", push.getListenerId(context));
+ options.put("clientId", component.getClientId(context));
+ HandlersChain handlersChain = new HandlersChain(push);
+ handlersChain.addInlineHandlerFromAttribute(context,
HtmlPush.ON_DATA_AVAILABLE);
+ handlersChain.addBehaviors(context, HtmlPush.DATA_AVAILABLE);
+
+ if (!handlersChain.hasSubmittingBehavior()) {
+ JSFunction ajaxFunction = AjaxRendererUtils
+ .buildAjaxFunction(context, push,
AjaxRendererUtils.AJAX_FUNCTION_NAME);
+ AjaxEventOptions eventOptions =
AjaxRendererUtils.buildEventOptions(context, push);
+ if (!eventOptions.isEmpty()) {
+ ajaxFunction.addParameter(eventOptions);
+ }
+ handlersChain.addInlineHandlerAsValue(context, ajaxFunction.toScript());
+ }
+
+ String handler = handlersChain.toScript();
+
+ if (handler != null) {
+ JSFunctionDefinition dataAvailableHandler = new
JSFunctionDefinition(JSReference.EVENT);
+ dataAvailableHandler.addToBody(handler);
+ options.put(HtmlPush.ON_DATA_AVAILABLE, dataAvailableHandler);
+ }
+ function.addParameter(options);
+ script.append(function.toScript());
+ } else {
+
script.append("RichFaces.stopPush('").append(push.getListenerId(context)).append("')");
+ }
+ script.append(";\n");
+ writer.writeText(script.toString(), null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ getUtils().encodeEndFormIfNessesary(context, component);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class<? extends UIComponent> getComponentClass() {
+ // only push component is allowed.
+ return UIPush.class;
+ }
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ super.doDecode(context, component);
+
+ UIPush push = (UIPush) component;
+ if (push.isEnabled()) {
+ Map<String, String> requestParameterMap =
context.getExternalContext().getRequestParameterMap();
+ if (requestParameterMap.get(push.getClientId(context)) != null ||
push.isHasActiveBehavior()) {
+ new ActionEvent(push).queue();
+ }
+ }
+ }
+
}
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java 2009-12-04
20:53:17 UTC (rev 16073)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java 2009-12-04
20:54:42 UTC (rev 16074)
@@ -21,16 +21,6 @@
package org.richfaces.renderkit.html;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.HandlersChain;
import org.ajax4jsf.renderkit.RendererBase;
@@ -40,193 +30,201 @@
import org.richfaces.component.UIAjaxStatus;
import org.richfaces.component.util.HtmlUtil;
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author Nick Belaevski
- *
*/
-@ResourceDependencies( {
- @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js"),
- @ResourceDependency(name = "richfaces-queue.js") })
+@ResourceDependencies({
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-queue.js")})
public class AjaxStatusRenderer extends RendererBase {
- private static final String START = "start";
- private static final String STOP = "stop";
- private static final String ERROR = "error";
+ private static final String START = "start";
+ private static final String STOP = "stop";
+ private static final String ERROR = "error";
- private static final String[] EVENT_NAMES = {
- "start", "stop", "error", "success"
- };
+ private static final String[] EVENT_NAMES = {
+ "start", "stop", "error", "success"
+ };
- private static enum StatusState {
- // NOTE: states encode order is important for script!
- start(START),
- error(ERROR) {
- {
- this.setOptional();
- }
- },
- stop(STOP) {
- {
- this.setInitial();
- }
- };
+ private static enum StatusState {
+ // NOTE: states encode order is important for script!
+ start(START),
+ error(ERROR) {
+ {
+ this.setOptional();
+ }
+ },
+ stop(STOP) {
+ {
+ this.setInitial();
+ }
+ };
- private String stateName;
+ private String stateName;
- private String styleAttributeName;
+ private String styleAttributeName;
- private String styleClassAttributeName;
+ private String styleClassAttributeName;
- private String textAttributeName;
+ private String textAttributeName;
- private String defaultStyleClass;
+ private String defaultStyleClass;
- private boolean initial;
+ private boolean initial;
- private boolean optional;
+ private boolean optional;
- private StatusState(String stateName) {
- this.stateName = stateName;
- this.styleAttributeName = stateName + "Style";
- this.styleClassAttributeName = stateName + "StyleClass";
- this.textAttributeName = stateName + "Text";
- this.defaultStyleClass = "rich-status-" + stateName;
- }
+ private StatusState(String stateName) {
+ this.stateName = stateName;
+ this.styleAttributeName = stateName + "Style";
+ this.styleClassAttributeName = stateName + "StyleClass";
+ this.textAttributeName = stateName + "Text";
+ this.defaultStyleClass = "rich-status-" + stateName;
+ }
- public String getStyleAttributeName() {
- return styleAttributeName;
- }
+ public String getStyleAttributeName() {
+ return styleAttributeName;
+ }
- public String getStyleClassAttributeName() {
- return styleClassAttributeName;
- }
+ public String getStyleClassAttributeName() {
+ return styleClassAttributeName;
+ }
- public String getFacetName() {
- return stateName;
- }
+ public String getFacetName() {
+ return stateName;
+ }
- public String getTextAttributeName() {
- return textAttributeName;
- }
+ public String getTextAttributeName() {
+ return textAttributeName;
+ }
- public String getDefaultStyleClass() {
- return defaultStyleClass;
- }
+ public String getDefaultStyleClass() {
+ return defaultStyleClass;
+ }
- public boolean isInitial() {
- return initial;
- }
+ public boolean isInitial() {
+ return initial;
+ }
- public boolean isOptional() {
- return optional;
- }
+ public boolean isOptional() {
+ return optional;
+ }
- protected void setOptional() {
- this.optional = true;
- }
+ protected void setOptional() {
+ this.optional = true;
+ }
- protected void setInitial() {
- this.initial = true;
- }
- }
+ protected void setInitial() {
+ this.initial = true;
+ }
+ }
- private RendererUtils rendererUtils = RendererUtils.getInstance();
+ private RendererUtils rendererUtils = RendererUtils.getInstance();
- protected void encodeState(FacesContext facesContext, UIAjaxStatus status,
- StatusState state) throws IOException {
+ protected void encodeState(FacesContext facesContext, UIAjaxStatus status,
+ StatusState state) throws IOException {
- Map<String, Object> statusAttributes = status.getAttributes();
- UIComponent stateFacet = status.getFacet(state.getFacetName());
- String stateText = null;
-
- if (stateFacet == null) {
- stateText = (String) statusAttributes.get(state.getTextAttributeName());
- }
-
- if (state.isOptional() && stateFacet == null && stateText == null) {
- return ;
- }
-
- ResponseWriter writer = facesContext.getResponseWriter();
- writer.startElement(HTML.SPAN_ELEM, status);
+ Map<String, Object> statusAttributes = status.getAttributes();
+ UIComponent stateFacet = status.getFacet(state.getFacetName());
+ String stateText = null;
- String stateStyle = (String) statusAttributes.get(state.getStyleAttributeName());
+ if (stateFacet == null) {
+ stateText = (String) statusAttributes.get(state.getTextAttributeName());
+ }
- rendererUtils.writeAttribute(writer, HTML.STYLE_ATTRIBUTE,
- HtmlUtil.concatStyles(stateStyle,
- state.isInitial() ? null : "display:none")
- );
+ if (state.isOptional() && stateFacet == null && stateText ==
null) {
+ return;
+ }
- String stateStyleClass = (String)
statusAttributes.get(state.getStyleClassAttributeName());
+ ResponseWriter writer = facesContext.getResponseWriter();
+ writer.startElement(HTML.SPAN_ELEM, status);
- rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses(state.getDefaultStyleClass(),
- stateStyleClass));
+ String stateStyle = (String)
statusAttributes.get(state.getStyleAttributeName());
- if (stateFacet != null && stateFacet.isRendered()) {
- stateFacet.encodeAll(facesContext);
- } else {
- if (stateText != null) {
- writer.writeText(stateText, null);
- }
- }
+ rendererUtils.writeAttribute(writer, HTML.STYLE_ATTRIBUTE,
+ HtmlUtil.concatStyles(stateStyle,
+ state.isInitial() ? null : "display:none")
+ );
- writer.endElement(HTML.SPAN_ELEM);
- }
+ String stateStyleClass = (String)
statusAttributes.get(state.getStyleClassAttributeName());
- @Override
- public void encodeEnd(FacesContext context, UIComponent component)
- throws IOException {
- super.encodeEnd(context, component);
+ rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
+ HtmlUtil.concatClasses(state.getDefaultStyleClass(),
+ stateStyleClass));
- UIAjaxStatus ajaxStatus = (UIAjaxStatus) component;
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.SPAN_ELEM, component);
- String clientId = component.getClientId(context);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId, "id");
+ if (stateFacet != null && stateFacet.isRendered()) {
+ stateFacet.encodeAll(facesContext);
+ } else {
+ if (stateText != null) {
+ writer.writeText(stateText, null);
+ }
+ }
- for (StatusState state : StatusState.values()) {
- encodeState(context, ajaxStatus, state);
- }
+ writer.endElement(HTML.SPAN_ELEM);
+ }
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.TEXT_JAVASCRIPT_TYPE, null);
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeEnd(context, component);
- JSFunction statusConstructor = new JSFunction("new RichFaces.status",
- clientId);
+ UIAjaxStatus ajaxStatus = (UIAjaxStatus) component;
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.SPAN_ELEM, component);
+ String clientId = component.getClientId(context);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId, "id");
- Map<String, Object> options = new HashMap<String, Object>();
+ for (StatusState state : StatusState.values()) {
+ encodeState(context, ajaxStatus, state);
+ }
- Map<String, Object> attributes = ajaxStatus.getAttributes();
- for (String eventName : EVENT_NAMES) {
- String eventAttribute = "on" + eventName;
- HandlersChain handlersChain = new HandlersChain(component, true);
- handlersChain.addInlineHandlerFromAttribute(context, eventAttribute);
- handlersChain.addBehaviors(context, eventName);
- rendererUtils.addToScriptHash(options, eventAttribute,
- handlersChain.toScript(), null,
- ScriptHashVariableWrapper.EVENT_HANDLER);
- }
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.TEXT_JAVASCRIPT_TYPE, null);
- rendererUtils.addToScriptHash(options, "statusName",
attributes.get("name"));
-
- if (!options.isEmpty()) {
- statusConstructor.addParameter(options);
- }
+ JSFunction statusConstructor = new JSFunction("new RichFaces.status",
+ clientId);
- writer.writeText(statusConstructor.toScript(), null);
- writer.endElement(HTML.SCRIPT_ELEM);
+ Map<String, Object> options = new HashMap<String, Object>();
- writer.endElement(HTML.SPAN_ELEM);
- }
+ Map<String, Object> attributes = ajaxStatus.getAttributes();
+ for (String eventName : EVENT_NAMES) {
+ String eventAttribute = "on" + eventName;
+ HandlersChain handlersChain = new HandlersChain(component, true);
+ handlersChain.addInlineHandlerFromAttribute(context, eventAttribute);
+ handlersChain.addBehaviors(context, eventName);
+ rendererUtils.addToScriptHash(options, eventAttribute,
+ handlersChain.toScript(), null,
+ ScriptHashVariableWrapper.EVENT_HANDLER);
+ }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- @Override
- protected Class<? extends UIComponent> getComponentClass() {
- return UIAjaxStatus.class;
- }
+ rendererUtils.addToScriptHash(options, "statusName",
attributes.get("name"));
+
+ if (!options.isEmpty()) {
+ statusConstructor.addParameter(options);
+ }
+
+ writer.writeText(statusConstructor.toScript(), null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIAjaxStatus.class;
+ }
}
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java 2009-12-04
20:53:17 UTC (rev 16073)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java 2009-12-04
20:54:42 UTC (rev 16074)
@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.resource;
import org.richfaces.component.PushEventTracker;
@@ -40,8 +38,8 @@
//TODO make this a singleton
public class PushResource extends AbstractBaseResource {
-
- @Override
+
+ @Override
public boolean isCacheable(FacesContext context) {
return false;
}