You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/11/17 01:16:50 UTC
svn commit: r1202947 [4/5] - in /myfaces/shared/trunk_4.0.x: ./ core/
core/src/main/java/org/apache/myfaces/shared/application/
core/src/main/java/org/apache/myfaces/shared/component/
core/src/main/java/org/apache/myfaces/shared/config/ core/src/main/j...
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java Thu Nov 17 00:16:48 2011
@@ -102,7 +102,8 @@ public class HtmlSecretRendererBase
}
else
{
- isRedisplay = org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(uiComponent, JSFAttr.REDISPLAY_ATTR, false);
+ isRedisplay = org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(uiComponent,
+ JSFAttr.REDISPLAY_ATTR, false);
}
if (isRedisplay)
{
@@ -111,13 +112,15 @@ public class HtmlSecretRendererBase
}
Map<String, List<ClientBehavior>> behaviors = null;
- if (uiComponent instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(facesContext.getExternalContext()))
+ if (uiComponent instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(
+ facesContext.getExternalContext()))
{
behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
- HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(facesContext, writer, uiComponent, behaviors);
+ HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
+ facesContext, writer, uiComponent, behaviors);
if (isCommonPropertiesOptimizationEnabled(facesContext))
{
CommonPropertyUtils.renderInputPassthroughPropertiesWithoutDisabledAndEvents(writer,
@@ -125,7 +128,8 @@ public class HtmlSecretRendererBase
}
else
{
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
+ HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
}
}
else
@@ -137,7 +141,8 @@ public class HtmlSecretRendererBase
}
else
{
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
+ HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
}
}
@@ -198,7 +203,8 @@ public class HtmlSecretRendererBase
}
}
- public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException
+ public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue)
+ throws ConverterException
{
RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class);
return RendererUtils.getConvertedUIOutputValue(facesContext,
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java Thu Nov 17 00:16:48 2011
@@ -225,7 +225,8 @@ public class HtmlTableRendererBase exten
}
// render the facet
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
- RendererUtils.renderChild(facesContext, colgroupsFacet);
+ //RendererUtils.renderChild(facesContext, colgroupsFacet);
+ colgroupsFacet.encodeAll(facesContext);
}
/**
@@ -501,7 +502,8 @@ public class HtmlTableRendererBase exten
{
writer.writeAttribute(HTML.CLASS_ATTR, styles.getColumnStyle(columnStyleIndex), null);
}
- RendererUtils.renderChild(facesContext, component);
+ //RendererUtils.renderChild(facesContext, component);
+ component.encodeAll(facesContext);
if(rowHeader)
{
writer.endElement(HTML.TH_ELEM);
@@ -912,14 +914,19 @@ public class HtmlTableRendererBase exten
{
totalColumns = totalColumns + newsPaperColumns - 1;
}
- writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(totalColumns), null);
+ // Only render colspan if is > 0
+ if (totalColumns > 0)
+ {
+ writer.writeAttribute(HTML.COLSPAN_ATTR, new Integer(totalColumns), null);
+ }
if (styleClass != null)
{
writer.writeAttribute(HTML.CLASS_ATTR, styleClass, null);
}
if (facet != null)
{
- RendererUtils.renderChild(facesContext, facet);
+ //RendererUtils.renderChild(facesContext, facet);
+ facet.encodeAll(facesContext);
}
writer.endElement(colElementName);
writer.endElement(HTML.TR_ELEM);
@@ -971,7 +978,8 @@ public class HtmlTableRendererBase exten
if(spacer == null) return;
writer.startElement(HTML.TD_ELEM, component);
- RendererUtils.renderChild(facesContext, spacer);
+ //RendererUtils.renderChild(facesContext, spacer);
+ spacer.encodeAll(facesContext);
writer.endElement(HTML.TD_ELEM);
}
@@ -1067,7 +1075,8 @@ public class HtmlTableRendererBase exten
if (facet != null)
{
- RendererUtils.renderChild(facesContext, facet);
+ //RendererUtils.renderChild(facesContext, facet);
+ facet.encodeAll(facesContext);
}
writer.endElement(determineHeaderCellTag(facesContext, uiComponent.getParent()));
}
@@ -1118,7 +1127,8 @@ public class HtmlTableRendererBase exten
}
if (facet != null)
{
- RendererUtils.renderChild(facesContext, facet);
+ //RendererUtils.renderChild(facesContext, facet);
+ facet.encodeAll(facesContext);
}
writer.endElement(HTML.TD_ELEM);
}
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java Thu Nov 17 00:16:48 2011
@@ -109,8 +109,7 @@ public class HtmlTextRendererBase
if (isCommonPropertiesOptimizationEnabled(facesContext))
{
long commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
-
- if (commonPropertiesMarked > 0)
+ if ( (commonPropertiesMarked & ~(CommonPropertyConstants.ESCAPE_PROP)) > 0)
{
span = true;
writer.startElement(HTML.SPAN_ELEM, component);
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java Thu Nov 17 00:16:48 2011
@@ -18,14 +18,10 @@
*/
package org.apache.myfaces.shared.renderkit.html;
-import org.apache.myfaces.shared.renderkit.RendererUtils;
-import org.apache.myfaces.shared.renderkit.html.HTML;
-import org.apache.myfaces.shared.renderkit.html.HtmlRenderer;
-import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
-import org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils;
-import org.apache.myfaces.shared.renderkit.html.util.ResourceUtils;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
-import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.UIOutput;
@@ -35,9 +31,10 @@ import javax.faces.component.html.HtmlIn
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.ConverterException;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
+
+import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils;
+import org.apache.myfaces.shared.renderkit.html.util.ResourceUtils;
/**
@@ -59,7 +56,8 @@ public class HtmlTextareaRendererBase
behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
if (!behaviors.isEmpty())
{
- ResourceUtils.renderDefaultJsfJsInlineIfNecessary(facesContext, facesContext.getResponseWriter());
+ ResourceUtils.renderDefaultJsfJsInlineIfNecessary(facesContext,
+ facesContext.getResponseWriter());
}
}
@@ -67,7 +65,9 @@ public class HtmlTextareaRendererBase
}
- protected void encodeTextArea(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+ protected void encodeTextArea(FacesContext facesContext, UIComponent uiComponent)
+ throws IOException
+ {
//allow subclasses to render custom attributes by separating rendering begin and end
renderTextAreaBegin(facesContext, uiComponent);
renderTextAreaValue(facesContext, uiComponent);
@@ -83,7 +83,8 @@ public class HtmlTextareaRendererBase
writer.startElement(HTML.TEXTAREA_ELEM, uiComponent);
Map<String, List<ClientBehavior>> behaviors = null;
- if (uiComponent instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(facesContext.getExternalContext()))
+ if (uiComponent instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(
+ facesContext.getExternalContext()))
{
behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
if (!behaviors.isEmpty())
@@ -97,7 +98,8 @@ public class HtmlTextareaRendererBase
}
HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
- HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(facesContext, writer, uiComponent, behaviors);
+ HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
+ facesContext, writer, uiComponent, behaviors);
if (isCommonPropertiesOptimizationEnabled(facesContext))
{
CommonPropertyUtils.renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(writer,
@@ -106,7 +108,8 @@ public class HtmlTextareaRendererBase
}
else
{
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
+ HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
}
}
else
@@ -121,7 +124,8 @@ public class HtmlTextareaRendererBase
}
else
{
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
+ HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
}
}
@@ -153,7 +157,8 @@ public class HtmlTextareaRendererBase
return ((HtmlInputTextarea)uiComponent).isDisabled();
}
- return org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(uiComponent, HTML.DISABLED_ATTR, false);
+ return org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(
+ uiComponent, HTML.DISABLED_ATTR, false);
}
@@ -168,7 +173,8 @@ public class HtmlTextareaRendererBase
}
}
- public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException
+ public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue)
+ throws ConverterException
{
RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class);
return org.apache.myfaces.shared.renderkit.RendererUtils.getConvertedUIOutputValue(facesContext,
Added: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java?rev=1202947&view=auto
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java (added)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java Thu Nov 17 00:16:48 2011
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.renderkit.html;
+
+/**
+ * The ScriptContext offers methods and fields
+ * to help with rendering out a script and keeping a
+ * proper formatting.
+ */
+public class JavascriptContext
+{
+ private static final String LINE_SEPARATOR = System.getProperty(
+ "line.separator", "\r\n");
+ private static final char TABULATOR = '\t';
+
+ private long currentIndentationLevel;
+ private StringBuffer buffer = new StringBuffer();
+ private boolean prettyPrint = false;
+ /**
+ * automatic formatting will render
+ * new-lines and indents if blocks are opened
+ * and closed - attention: you need to append
+ * opening and closing brackets of blocks separately in this case!
+ */
+ private boolean automaticFormatting = true;
+
+ public JavascriptContext()
+ {
+
+ }
+
+ public JavascriptContext(boolean prettyPrint)
+ {
+ this.prettyPrint = prettyPrint;
+ }
+
+ public JavascriptContext(StringBuffer buf, boolean prettyPrint)
+ {
+ this.prettyPrint = prettyPrint;
+ this.buffer = buf;
+ }
+
+ public void increaseIndent()
+ {
+ currentIndentationLevel++;
+ }
+
+ public void decreaseIndent()
+ {
+ currentIndentationLevel--;
+
+ if (currentIndentationLevel < 0)
+ {
+ currentIndentationLevel = 0;
+ }
+ }
+
+ public void prettyLine()
+ {
+ if (prettyPrint)
+ {
+ append(LINE_SEPARATOR);
+
+ for (int i = 0; i < getCurrentIndentationLevel(); i++)
+ {
+ append(TABULATOR);
+ }
+ }
+ }
+
+ public void prettyLineIncreaseIndent()
+ {
+ increaseIndent();
+ prettyLine();
+ }
+
+ public void prettyLineDecreaseIndent()
+ {
+ decreaseIndent();
+ prettyLine();
+ }
+
+ public long getCurrentIndentationLevel()
+ {
+ return currentIndentationLevel;
+ }
+
+ public void setCurrentIndentationLevel(long currentIndentationLevel)
+ {
+ this.currentIndentationLevel = currentIndentationLevel;
+ }
+
+ public JavascriptContext append(String str)
+ {
+
+ if (automaticFormatting && str.length() == 1)
+ {
+ boolean openBlock = str.equals("{");
+ boolean closeBlock = str.equals("}");
+
+ if (openBlock)
+ {
+ prettyLine();
+ }
+ else if (closeBlock)
+ {
+ prettyLineDecreaseIndent();
+ }
+
+ buffer.append(str);
+
+ if (openBlock)
+ {
+ prettyLineIncreaseIndent();
+ }
+ else if (closeBlock)
+ {
+ prettyLine();
+ }
+ }
+ else
+ {
+ buffer.append(str);
+ }
+ return this;
+ }
+
+ public JavascriptContext append(char c)
+ {
+ buffer.append(c);
+ return this;
+ }
+
+ public JavascriptContext append(int i)
+ {
+ buffer.append(i);
+ return this;
+ }
+
+ public String toString()
+ {
+ return buffer.toString();
+ }
+}
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java Thu Nov 17 00:16:48 2011
@@ -100,9 +100,14 @@ public abstract class HTMLEncoder
app = "<br/>";
}
break;
+ default:
+ break;
}
- } else if (encodeNonLatin && (int)c > 0x80) {
- switch(c) {
+ }
+ else if (encodeNonLatin && (int)c > 0x80)
+ {
+ switch(c)
+ {
//german umlauts
case '\u00E4' : app = "ä"; break;
case '\u00C4' : app = "Ä"; break;
@@ -132,7 +137,9 @@ public abstract class HTMLEncoder
sb = new StringBuilder(string.substring(0, i));
}
sb.append(app);
- } else {
+ }
+ else
+ {
if (sb != null)
{
sb.append(c);
@@ -161,7 +168,8 @@ public abstract class HTMLEncoder
/**
* Variant of {@link #encode} where encodeNbsp is true.
*/
- public static void encode (char[] string, int offset, int length, boolean encodeNewline, Writer writer) throws IOException
+ public static void encode (char[] string, int offset, int length, boolean encodeNewline, Writer writer)
+ throws IOException
{
encode(string, offset, length, encodeNewline, true, writer);
}
@@ -169,7 +177,8 @@ public abstract class HTMLEncoder
/**
* Variant of {@link #encode} where encodeNbsp and encodeNonLatin are true
*/
- public static void encode (char[] string, int offset, int length, boolean encodeNewline, boolean encodeSubsequentBlanksToNbsp, Writer writer) throws IOException
+ public static void encode (char[] string, int offset, int length, boolean encodeNewline,
+ boolean encodeSubsequentBlanksToNbsp, Writer writer) throws IOException
{
encode(string, offset, length, encodeNewline, encodeSubsequentBlanksToNbsp, true, writer);
}
@@ -226,9 +235,14 @@ public abstract class HTMLEncoder
app = "<br/>";
}
break;
+ default:
+ break;
}
- } else if (encodeNonLatin && (int)c > 0x80) {
- switch(c) {
+ }
+ else if (encodeNonLatin && (int)c > 0x80)
+ {
+ switch(c)
+ {
//german umlauts
case '\u00E4' : app = "ä"; break;
case '\u00C4' : app = "Ä"; break;
@@ -259,7 +273,9 @@ public abstract class HTMLEncoder
sb.append(string, offset, i - offset);
}
sb.append(app);
- } else {
+ }
+ else
+ {
if (sb != null)
{
sb.append(c);
@@ -480,7 +496,9 @@ public abstract class HTMLEncoder
sb = new StringBuilder(string.substring(0, i));
}
sb.append(app);
- } else {
+ }
+ else
+ {
if (sb != null)
{
sb.append(c);
@@ -572,13 +590,14 @@ public abstract class HTMLEncoder
c = string.charAt(i);
// - From %00 to %20 (' ' %20 could encode as +, but %20 also works, so we keep %20)
- // - <"> %22 (If there is encode of "%", there is a risk of duplicate encoding, so we make easier and omit this one)
+ // - <"> %22 (If there is encode of "%", there is a risk of duplicate encoding, so
+ // we make easier and omit this one)
// - "<" %3C, ">" %3E,
// - "\" %5C, "^" %5E, "`" %60
// - "{" %7B, "|" %7C, "}" %7D
// - From %7F ad infinitum (each character as many bytes as necessary but take into account
- // that a single char should contain 2,3 or more bytes!. This data should be encoded translating from the document
- // character encoding to percent encoding)
+ // that a single char should contain 2,3 or more bytes!. This data should be encoded
+ // translating from the document character encoding to percent encoding)
//
// "&" should be encoded as "&" because this link is inside an html page, and
// put & is invalid in this context
@@ -646,7 +665,9 @@ public abstract class HTMLEncoder
sb = new StringBuilder(string.substring(0, i));
}
sb.append(app);
- } else {
+ }
+ else
+ {
if (sb != null)
{
sb.append(c);
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/ResourceUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/ResourceUtils.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/ResourceUtils.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/ResourceUtils.java Thu Nov 17 00:16:48 2011
@@ -36,7 +36,8 @@ import org.apache.myfaces.shared.renderk
* @version $Revision$ $Date$
* @since 4.0.1
*/
-public class ResourceUtils {
+public class ResourceUtils
+{
public final static String JAVAX_FACES_LIBRARY_NAME = "javax.faces";
public final static String JSF_JS_RESOURCE_NAME = "jsf.js";
@@ -45,8 +46,20 @@ public class ResourceUtils {
public final static String MYFACES_LIBRARY_NAME = "org.apache.myfaces";
private final static String RENDERED_MYFACES_JS = "org.apache.myfaces.RENDERED_MYFACES_JS";
+ public final static String JSF_MYFACES_JSFJS_MINIMAL = "minimal";
+ public final static String JSF_MYFACES_JSFJS_MINIMAL_MODERN = "minimal-modern";
+ public final static String JSF_MYFACES_JSFJS_NORMAL = "normal";
+
public final static String JSF_UNCOMPRESSED_JS_RESOURCE_NAME = "jsf-uncompressed.js";
- private final static String RENDERED_STYLESHEET_RESOURCES_SET = "org.apache.myfaces.RENDERED_STYLESHEET_RESOURCES_SET";
+ public final static String JSF_MINIMAL_JS_RESOURCE_NAME = "jsf-minimal.js";
+ public final static String JSF_MINIMAL_MODERN_JS_RESOURCE_NAME = "jsf-minimal-modern.js";
+
+ public final static String JSF_MYFACES_JSFJS_I18N = "jsf-i18n.js";
+ public final static String JSF_MYFACES_JSFJS_EXPERIMENTAL = "jsf-experimental.js";
+ public final static String JSF_MYFACES_JSFJS_LEGACY = "jsf-legacy.js";
+
+ private final static String RENDERED_STYLESHEET_RESOURCES_SET =
+ "org.apache.myfaces.RENDERED_STYLESHEET_RESOURCES_SET";
private final static String RENDERED_SCRIPT_RESOURCES_SET = "org.apache.myfaces.RENDERED_SCRIPT_RESOURCES_SET";
private final static String RENDERED_JSF_JS = "org.apache.myfaces.RENDERED_JSF_JS";
public final static String HEAD_TARGET = "head";
@@ -68,7 +81,8 @@ public class ResourceUtils {
@SuppressWarnings("unchecked")
private static Map<String, Boolean> getRenderedStylesheetResources(FacesContext facesContext)
{
- Map<String, Boolean> map = (Map<String, Boolean>) facesContext.getAttributes().get(RENDERED_STYLESHEET_RESOURCES_SET);
+ Map<String, Boolean> map = (Map<String, Boolean>) facesContext.getAttributes().get(
+ RENDERED_STYLESHEET_RESOURCES_SET);
if (map == null)
{
map = new HashMap<String, Boolean>();
@@ -87,7 +101,8 @@ public class ResourceUtils {
@SuppressWarnings("unchecked")
private static Map<String, Boolean> getRenderedScriptResources(FacesContext facesContext)
{
- Map<String, Boolean> map = (Map<String, Boolean>) facesContext.getAttributes().get(RENDERED_SCRIPT_RESOURCES_SET);
+ Map<String, Boolean> map = (Map<String, Boolean>) facesContext.getAttributes().get(
+ RENDERED_SCRIPT_RESOURCES_SET);
if (map == null)
{
map = new HashMap<String, Boolean>();
@@ -98,32 +113,38 @@ public class ResourceUtils {
public static void markScriptAsRendered(FacesContext facesContext, String libraryName, String resourceName)
{
- getRenderedScriptResources(facesContext).put(libraryName != null ? libraryName+'/'+resourceName : resourceName, Boolean.TRUE);
+ getRenderedScriptResources(facesContext).put(
+ libraryName != null ? libraryName+'/'+resourceName : resourceName, Boolean.TRUE);
if (JAVAX_FACES_LIBRARY_NAME.equals(libraryName) &&
JSF_JS_RESOURCE_NAME.equals(resourceName))
{
// If we are calling this method, it is expected myfaces core is being used as runtime and note
// oamSubmit script is included inside jsf.js, so mark this one too.
- getRenderedScriptResources(facesContext).put(MYFACES_LIBRARY_NAME+'/'+MYFACES_JS_RESOURCE_NAME, Boolean.TRUE);
+ getRenderedScriptResources(facesContext).put(
+ MYFACES_LIBRARY_NAME+'/'+MYFACES_JS_RESOURCE_NAME, Boolean.TRUE);
}
}
public static void markStylesheetAsRendered(FacesContext facesContext, String libraryName, String resourceName)
{
- getRenderedStylesheetResources(facesContext).put(libraryName != null ? libraryName+'/'+resourceName : resourceName, Boolean.TRUE);
+ getRenderedStylesheetResources(facesContext).put(
+ libraryName != null ? libraryName+'/'+resourceName : resourceName, Boolean.TRUE);
}
public static boolean isRenderedScript(FacesContext facesContext, String libraryName, String resourceName)
{
- return getRenderedScriptResources(facesContext).containsKey(libraryName != null ? libraryName+'/'+resourceName : resourceName);
+ return getRenderedScriptResources(facesContext).containsKey(
+ libraryName != null ? libraryName+'/'+resourceName : resourceName);
}
public static boolean isRenderedStylesheet(FacesContext facesContext, String libraryName, String resourceName)
{
- return getRenderedStylesheetResources(facesContext).containsKey(libraryName != null ? libraryName+'/'+resourceName : resourceName);
+ return getRenderedStylesheetResources(facesContext).containsKey(
+ libraryName != null ? libraryName+'/'+resourceName : resourceName);
}
- public static void writeScriptInline(FacesContext facesContext, ResponseWriter writer, String libraryName, String resourceName) throws IOException
+ public static void writeScriptInline(FacesContext facesContext, ResponseWriter writer, String libraryName,
+ String resourceName) throws IOException
{
if (!ResourceUtils.isRenderedScript(facesContext, libraryName, resourceName))
{
@@ -139,7 +160,8 @@ public class ResourceUtils {
else
{
//Fast shortcut, don't create component instance and do what HtmlScriptRenderer do.
- Resource resource = facesContext.getApplication().getResourceHandler().createResource(resourceName, libraryName);
+ Resource resource = facesContext.getApplication().getResourceHandler().createResource(
+ resourceName, libraryName);
markScriptAsRendered(facesContext, libraryName, resourceName);
writer.startElement(HTML.SCRIPT_ELEM, null);
writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT , null);
@@ -149,7 +171,8 @@ public class ResourceUtils {
}
}
- public static void renderDefaultJsfJsInlineIfNecessary(FacesContext facesContext, ResponseWriter writer) throws IOException
+ public static void renderDefaultJsfJsInlineIfNecessary(FacesContext facesContext, ResponseWriter writer)
+ throws IOException
{
if (facesContext.getAttributes().containsKey(RENDERED_JSF_JS))
{
@@ -197,7 +220,8 @@ public class ResourceUtils {
else
{
//Fast shortcut, don't create component instance and do what HtmlScriptRenderer do.
- Resource resource = facesContext.getApplication().getResourceHandler().createResource(JSF_JS_RESOURCE_NAME, JAVAX_FACES_LIBRARY_NAME);
+ Resource resource = facesContext.getApplication().getResourceHandler().createResource(
+ JSF_JS_RESOURCE_NAME, JAVAX_FACES_LIBRARY_NAME);
markScriptAsRendered(facesContext, JAVAX_FACES_LIBRARY_NAME, JSF_JS_RESOURCE_NAME);
writer.startElement(HTML.SCRIPT_ELEM, null);
writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
@@ -210,8 +234,11 @@ public class ResourceUtils {
return;
}
- public static void renderMyfacesJSInlineIfNecessary(FacesContext facesContext, ResponseWriter writer) throws IOException {
- if (facesContext.getAttributes().containsKey(RENDERED_MYFACES_JS)) {
+ public static void renderMyfacesJSInlineIfNecessary(FacesContext facesContext, ResponseWriter writer)
+ throws IOException
+ {
+ if (facesContext.getAttributes().containsKey(RENDERED_MYFACES_JS))
+ {
return;
}
@@ -225,7 +252,8 @@ public class ResourceUtils {
}
// Check first if we have lucky, we are using myfaces and the script has
// been previously rendered
- if (isRenderedScript(facesContext, MYFACES_LIBRARY_NAME, MYFACES_JS_RESOURCE_NAME)) {
+ if (isRenderedScript(facesContext, MYFACES_LIBRARY_NAME, MYFACES_JS_RESOURCE_NAME))
+ {
facesContext.getAttributes().put(RENDERED_MYFACES_JS, Boolean.TRUE);
return;
}
@@ -255,7 +283,8 @@ public class ResourceUtils {
else
{
//Fast shortcut, don't create component instance and do what HtmlScriptRenderer do.
- Resource resource = facesContext.getApplication().getResourceHandler().createResource(MYFACES_JS_RESOURCE_NAME, MYFACES_LIBRARY_NAME);
+ Resource resource = facesContext.getApplication().getResourceHandler().createResource(
+ MYFACES_JS_RESOURCE_NAME, MYFACES_LIBRARY_NAME);
markScriptAsRendered(facesContext, MYFACES_LIBRARY_NAME, MYFACES_JS_RESOURCE_NAME);
writer.startElement(HTML.SCRIPT_ELEM, null);
writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/UnicodeEncoder.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/UnicodeEncoder.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/UnicodeEncoder.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/UnicodeEncoder.java Thu Nov 17 00:16:48 2011
@@ -42,7 +42,8 @@ public abstract class UnicodeEncoder
c = string.charAt(i);
if (((int)c) >= 0x80)
{
- if( sb == null ){
+ if( sb == null )
+ {
sb = new StringBuilder( string.length()+4 );
sb.append( string.substring(0,i) );
}
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/BaseResourceHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/BaseResourceHandlerSupport.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/BaseResourceHandlerSupport.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/BaseResourceHandlerSupport.java Thu Nov 17 00:16:48 2011
@@ -38,10 +38,11 @@ public class BaseResourceHandlerSupport
{
/**
- * Set the max time in miliseconds set on the "Expires" header for a resource.
+ * Set the max time in miliseconds set on the "Expires" header for a resource rendered by
+ * the default ResourceHandler.
* (default to one week in miliseconds or 604800000)
*/
- @JSFWebConfigParam(since="2.0", defaultValue="604800000")
+ @JSFWebConfigParam(since="2.0", defaultValue="604800000", group="resources", tags="performance")
public static final String RESOURCE_MAX_TIME_EXPIRES = "org.apache.myfaces.RESOURCE_MAX_TIME_EXPIRES";
/**
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ClassLoaderResourceLoader.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ClassLoaderResourceLoader.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ClassLoaderResourceLoader.java Thu Nov 17 00:16:48 2011
@@ -21,10 +21,6 @@ package org.apache.myfaces.shared.resour
import java.io.InputStream;
import java.net.URL;
-import javax.faces.application.ProjectStage;
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.shared.renderkit.html.util.ResourceUtils;
import org.apache.myfaces.shared.util.ClassUtils;
/**
@@ -73,12 +69,9 @@ public class ClassLoaderResourceLoader e
}
};*/
- private final boolean _developmentStage;
-
public ClassLoaderResourceLoader(String prefix)
{
super(prefix);
- _developmentStage = FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Development);
}
@Override
@@ -434,21 +427,21 @@ public class ClassLoaderResourceLoader e
public ResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
String resourceName, String resourceVersion)
{
- if (_developmentStage && libraryName != null &&
- ResourceUtils.JAVAX_FACES_LIBRARY_NAME.equals(libraryName) &&
- ResourceUtils.JSF_JS_RESOURCE_NAME.equals(resourceName))
- {
+ //if (_developmentStage && libraryName != null &&
+ // ResourceUtils.JAVAX_FACES_LIBRARY_NAME.equals(libraryName) &&
+ // ResourceUtils.JSF_JS_RESOURCE_NAME.equals(resourceName))
+ //{
// InternalClassLoaderResourceLoader will serve it, so return null in this case.
- return null;
- } else if (_developmentStage && libraryName != null &&
- ResourceUtils.MYFACES_LIBRARY_NAME.equals(libraryName) &&
- ResourceUtils.MYFACES_JS_RESOURCE_NAME.equals(resourceName)) {
+ // return null;
+ //} else if (_developmentStage && libraryName != null &&
+ // ResourceUtils.MYFACES_LIBRARY_NAME.equals(libraryName) &&
+ // ResourceUtils.MYFACES_JS_RESOURCE_NAME.equals(resourceName)) {
// InternalClassLoaderResourceLoader will serve it, so return null in this case.
- return null;
- } else
- {
+ // return null;
+ //} else
+ //{
return new ResourceMetaImpl(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
- }
+ //}
}
/**
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ExternalContextResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ExternalContextResourceLoader.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ExternalContextResourceLoader.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ExternalContextResourceLoader.java Thu Nov 17 00:16:48 2011
@@ -39,14 +39,14 @@ public class ExternalContextResourceLoad
*
* Used on getLibraryVersion to filter resource directories
**/
- protected static Pattern VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*/");
+ protected static final Pattern VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*/");
/**
* It checks version like this: /1.js, /1_0.js, /1_0_0.js, /100_100.js
*
* Used on getResourceVersion to filter resources
**/
- protected static Pattern RESOURCE_VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*\\..*");
+ protected static final Pattern RESOURCE_VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*\\..*");
public ExternalContextResourceLoader(String prefix)
{
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java Thu Nov 17 00:16:48 2011
@@ -38,11 +38,20 @@ public class ResourceHandlerCache
private Boolean _resourceCacheEnabled = null;
private Map<ResourceKey, ResourceValue> _resourceCacheMap = null;
- @JSFWebConfigParam(defaultValue = "500", since = "2.0.2")
+ /**
+ * Controls the size of the cache used to check if a resource exists or not.
+ *
+ * <p>See org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED for details.</p>
+ */
+ @JSFWebConfigParam(defaultValue = "500", since = "2.0.2", group="resources", classType="java.lang.Integer", tags="performance")
private static final String RESOURCE_HANDLER_CACHE_SIZE_ATTRIBUTE = "org.apache.myfaces.RESOURCE_HANDLER_CACHE_SIZE";
private static final int RESOURCE_HANDLER_CACHE_DEFAULT_SIZE = 500;
- @JSFWebConfigParam(defaultValue = "true", since = "2.0.2")
+ /**
+ * Enable or disable the cache used to "remember" if a resource handled by the default ResourceHandler exists or not.
+ *
+ */
+ @JSFWebConfigParam(defaultValue = "true", since = "2.0.2", group="resources", expectedValues="true,false", tags="performance")
private static final String RESOURCE_HANDLER_CACHE_ENABLED_ATTRIBUTE = "org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED";
private static final boolean RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT = true;
Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderUtils.java?rev=1202947&r1=1202946&r2=1202947&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderUtils.java (original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderUtils.java Thu Nov 17 00:16:48 2011
@@ -40,14 +40,14 @@ public class ResourceLoaderUtils
"EEE, dd MMM yyyy HH:mm:ss zzz", "EEEEEE, dd-MMM-yy HH:mm:ss zzz",
"EEE MMMM d HH:mm:ss yyyy" };
- private static TimeZone __GMT = TimeZone.getTimeZone("GMT");
+ private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
public static String formatDateHeader(long value)
{
SimpleDateFormat format = new SimpleDateFormat(
HTTP_RESPONSE_DATE_HEADER,
Locale.US);
- format.setTimeZone(__GMT);
+ format.setTimeZone(GMT);
return format.format(new Date(value));
}
@@ -60,12 +60,11 @@ public class ResourceLoaderUtils
{
SimpleDateFormat format = new SimpleDateFormat(
HTTP_REQUEST_DATE_HEADER[i], Locale.US);
- format.setTimeZone(__GMT);
+ format.setTimeZone(GMT);
date = format.parse(value);
}
catch (ParseException e)
{
- ;
}
}
if (date == null)
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/
------------------------------------------------------------------------------
bugtraq:number = true
Added: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java?rev=1202947&view=auto
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java (added)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java Thu Nov 17 00:16:48 2011
@@ -0,0 +1,304 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.taglib;
+
+import org.apache.myfaces.shared.renderkit.JSFAttr;
+
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.webapp.UIComponentELTag;
+
+/**
+ * @author Manfred Geiler (latest modification by $Author$)
+ * @author Bruno Aranda (JSR-252)
+ * @version $Revision$ $Date$
+ */
+public abstract class UIComponentELTagBase extends UIComponentELTag
+{
+ //private static final Log log = LogFactory.getLog(UIComponentTagBase.class);
+
+ //UIComponent attributes
+ private ValueExpression _forceId;
+
+ private ValueExpression _forceIdIndex;
+ private static final Boolean DEFAULT_FORCE_ID_INDEX_VALUE = Boolean.TRUE;
+
+ private ValueExpression _javascriptLocation;
+ private ValueExpression _imageLocation;
+ private ValueExpression _styleLocation;
+
+ //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
+ private ValueExpression _value;
+ private ValueExpression _converter;
+
+ //attributes id, rendered and binding are handled by UIComponentTag
+
+ public void release()
+ {
+ super.release();
+
+ _forceId = null;
+ _forceIdIndex = null;
+
+ _value = null;
+ _converter = null;
+
+ _javascriptLocation = null;
+ _imageLocation = null;
+ _styleLocation = null;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+
+ setBooleanProperty(component,
+ org.apache.myfaces.shared.renderkit.JSFAttr.FORCE_ID_ATTR,
+ _forceId);
+ setBooleanProperty(
+ component,
+ org.apache.myfaces.shared.renderkit.JSFAttr.FORCE_ID_INDEX_ATTR,
+ _forceIdIndex, DEFAULT_FORCE_ID_INDEX_VALUE);
+ if (_javascriptLocation != null)
+ {
+ setStringProperty(component, JSFAttr.JAVASCRIPT_LOCATION,
+ _javascriptLocation);
+ }
+ if (_imageLocation != null)
+ {
+ setStringProperty(component, JSFAttr.IMAGE_LOCATION, _imageLocation);
+ }
+ if (_styleLocation != null)
+ {
+ setStringProperty(component, JSFAttr.STYLE_LOCATION, _styleLocation);
+ }
+
+ //rendererType already handled by UIComponentTag
+
+ setValueProperty(component, _value);
+ setConverterProperty(component, _converter);
+ }
+
+ /**
+ * Sets the forceId attribute of the tag. NOTE: Not every tag that extends this class will
+ * actually make use of this attribute. Check the TLD to see which components actually
+ * implement it.
+ *
+ * @param aForceId The value of the forceId attribute.
+ */
+ public void setForceId(ValueExpression aForceId)
+ {
+ _forceId = aForceId;
+ }
+
+ /**
+ * Sets the forceIdIndex attribute of the tag. NOTE: Not every tag that extends this class will
+ * actually make use of this attribute. Check the TLD to see which components actually implement it.
+ *
+ * @param aForceIdIndex The value of the forceIdIndex attribute.
+ */
+ public void setForceIdIndex(ValueExpression aForceIdIndex)
+ {
+ _forceIdIndex = aForceIdIndex;
+ }
+
+ public void setValue(ValueExpression value)
+ {
+ _value = value;
+ }
+
+ public void setConverter(ValueExpression converter)
+ {
+ _converter = converter;
+ }
+
+ /**
+ * Sets the javascript location attribute of the tag. NOTE: Not every tag that extends this class will
+ * actually make use of this attribute. Check the TLD to see which components actually implement it.
+ *
+ * @param aJavascriptLocation The alternate javascript location to use.
+ */
+ public void setJavascriptLocation(ValueExpression aJavascriptLocation)
+ {
+ _javascriptLocation = aJavascriptLocation;
+ }
+
+ /**
+ * Sets the image location attribute of the tag. NOTE: Not every tag that extends this class will
+ * actually make use of this attribute. Check the TLD to see which components actually implement it.
+ *
+ * @param aImageLocation The alternate image location to use.
+ */
+ public void setImageLocation(ValueExpression aImageLocation)
+ {
+ _imageLocation = aImageLocation;
+ }
+
+ /**
+ * Sets the style location attribute of the tag. NOTE: Not every tag that extends this class will
+ * actually make use of this attribute. Check the TLD to see which components actually implement it.
+ *
+ * @param aStyleLocation The alternate style location to use.
+ */
+ public void setStyleLocation(ValueExpression aStyleLocation)
+ {
+ _styleLocation = aStyleLocation;
+ }
+
+ // sub class helpers
+
+ protected void setIntegerProperty(UIComponent component, String propName,
+ ValueExpression value)
+ {
+ UIComponentELTagUtils.setIntegerProperty(component, propName, value);
+ }
+
+ protected void setIntegerProperty(UIComponent component, String propName,
+ ValueExpression value, Integer defaultValue)
+ {
+ UIComponentELTagUtils.setIntegerProperty(component, propName, value,
+ defaultValue);
+ }
+
+ protected void setLongProperty(UIComponent component, String propName,
+ ValueExpression value)
+ {
+ UIComponentELTagUtils.setLongProperty(component, propName, value);
+ }
+
+ protected void setLongProperty(UIComponent component, String propName,
+ ValueExpression value, Long defaultValue)
+ {
+ UIComponentELTagUtils.setLongProperty(component, propName, value,
+ defaultValue);
+ }
+
+ @Deprecated
+ protected void setStringProperty(UIComponent component, String propName,
+ String value)
+ {
+ UIComponentTagUtils.setStringProperty(getFacesContext(), component,
+ propName, value);
+ }
+
+ protected void setStringProperty(UIComponent component, String propName,
+ ValueExpression value)
+ {
+ UIComponentELTagUtils.setStringProperty(component, propName, value);
+ }
+
+ protected void setStringProperty(UIComponent component, String propName,
+ ValueExpression value, String defaultValue)
+ {
+ UIComponentELTagUtils.setStringProperty(component, propName, value,
+ defaultValue);
+ }
+
+ @Deprecated
+ protected void setBooleanProperty(UIComponent component, String propName,
+ String value)
+ {
+ UIComponentTagUtils.setBooleanProperty(getFacesContext(), component,
+ propName, value);
+ }
+
+ protected void setBooleanProperty(UIComponent component, String propName,
+ ValueExpression value)
+ {
+ UIComponentELTagUtils.setBooleanProperty(component, propName, value);
+ }
+
+ protected void setBooleanProperty(UIComponent component, String propName,
+ ValueExpression value, Boolean defaultValue)
+ {
+ UIComponentELTagUtils.setBooleanProperty(component, propName, value,
+ defaultValue);
+ }
+
+ private void setValueProperty(UIComponent component, ValueExpression value)
+ {
+ UIComponentELTagUtils.setValueProperty(getFacesContext(), component,
+ value);
+ }
+
+ private void setConverterProperty(UIComponent component,
+ ValueExpression value)
+ {
+ UIComponentELTagUtils.setConverterProperty(getFacesContext(),
+ component, value);
+ }
+
+ protected void addValidatorProperty(UIComponent component,
+ MethodExpression value)
+ {
+ UIComponentELTagUtils.addValidatorProperty(getFacesContext(),
+ component, value);
+ }
+
+ @Deprecated
+ protected void setActionProperty(UIComponent component, String action)
+ {
+ UIComponentTagUtils.setActionProperty(getFacesContext(), component,
+ action);
+ }
+
+ protected void setActionProperty(UIComponent component,
+ MethodExpression action)
+ {
+ UIComponentELTagUtils.setActionProperty(getFacesContext(), component,
+ action);
+ }
+
+ @Deprecated
+ protected void setActionListenerProperty(UIComponent component,
+ String actionListener)
+ {
+ UIComponentTagUtils.setActionListenerProperty(getFacesContext(),
+ component, actionListener);
+ }
+
+ protected void setActionListenerProperty(UIComponent component,
+ MethodExpression actionListener)
+ {
+ UIComponentELTagUtils.addActionListenerProperty(getFacesContext(),
+ component, actionListener);
+ }
+
+ protected void addValueChangedListenerProperty(UIComponent component,
+ MethodExpression valueChangedListener)
+ {
+ UIComponentELTagUtils.addValueChangedListenerProperty(
+ getFacesContext(), component, valueChangedListener);
+ }
+
+ protected void setValueBinding(UIComponent component, String propName,
+ ValueExpression value)
+ {
+ UIComponentELTagUtils.setValueBinding(getFacesContext(), component,
+ propName, value);
+ }
+
+ protected Object evaluateValueExpression(ValueExpression expression)
+ {
+ return UIComponentELTagUtils.evaluateValueExpression(getFacesContext()
+ .getELContext(), expression);
+ }
+
+}
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java?rev=1202947&view=auto
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java (added)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java Thu Nov 17 00:16:48 2011
@@ -0,0 +1,417 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.taglib;
+
+import java.util.logging.Logger;
+
+import javax.el.ELContext;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.component.ActionSource2;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIGraphic;
+import javax.faces.component.UIParameter;
+import javax.faces.component.UISelectBoolean;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.event.MethodExpressionActionListener;
+import javax.faces.event.MethodExpressionValueChangeListener;
+import javax.faces.validator.MethodExpressionValidator;
+
+/**
+ * @author Manfred Geiler (latest modification by $Author$)
+ * @author Bruno Aranda (JSR-252)
+ * @version $Revision$ $Date$
+ *
+ * @since 1.2
+ */
+public class UIComponentELTagUtils
+{
+ //private static final Log log = LogFactory.getLog(UIComponentELTagUtils.class);
+ private static final Logger log = Logger
+ .getLogger(UIComponentELTagUtils.class.getName());
+
+ private UIComponentELTagUtils()
+ {
+ } //util class, no instantiation allowed
+
+ /**
+ * @since 1.2
+ */
+ public static void setIntegerProperty(UIComponent component,
+ String propName, ValueExpression value)
+ {
+ setIntegerProperty(component, propName, value, null);
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setIntegerProperty(UIComponent component,
+ String propName, ValueExpression value, Integer defaultValue)
+ {
+ if (value != null)
+ {
+ if (value.isLiteralText())
+ {
+ component.getAttributes().put(propName,
+ Integer.valueOf(value.getExpressionString()));
+ }
+ else
+ {
+ component.setValueExpression(propName, value);
+ }
+ }
+ else
+ {
+ if (defaultValue != null)
+ {
+ component.getAttributes().put(propName, defaultValue);
+ }
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setLongProperty(UIComponent component, String propName,
+ ValueExpression value)
+ {
+ setLongProperty(component, propName, value, null);
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setLongProperty(UIComponent component, String propName,
+ ValueExpression value, Long defaultValue)
+ {
+ if (value != null)
+ {
+ if (value.isLiteralText())
+ {
+ component.getAttributes().put(propName,
+ Long.valueOf(value.getExpressionString()));
+ }
+ else
+ {
+ component.setValueExpression(propName, value);
+ }
+ }
+ else
+ {
+ if (defaultValue != null)
+ {
+ component.getAttributes().put(propName, defaultValue);
+ }
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setStringProperty(UIComponent component,
+ String propName, ValueExpression value)
+ {
+ setStringProperty(component, propName, value, null);
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setStringProperty(UIComponent component,
+ String propName, ValueExpression value, String defaultValue)
+ {
+ if (value != null)
+ {
+ if (value.isLiteralText())
+ {
+ component.getAttributes().put(propName,
+ value.getExpressionString());
+ }
+ else
+ {
+ component.setValueExpression(propName, value);
+ }
+ }
+ else
+ {
+ if (defaultValue != null)
+ {
+ component.getAttributes().put(propName, defaultValue);
+ }
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setBooleanProperty(UIComponent component,
+ String propName, ValueExpression value)
+ {
+ setBooleanProperty(component, propName, value, null);
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setBooleanProperty(UIComponent component,
+ String propName, ValueExpression value, Boolean defaultValue)
+ {
+ if (value != null)
+ {
+ if (value.isLiteralText())
+ {
+ component.getAttributes().put(propName,
+ Boolean.valueOf(value.getExpressionString()));
+ }
+ else
+ {
+ component.setValueExpression(propName, value);
+ }
+ }
+ else
+ {
+ if (defaultValue != null)
+ {
+ component.getAttributes().put(propName, defaultValue);
+ }
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setValueProperty(FacesContext context,
+ UIComponent component, ValueExpression value)
+ {
+ if (value != null)
+ {
+ if (!value.isLiteralText())
+ {
+ component.setValueExpression(
+ org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR,
+ value);
+ }
+ else if (component instanceof UICommand)
+ {
+ ((UICommand) component).setValue(value.getExpressionString());
+ }
+ else if (component instanceof UIParameter)
+ {
+ ((UIParameter) component).setValue(value.getExpressionString());
+ }
+ else if (component instanceof UISelectBoolean)
+ {
+ ((UISelectBoolean) component).setValue(Boolean.valueOf(value
+ .getExpressionString()));
+ }
+ else if (component instanceof UIGraphic)
+ {
+ ((UIGraphic) component).setValue(value.getExpressionString());
+ }
+ //Since many input components are ValueHolders the special components
+ //must come first, ValueHolder is the last resort.
+ else if (component instanceof ValueHolder)
+ {
+ ((ValueHolder) component).setValue(value.getExpressionString());
+ }
+ else
+ {
+ log.severe("Component " + component.getClass().getName()
+ + " is no ValueHolder, cannot set value.");
+ }
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setConverterProperty(FacesContext context,
+ UIComponent component, ValueExpression value)
+ {
+ if (value != null)
+ {
+ if (component instanceof ValueHolder)
+ {
+ if (value.isLiteralText())
+ {
+ FacesContext facesContext = FacesContext
+ .getCurrentInstance();
+ Converter converter = facesContext.getApplication()
+ .createConverter(value.getExpressionString());
+ ((ValueHolder) component).setConverter(converter);
+ }
+ else
+ {
+ component
+ .setValueExpression(
+ org.apache.myfaces.shared.renderkit.JSFAttr.CONVERTER_ATTR,
+ value);
+ }
+ }
+ else
+ {
+ log.severe("Component " + component.getClass().getName()
+ + " is no ValueHolder, cannot set value.");
+ }
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void addValidatorProperty(FacesContext context,
+ UIComponent component, MethodExpression validator)
+ {
+ if (validator != null)
+ {
+ if (!(component instanceof EditableValueHolder))
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no EditableValueHolder");
+ }
+
+ ((EditableValueHolder) component)
+ .addValidator(new MethodExpressionValidator(validator));
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setValueBinding(FacesContext context,
+ UIComponent component, String propName, ValueExpression value)
+ {
+ if (value != null)
+ {
+ if (!value.isLiteralText())
+ {
+ component.setValueExpression(propName, value);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context) + " attribute "
+ + propName + " must be a value reference, was " + value);
+ }
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void setActionProperty(FacesContext context,
+ UIComponent component, MethodExpression action)
+ {
+ if (action != null)
+ {
+ if (!(component instanceof ActionSource2))
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no ActionSource2");
+ }
+
+ ((ActionSource2) component).setActionExpression(action);
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void addActionListenerProperty(FacesContext context,
+ UIComponent component, MethodExpression actionListener)
+ {
+ if (actionListener != null)
+ {
+ if (!(component instanceof ActionSource2))
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no ActionSource");
+ }
+
+ ((ActionSource2) component)
+ .addActionListener(new MethodExpressionActionListener(
+ actionListener));
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static void addValueChangedListenerProperty(FacesContext context,
+ UIComponent component, MethodExpression valueChangedListener)
+ {
+ if (valueChangedListener != null)
+ {
+ if (!(component instanceof EditableValueHolder))
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no EditableValueHolder");
+ }
+
+ ((EditableValueHolder) component)
+ .addValueChangeListener(new MethodExpressionValueChangeListener(
+ valueChangedListener));
+ }
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static Object evaluateValueExpression(ELContext elContext,
+ ValueExpression valueExpression)
+ {
+ return valueExpression.isLiteralText() ? valueExpression
+ .getExpressionString() : valueExpression.getValue(elContext);
+ }
+
+ /**
+ * @since 1.2
+ */
+ public static Boolean getBooleanValue(ELContext elContext,
+ ValueExpression valueExpression)
+ {
+ if (valueExpression.isLiteralText())
+ {
+ return Boolean.valueOf(valueExpression.getExpressionString());
+ }
+
+ return (Boolean) valueExpression.getValue(elContext);
+ }
+
+ public static Integer getIntegerValue(ELContext elContext,
+ ValueExpression valueExpression)
+ {
+ if (valueExpression.isLiteralText())
+ {
+ return Integer.valueOf(valueExpression.getExpressionString());
+ }
+
+ return (Integer) valueExpression.getValue(elContext);
+ }
+
+}
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java?rev=1202947&view=auto
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java (added)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java Thu Nov 17 00:16:48 2011
@@ -0,0 +1,361 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.taglib;
+
+import java.util.logging.Logger;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIGraphic;
+import javax.faces.component.UIParameter;
+import javax.faces.component.UISelectBoolean;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.webapp.UIComponentTag;
+
+import org.apache.myfaces.shared.el.SimpleActionMethodBinding;
+
+/**
+ * @author Manfred Geiler (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ *
+ * @deprecated replaced by @{link UIComponentELTagUtils}
+ */
+public class UIComponentTagUtils
+{
+ //private static final Log log = LogFactory.getLog(UIComponentTagUtils.class);
+ private static final Logger log = Logger
+ .getLogger(UIComponentTagUtils.class.getName());
+
+ private static final Class[] VALIDATOR_ARGS = { FacesContext.class,
+ UIComponent.class, Object.class };
+ private static final Class[] ACTION_LISTENER_ARGS = { ActionEvent.class };
+ private static final Class[] VALUE_LISTENER_ARGS = { ValueChangeEvent.class };
+
+ private UIComponentTagUtils()
+ {
+ } //util class, no instantiation allowed
+
+ public static boolean isValueReference(String v)
+ {
+ return UIComponentTag.isValueReference(v);
+ }
+
+ public static void setIntegerProperty(FacesContext context,
+ UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Integer.valueOf(value));
+ }
+ }
+ }
+
+ public static void setLongProperty(FacesContext context,
+ UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //FIXME: should use converter maybe?
+ component.getAttributes().put(propName, Long.valueOf(value));
+ }
+ }
+ }
+
+ public static void setStringProperty(FacesContext context,
+ UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //TODO: Warning if component has no such property (with reflection)
+ component.getAttributes().put(propName, value);
+ }
+ }
+ }
+
+ public static void setBooleanProperty(FacesContext context,
+ UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ //TODO: More sophisticated way to convert boolean value (yes/no, 1/0, on/off, etc.)
+ component.getAttributes().put(propName, Boolean.valueOf(value));
+ }
+ }
+ }
+
+ public static void setValueProperty(FacesContext context,
+ UIComponent component, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
+ component.setValueBinding(
+ org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR,
+ vb);
+ }
+ else if (component instanceof UICommand)
+ {
+ ((UICommand) component).setValue(value);
+ }
+ else if (component instanceof UIParameter)
+ {
+ ((UIParameter) component).setValue(value);
+ }
+ else if (component instanceof UISelectBoolean)
+ {
+ ((UISelectBoolean) component).setValue(Boolean.valueOf(value));
+ }
+ else if (component instanceof UIGraphic)
+ {
+ ((UIGraphic) component).setValue(value);
+ }
+ //Since many input components are ValueHolders the special components
+ //must come first, ValueHolder is the last resort.
+ else if (component instanceof ValueHolder)
+ {
+ ((ValueHolder) component).setValue(value);
+ }
+ else
+ {
+ log.severe("Component " + component.getClass().getName()
+ + " is no ValueHolder, cannot set value.");
+ }
+ }
+ }
+
+ public static void setConverterProperty(FacesContext context,
+ UIComponent component, String value)
+ {
+ if (value != null)
+ {
+ if (component instanceof ValueHolder)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = context.getApplication()
+ .createValueBinding(value);
+ component
+ .setValueBinding(
+ org.apache.myfaces.shared.renderkit.JSFAttr.CONVERTER_ATTR,
+ vb);
+ }
+ else
+ {
+ FacesContext facesContext = FacesContext
+ .getCurrentInstance();
+ Converter converter = facesContext.getApplication()
+ .createConverter(value);
+ ((ValueHolder) component).setConverter(converter);
+ }
+ }
+ else
+ {
+ log.severe("Component " + component.getClass().getName()
+ + " is no ValueHolder, cannot set value.");
+ }
+ }
+ }
+
+ public static void setValidatorProperty(FacesContext context,
+ UIComponent component, String validator)
+ {
+ if (validator != null)
+ {
+ if (!(component instanceof EditableValueHolder))
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no EditableValueHolder");
+ }
+ if (isValueReference(validator))
+ {
+ MethodBinding mb = context.getApplication()
+ .createMethodBinding(validator, VALIDATOR_ARGS);
+ ((EditableValueHolder) component).setValidator(mb);
+ }
+ else
+ {
+ log.severe("Component " + component.getClientId(context)
+ + " has invalid validation expression " + validator);
+ }
+ }
+ }
+
+ public static void setValueBinding(FacesContext context,
+ UIComponent component, String propName, String value)
+ {
+ if (value != null)
+ {
+ if (isValueReference(value))
+ {
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
+ component.setValueBinding(propName, vb);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context) + " attribute "
+ + propName + " must be a value reference, was " + value);
+ }
+ }
+ }
+
+ public static void setActionProperty(FacesContext context,
+ UIComponent component, String action)
+ {
+ if (action != null)
+ {
+ if (!(component instanceof ActionSource))
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no ActionSource");
+ }
+ MethodBinding mb;
+ if (isValueReference(action))
+ {
+ mb = context.getApplication().createMethodBinding(action, null);
+ }
+ else
+ {
+ mb = new SimpleActionMethodBinding(action);
+ }
+ ((ActionSource) component).setAction(mb);
+ }
+ }
+
+ public static void setActionListenerProperty(FacesContext context,
+ UIComponent component, String actionListener)
+ {
+ if (actionListener != null)
+ {
+ if (!(component instanceof ActionSource))
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no ActionSource");
+ }
+ if (isValueReference(actionListener))
+ {
+ MethodBinding mb = context.getApplication()
+ .createMethodBinding(actionListener,
+ ACTION_LISTENER_ARGS);
+
+ /**
+ if(! Void.class.equals(mb.getType(context)))
+ {
+ throw new IllegalArgumentException(
+ actionListener +
+ " : Return types for action listeners must be void, see JSF spec. 3.2.1.1");
+ }
+ */
+
+ ((ActionSource) component).setActionListener(mb);
+ }
+ else
+ {
+ log.severe("Component " + component.getClientId(context)
+ + " has invalid actionListener value: "
+ + actionListener);
+ }
+ }
+ }
+
+ public static void setValueChangedListenerProperty(FacesContext context,
+ UIComponent component, String valueChangedListener)
+ {
+ if (valueChangedListener != null)
+ {
+ if (!(component instanceof EditableValueHolder))
+ {
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no EditableValueHolder");
+ }
+ if (isValueReference(valueChangedListener))
+ {
+ MethodBinding mb = context.getApplication()
+ .createMethodBinding(valueChangedListener,
+ VALUE_LISTENER_ARGS);
+ /**
+ if(! Void.class.equals(mb.getType(context)))
+ {
+ throw new IllegalArgumentException(
+ valueChangedListener +
+ " : Return types for value change listeners must be void, see JSF spec. 3.2.5.1");
+ }
+ */
+
+ ((EditableValueHolder) component).setValueChangeListener(mb);
+ }
+ else
+ {
+ log.severe("Component " + component.getClientId(context)
+ + " has invalid valueChangedListener expression "
+ + valueChangedListener);
+ }
+ }
+ }
+
+}
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/core/
------------------------------------------------------------------------------
bugtraq:number = true
Added: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/core/SelectItemTagBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/core/SelectItemTagBase.java?rev=1202947&view=auto
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/core/SelectItemTagBase.java (added)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/core/SelectItemTagBase.java Thu Nov 17 00:16:48 2011
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.taglib.core;
+
+import org.apache.myfaces.shared.renderkit.JSFAttr;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+
+/**
+ * @author Thomas Spiegl (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class SelectItemTagBase
+ extends org.apache.myfaces.shared.taglib.UIComponentELTagBase
+{
+ //private static final Log log = LogFactory.getLog(SelectItemTag.class);
+
+ public String getComponentType()
+ {
+ return "javax.faces.SelectItem";
+ }
+
+ public String getRendererType()
+ {
+ return null;
+ }
+
+ // UISelectItem attributes
+ private ValueExpression _itemDisabled;
+ private ValueExpression _itemDescription;
+ private ValueExpression _itemLabel;
+ private ValueExpression _itemValue;
+ private ValueExpression _escape;
+ private ValueExpression _noSelectionOption;
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+
+ setBooleanProperty(component, JSFAttr.ITEM_DISABLED_ATTR, _itemDisabled);
+ setStringProperty(component, JSFAttr.ITEM_DESCRIPTION_ATTR, _itemDescription);
+ setStringProperty(component, org.apache.myfaces.shared.renderkit.JSFAttr.ITEM_LABEL_ATTR, _itemLabel);
+ setStringProperty(component, JSFAttr.ITEM_VALUE_ATTR, _itemValue);
+ setBooleanProperty(component, JSFAttr.ITEM_ESCAPED_ATTR, _escape, Boolean.TRUE);
+ setBooleanProperty(component, JSFAttr.NO_SELECTION_OPTION_ATTR, _noSelectionOption, Boolean.FALSE);
+ }
+
+ public void setItemDisabled(ValueExpression itemDisabled)
+ {
+ _itemDisabled = itemDisabled;
+ }
+
+ public void setItemDescription(ValueExpression itemDescription)
+ {
+ _itemDescription = itemDescription;
+ }
+
+ public void setItemLabel(ValueExpression itemLabel)
+ {
+ _itemLabel = itemLabel;
+ }
+
+ @Deprecated
+ protected void setItemValue(String itemValue)
+ {
+ _itemValue = getFacesContext().getApplication().getExpressionFactory().createValueExpression(
+ getFacesContext().getELContext(),itemValue,String.class);
+ }
+
+ public void setItemValue(ValueExpression itemValue)
+ {
+ _itemValue = itemValue;
+ }
+
+ public void setEscape(ValueExpression escape)
+ {
+ _escape = escape;
+ }
+
+ protected ValueExpression getItemValue()
+ {
+ return _itemValue;
+ }
+
+ public void setNoSelectionOption(ValueExpression noSelectionOption)
+ {
+ _noSelectionOption = noSelectionOption;
+ }
+
+}
Propchange: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/taglib/core/SelectItemTagBase.java
------------------------------------------------------------------------------
svn:eol-style = native