You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2005/10/07 17:43:13 UTC
svn commit: r307148 -
/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/effect/EffectRenderer.java
Author: werpu
Date: Fri Oct 7 08:43:10 2005
New Revision: 307148
URL: http://svn.apache.org/viewcvs?rev=307148&view=rev
Log:
fixed the headers and the formatting
Modified:
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/effect/EffectRenderer.java
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/effect/EffectRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/effect/EffectRenderer.java?rev=307148&r1=307147&r2=307148&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/effect/EffectRenderer.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/effect/EffectRenderer.java Fri Oct 7 08:43:10 2005
@@ -32,21 +32,19 @@
import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
/**
- * For the fade, we only need a simple renderer and a backend javascript
- * inclusion so that we can serve it out of the jar
- *
- * @author Werner Punz werpu@gmx.at
- */
-/**
* Fade field only currently the renderer is implemented and the tag, because we
* do not store any extra functionality over a simple div in here
+
+ * For the fade, we only need a simple renderer and a backend javascript
+ * inclusion so that we can serve it out of the jar
*
* @author Werner Punz werpu@gmx.at
- * @version $Revision: $ $Date: $
+ * @version $$Revision$$ $$Date$$
*/
-public class EffectRenderer extends HtmlRenderer {
+public class EffectRenderer extends HtmlRenderer
+{
- private static final String JAVASCRIPT_ENCODED = "org.apache.myfaces.inputsuggestajax.JAVASCRIPT_ENCODED";
+ private static final String JAVASCRIPT_ENCODED = "org.apache.myfaces.inputsuggestajax.JAVASCRIPT_ENCODED";
/**
* Encodes any stand-alone javascript functions that are needed. Uses either
@@ -59,54 +57,70 @@
* UIComponent
* @throws java.io.IOException
*/
- private void encodeJavascript(FacesContext context, UIComponent component) throws IOException {
+ private void encodeJavascript(FacesContext context, UIComponent component)
+ throws IOException
+ {
// check to see if javascript has already been written (which could
// happen if more than one tree on the same page)
- if (context.getExternalContext().getRequestMap().containsKey(JAVASCRIPT_ENCODED)) {
+ if (context.getExternalContext().getRequestMap().containsKey(
+ JAVASCRIPT_ENCODED))
+ {
return;
}
// render javascript function for client-side toggle (it won't be used
// if user has opted for server-side toggle)
ResponseWriter out = context.getResponseWriter();
- String javascriptLocation = (String) component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
- if (javascriptLocation == null) {
- AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class, "prototype.js", context);
- AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class, "effects.js", context);
- AddResource.addJavaScriptToHeader(EffectRenderer.class, "fat.js", context);
-
+ String javascriptLocation = (String) component.getAttributes().get(
+ JSFAttr.JAVASCRIPT_LOCATION);
+ if (javascriptLocation == null)
+ {
+ AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class,
+ "prototype.js", context);
+ AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class,
+ "effects.js", context);
+ AddResource.addJavaScriptToHeader(EffectRenderer.class, "fat.js",
+ context);
- } else {
+ }
+ else
+ {
out.startElement(HTML.SCRIPT_ELEM, null);
out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR, javascriptLocation + "/prototype.js", null);
+ out.writeAttribute(HTML.SRC_ATTR, javascriptLocation
+ + "/prototype.js", null);
out.endElement(HTML.SCRIPT_ELEM);
out.startElement(HTML.SCRIPT_ELEM, null);
out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR, javascriptLocation + "/effects.js", null);
+ out.writeAttribute(HTML.SRC_ATTR, javascriptLocation
+ + "/effects.js", null);
out.endElement(HTML.SCRIPT_ELEM);
out.startElement(HTML.SCRIPT_ELEM, null);
out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR, javascriptLocation + "/dragdrop.js", null);
+ out.writeAttribute(HTML.SRC_ATTR, javascriptLocation
+ + "/dragdrop.js", null);
out.endElement(HTML.SCRIPT_ELEM);
out.startElement(HTML.SCRIPT_ELEM, null);
out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR, javascriptLocation + "/controls.js", null);
+ out.writeAttribute(HTML.SRC_ATTR, javascriptLocation
+ + "/controls.js", null);
out.endElement(HTML.SCRIPT_ELEM);
}
- context.getExternalContext().getRequestMap().put(JAVASCRIPT_ENCODED, Boolean.TRUE);
+ context.getExternalContext().getRequestMap().put(JAVASCRIPT_ENCODED,
+ Boolean.TRUE);
}
- public boolean getRendersChildren() {
+ public boolean getRendersChildren()
+ {
return true;
}
- public static final String RENDERER_TYPE = "script.aculo.us.renderer";
+ public static final String RENDERER_TYPE = "script.aculo.us.renderer";
/**
* We only need an encodeBeing method because the fade control, does not
@@ -121,8 +135,11 @@
* severely
*
*/
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
- if ((context == null) || (component == null)) {
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ if ((context == null) || (component == null))
+ {
throw new NullPointerException();
}
@@ -141,21 +158,27 @@
*
* @param component
*/
- private void prepareFade(UIComponent component) {
+ private void prepareFade(UIComponent component)
+ {
Div theComponent = (Div) component;
- Boolean fade = (Boolean) component.getAttributes().get(EffectTag.TAG_PARAM_FADE);
+ Boolean fade = (Boolean) component.getAttributes().get(
+ EffectTag.TAG_PARAM_FADE);
String theStyleClass = theComponent.getStyleClass();
if (theStyleClass == null)
theStyleClass = "";
- if (fade != null && fade.booleanValue() && !(theStyleClass.indexOf("fade") != -1)) {
+ if (fade != null && fade.booleanValue()
+ && !(theStyleClass.indexOf("fade") != -1))
+ {
- if (theStyleClass != null && !theStyleClass.trim().equalsIgnoreCase(""))
+ if (theStyleClass != null
+ && !theStyleClass.trim().equalsIgnoreCase(""))
theStyleClass += ";fade";
else
theStyleClass = "fade";
- String fadeColor = (String) component.getAttributes().get(EffectTag.TAG_PARAM_FADECOLOR);
+ String fadeColor = (String) component.getAttributes().get(
+ EffectTag.TAG_PARAM_FADECOLOR);
fadeColor = (fadeColor != null) ? fadeColor : "";
fadeColor = fadeColor.replaceAll("#", "");
@@ -167,15 +190,22 @@
}
}
- public void renderEffectsBegin(FacesContext context, UIComponent component) throws IOException {
+ public void renderEffectsBegin(FacesContext context, UIComponent component)
+ throws IOException
+ {
// dump all the parameters which affect us into we dont set a central
// unchecked here to keep the warning level high
- Boolean squish = (Boolean) component.getAttributes().get(EffectTag.TAG_PARAM_SQUISH);
- Boolean puff = (Boolean) component.getAttributes().get(EffectTag.TAG_PARAM_PUFF);
- Boolean scale = (Boolean) component.getAttributes().get(EffectTag.TAG_PARAM_SCALE);
- Boolean pulsate = (Boolean) component.getAttributes().get(EffectTag.TAG_PARAM_PULSATE);
- Integer scaleSize = (Integer) component.getAttributes().get(EffectTag.TAG_PARAM_SCALE_SIZE);
+ Boolean squish = (Boolean) component.getAttributes().get(
+ EffectTag.TAG_PARAM_SQUISH);
+ Boolean puff = (Boolean) component.getAttributes().get(
+ EffectTag.TAG_PARAM_PUFF);
+ Boolean scale = (Boolean) component.getAttributes().get(
+ EffectTag.TAG_PARAM_SCALE);
+ Boolean pulsate = (Boolean) component.getAttributes().get(
+ EffectTag.TAG_PARAM_PULSATE);
+ Integer scaleSize = (Integer) component.getAttributes().get(
+ EffectTag.TAG_PARAM_SCALE_SIZE);
Div div = (Div) component;
ResponseWriter writer = context.getResponseWriter();
@@ -189,30 +219,44 @@
String styleClass = div.getStyleClass();
String style = div.getStyle();
- if (null != styleClass && null != style) {
- throw new IllegalStateException("Only one of style or styleClass can be specified");
+ if (null != styleClass && null != style)
+ {
+ throw new IllegalStateException(
+ "Only one of style or styleClass can be specified");
}
- if (null != styleClass) {
+ if (null != styleClass)
+ {
writer.writeAttribute(HTML.CLASS_ATTR, styleClass, null);
}
- if (null != style) {
+ if (null != style)
+ {
writer.writeAttribute(HTML.STYLE_ATTR, style, null);
}
// todo check the existing code for already existent javascript code
// not needed now, but probably in the long run
- if (puff != null && puff.booleanValue()) {
- writer.writeAttribute(HTML.ONCLICK_ATTR, "javascript:new Effect.Puff(this);", null);
- }
- if (squish != null && squish.booleanValue()) {
- writer.writeAttribute(HTML.ONCLICK_ATTR, "javascript:new Effect.Squish(this);", null);
- }
- if(pulsate != null && pulsate.booleanValue()) {
- writer.writeAttribute(HTML.ONCLICK_ATTR, "javascript:new Effect.Pulsate(this);", null);
- }
- if (scale != null && scale.booleanValue()) {
- writer.writeAttribute(HTML.ONMOUSEOVER_ATTR, "javascript:new Effect.Scale(this," + scaleSize.toString() + ");", null);
- writer.writeAttribute(HTML.ONMOUSEOUT_ATTR, "javascript:new Effect.Scale(this,100);", null);
+ if (puff != null && puff.booleanValue())
+ {
+ writer.writeAttribute(HTML.ONCLICK_ATTR,
+ "javascript:new Effect.Puff(this);", null);
+ }
+ if (squish != null && squish.booleanValue())
+ {
+ writer.writeAttribute(HTML.ONCLICK_ATTR,
+ "javascript:new Effect.Squish(this);", null);
+ }
+ if (pulsate != null && pulsate.booleanValue())
+ {
+ writer.writeAttribute(HTML.ONCLICK_ATTR,
+ "javascript:new Effect.Pulsate(this);", null);
+ }
+ if (scale != null && scale.booleanValue())
+ {
+ writer.writeAttribute(HTML.ONMOUSEOVER_ATTR,
+ "javascript:new Effect.Scale(this," + scaleSize.toString()
+ + ");", null);
+ writer.writeAttribute(HTML.ONMOUSEOUT_ATTR,
+ "javascript:new Effect.Scale(this,100);", null);
}
}
@@ -223,7 +267,9 @@
* @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
* javax.faces.component.UIComponent)
*/
- public void encodeChildren(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+ public void encodeChildren(FacesContext facesContext,
+ UIComponent uiComponent) throws IOException
+ {
RendererUtils.renderChildren(facesContext, uiComponent);
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
@@ -233,7 +279,9 @@
* Standard encode end
*
*/
- public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
+ public void encodeEnd(FacesContext facesContext, UIComponent component)
+ throws IOException
+ {
ResponseWriter writer = facesContext.getResponseWriter();
writer.endElement(HTML.DIV_ELEM);
HtmlRendererUtils.writePrettyLineSeparator(facesContext);