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 2012/03/30 20:14:26 UTC
svn commit: r1307565 [2/6] - in
/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared:
application/ renderkit/ renderkit/html/ resource/ taglib/ taglib/core/
util/ util/io/ util/renderkit/
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java?rev=1307565&r1=1307564&r2=1307565&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTableRendererBase.java Fri Mar 30 18:14:25 2012
@@ -327,6 +327,29 @@ public class HtmlTableRendererBase exten
}
}
+ private Integer[] getBodyRows(FacesContext facesContext, UIComponent component)
+ {
+ Integer[] bodyrows = null;
+ String bodyrowsAttr = (String) component.getAttributes().get(JSFAttr.BODYROWS_ATTR);
+ if(bodyrowsAttr != null && !"".equals(bodyrowsAttr))
+ {
+ String[] bodyrowsString = StringUtils.trim(StringUtils.splitShortString(bodyrowsAttr, ','));
+ // parsing with no exception handling, because of JSF-spec:
+ // "If present, this must be a comma separated list of integers."
+ bodyrows = new Integer[bodyrowsString.length];
+ for(int i = 0; i < bodyrowsString.length; i++)
+ {
+ bodyrows[i] = new Integer(bodyrowsString[i]);
+ }
+
+ }
+ else
+ {
+ bodyrows = ZERO_INT_ARRAY;
+ }
+ return bodyrows;
+ }
+
/**
* Renders everything inside the TBODY tag by iterating over the row objects
* between offsets first and first+rows and applying the UIColumn components
@@ -337,12 +360,19 @@ public class HtmlTableRendererBase exten
*/
public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException
{
-
UIData uiData = (UIData) component;
ResponseWriter writer = facesContext.getResponseWriter();
int rowCount = uiData.getRowCount();
+ int newspaperColumns = getNewspaperColumns(component);
+
+ if (rowCount == -1 && newspaperColumns == 1)
+ {
+ encodeInnerHtmlUnknownRowCount(facesContext, component);
+ return;
+ }
+
if (rowCount == 0)
{
//nothing to render, to get valid xhtml we render an empty dummy row
@@ -377,7 +407,6 @@ public class HtmlTableRendererBase exten
}
}
- int newspaperColumns = getNewspaperColumns(component);
int newspaperRows;
if((last - first) % newspaperColumns == 0)
{
@@ -390,24 +419,7 @@ public class HtmlTableRendererBase exten
boolean newspaperHorizontalOrientation = isNewspaperHorizontalOrientation(component);
// get the row indizes for which a new TBODY element should be created
- Integer[] bodyrows = null;
- String bodyrowsAttr = (String) component.getAttributes().get(JSFAttr.BODYROWS_ATTR);
- if(bodyrowsAttr != null && !"".equals(bodyrowsAttr))
- {
- String[] bodyrowsString = StringUtils.trim(StringUtils.splitShortString(bodyrowsAttr, ','));
- // parsing with no exception handling, because of JSF-spec:
- // "If present, this must be a comma separated list of integers."
- bodyrows = new Integer[bodyrowsString.length];
- for(int i = 0; i < bodyrowsString.length; i++)
- {
- bodyrows[i] = new Integer(bodyrowsString[i]);
- }
-
- }
- else
- {
- bodyrows = ZERO_INT_ARRAY;
- }
+ Integer[] bodyrows = getBodyRows(facesContext, component);
int bodyrowsCount = 0;
// walk through the newspaper rows
@@ -520,6 +532,113 @@ public class HtmlTableRendererBase exten
writer.endElement(HTML.TBODY_ELEM);
}
}
+
+ private void encodeInnerHtmlUnknownRowCount(FacesContext facesContext, UIComponent component)throws IOException
+ {
+ UIData uiData = (UIData) component;
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ Styles styles = getStyles(uiData);
+
+ Integer[] bodyrows = getBodyRows(facesContext, component);
+ int bodyrowsCount = 0;
+
+ int first = uiData.getFirst();
+ int rows = uiData.getRows();
+ int currentRow = first;
+ boolean isRowRendered = false;
+
+ while(true)
+ {
+ uiData.setRowIndex(currentRow);
+ if (!uiData.isRowAvailable())
+ {
+ break;
+ }
+
+ isRowRendered = true;
+
+ // first column in table, start new row
+ beforeRow(facesContext, uiData);
+
+ // is the current row listed in the bodyrows attribute
+ if(ArrayUtils.contains(bodyrows, currentRow))
+ {
+ // close any preopened TBODY element first
+ if(bodyrowsCount != 0)
+ {
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ writer.endElement(HTML.TBODY_ELEM);
+ }
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ writer.startElement(HTML.TBODY_ELEM, uiData);
+ // Do not attach bodyrowsCount to the first TBODY element, because of backward compatibility
+ writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext) + ":tbody_element" +
+ (bodyrowsCount == 0 ? "" : bodyrowsCount), null);
+ bodyrowsCount++;
+ }
+
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ renderRowStart(facesContext, writer, uiData, styles, currentRow);
+
+ List<UIComponent> children = null;
+ for (int j = 0, size = getChildCount(component); j < size; j++)
+ {
+ if (children == null)
+ {
+ children = getChildren(component);
+ }
+ UIComponent child = (UIComponent) children.get(j);
+ if (child.isRendered())
+ {
+ boolean columnRendering = child instanceof UIColumn;
+
+ if (columnRendering)
+ {
+ beforeColumn(facesContext, uiData, j);
+ }
+
+ encodeColumnChild(facesContext, writer, uiData, child,
+ styles, j);
+
+ if (columnRendering)
+ {
+ afterColumn(facesContext, uiData, j);
+ }
+ }
+ }
+
+ renderRowEnd(facesContext, writer, uiData);
+ afterRow(facesContext, uiData);
+
+ currentRow++;
+
+ if (rows > 0 && currentRow-first > rows )
+ {
+ break;
+ }
+ }
+
+ if (!isRowRendered)
+ {
+ //nothing to render, to get valid xhtml we render an empty dummy row
+ writer.startElement(HTML.TBODY_ELEM, uiData);
+ writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext) + ":tbody_element", null);
+ writer.startElement(HTML.TR_ELEM, uiData);
+ writer.startElement(HTML.TD_ELEM, uiData);
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEM);
+ writer.endElement(HTML.TBODY_ELEM);
+ return;
+ }
+
+ if(bodyrowsCount != 0)
+ {
+ // close the last TBODY element
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ writer.endElement(HTML.TBODY_ELEM);
+ }
+ }
protected void encodeColumnChild(FacesContext facesContext, ResponseWriter writer,
UIData uiData, UIComponent component, Styles styles, int columnStyleIndex) throws IOException
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java?rev=1307565&r1=1307564&r2=1307565&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java Fri Mar 30 18:14:25 2012
@@ -1,160 +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 StringBuilder buffer = new StringBuilder();
- 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(StringBuilder 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();
- }
-}
+/*
+ * 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 StringBuilder buffer = new StringBuilder();
+ 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(StringBuilder 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();
+ }
+}
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java?rev=1307565&r1=1307564&r2=1307565&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java Fri Mar 30 18:14:25 2012
@@ -1,100 +1,100 @@
-/*
- * 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.resource;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Comparator;
-
-import javax.faces.FacesWrapper;
-
-/**
- *
- * @author Leonardo Uribe
- *
- */
-public abstract class ResourceLoaderWrapper extends ResourceLoader implements FacesWrapper<ResourceLoader>
-{
-
- public ResourceLoaderWrapper()
- {
- super(null);
- }
-
- public String getResourceVersion(String path)
- {
- return getWrapped().getResourceVersion(path);
- }
-
- public String getLibraryVersion(String path)
- {
- return getWrapped().getLibraryVersion(path);
- }
-
- public URL getResourceURL(ResourceMeta resourceMeta)
- {
- return getWrapped().getResourceURL(resourceMeta);
- }
-
- public InputStream getResourceInputStream(ResourceMeta resourceMeta)
- {
- return getWrapped().getResourceInputStream(resourceMeta);
- }
-
- public ResourceMeta createResourceMeta(String prefix, String libraryName,
- String libraryVersion, String resourceName, String resourceVersion)
- {
- return getWrapped().createResourceMeta(prefix, libraryName, libraryVersion,
- resourceName, resourceVersion);
- }
-
- public boolean libraryExists(String libraryName)
- {
- return getWrapped().libraryExists(libraryName);
- }
-
- public String getPrefix()
- {
- return getWrapped().getPrefix();
- }
-
- public void setPrefix(String prefix)
- {
- getWrapped().setPrefix(prefix);
- }
-
- @Override
- public boolean resourceExists(ResourceMeta resourceMeta)
- {
- return getWrapped().resourceExists(resourceMeta);
- }
-
- @Override
- protected Comparator<String> getVersionComparator()
- {
- return getWrapped().getVersionComparator();
- }
-
- @Override
- protected void setVersionComparator(Comparator<String> versionComparator)
- {
- getWrapped().setVersionComparator(versionComparator);
- }
-
-}
+/*
+ * 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.resource;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Comparator;
+
+import javax.faces.FacesWrapper;
+
+/**
+ *
+ * @author Leonardo Uribe
+ *
+ */
+public abstract class ResourceLoaderWrapper extends ResourceLoader implements FacesWrapper<ResourceLoader>
+{
+
+ public ResourceLoaderWrapper()
+ {
+ super(null);
+ }
+
+ public String getResourceVersion(String path)
+ {
+ return getWrapped().getResourceVersion(path);
+ }
+
+ public String getLibraryVersion(String path)
+ {
+ return getWrapped().getLibraryVersion(path);
+ }
+
+ public URL getResourceURL(ResourceMeta resourceMeta)
+ {
+ return getWrapped().getResourceURL(resourceMeta);
+ }
+
+ public InputStream getResourceInputStream(ResourceMeta resourceMeta)
+ {
+ return getWrapped().getResourceInputStream(resourceMeta);
+ }
+
+ public ResourceMeta createResourceMeta(String prefix, String libraryName,
+ String libraryVersion, String resourceName, String resourceVersion)
+ {
+ return getWrapped().createResourceMeta(prefix, libraryName, libraryVersion,
+ resourceName, resourceVersion);
+ }
+
+ public boolean libraryExists(String libraryName)
+ {
+ return getWrapped().libraryExists(libraryName);
+ }
+
+ public String getPrefix()
+ {
+ return getWrapped().getPrefix();
+ }
+
+ public void setPrefix(String prefix)
+ {
+ getWrapped().setPrefix(prefix);
+ }
+
+ @Override
+ public boolean resourceExists(ResourceMeta resourceMeta)
+ {
+ return getWrapped().resourceExists(resourceMeta);
+ }
+
+ @Override
+ protected Comparator<String> getVersionComparator()
+ {
+ return getWrapped().getVersionComparator();
+ }
+
+ @Override
+ protected void setVersionComparator(Comparator<String> versionComparator)
+ {
+ getWrapped().setVersionComparator(versionComparator);
+ }
+
+}
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java?rev=1307565&r1=1307564&r2=1307565&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java Fri Mar 30 18:14:25 2012
@@ -1,199 +1,199 @@
-/*
- * 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.resource;
-
-public class ResourceValidationUtils
-{
- public static boolean isValidResourceName(String resourceName)
- {
- return validateResourceName(resourceName, true);
- }
-
- public static boolean isValidLibraryName(String libraryName)
- {
- return validate(libraryName, false);
- }
-
- public static boolean isValidLibraryName(String libraryName, boolean allowSlash)
- {
- return validate(libraryName, allowSlash);
- }
-
- public static boolean isValidLocalePrefix(String localePrefix)
- {
- for (int i = 0; i < localePrefix.length(); i++)
- {
- char c = localePrefix.charAt(i);
- if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') || (c >='0' && c <='9') )
- {
- continue;
- }
- else
- {
- return false;
- }
- }
- return true;
- }
-
- private static boolean validate(String expression, boolean allowSlash)
- {
- if (expression.length() == 2 &&
- expression.charAt(0) == '.' &&
- expression.charAt(1) == '.')
- {
- return false;
- }
- for (int i = 0; i < expression.length(); i++)
- {
- char c = expression.charAt(i);
-
- // Enforce NameChar convention as specified
- // http://www.w3.org/TR/REC-xml/#NT-NameChar
- // Valid characters for NameChar
- // ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
- // [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] |
- // [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
- // | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
- // "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
- // Excluding ":"
- if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') ||
- (c >=0xC0 && c <=0xD6) || (c >=0xD8 && c <=0xF6) ||
- (c >=0xF8 && c <=0x2FF) || (c >=0x370 && c <=0x37D) ||
- (c >=0x37F && c <=0x1FFF) || (c >=0x200C && c <=0x200D) ||
- (c >=0x2070 && c <=0x218F) || (c >=0x2C00 && c <=0x2FEF) ||
- (c >=0x3001 && c <=0xD7FF) || (c >=0xF900 && c <=0xFDCF) ||
- (c >=0xFDF0 && c <=0xFFFD) || (c >=0x10000 && c <=0xEFFFF) ||
- c == '-' || (c >='0' && c <='9') || c == 0xB7 || (c >=0x300 && c <=0x36F) ||
- (c >=0x203F && c <=0x2040) || (allowSlash && c == '/')
- )
- {
- continue;
- }
- else if (c == '.')
- {
- if (i+2 < expression.length())
- {
- char c1 = expression.charAt(i+1);
- char c2 = expression.charAt(i+2);
- if (c == c1 && (c2 == '/' || c2 == '\\' ) )
- {
- return false;
- }
- }
- continue;
- }
- else
- {
- return false;
- }
- }
- if (expression.length() >= 3)
- {
- int length = expression.length();
- if ( (expression.charAt(length-3) == '/' || expression.charAt(length-3) == '\\' ) &&
- expression.charAt(length-2) == '.' &&
- expression.charAt(length-1) == '.' )
- {
- return false;
- }
- }
- return true;
- }
-
- private static boolean validateResourceName(String expression, boolean allowSlash)
- {
- if (expression.length() == 2 &&
- expression.charAt(0) == '.' &&
- expression.charAt(1) == '.')
- {
- return false;
- }
- for (int i = 0; i < expression.length(); i++)
- {
- char c = expression.charAt(i);
-
- // Enforce NameChar convention as specified
- // http://www.w3.org/TR/REC-xml/#NT-NameChar
- // Valid characters for NameChar
- // ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
- // [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] |
- // [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
- // | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
- // "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
- // Excluding ":"
-
- // Forbidden chars by win
- // < (less than)
- // > (greater than)
- // : (colon)
- // " (double quote)
- // / (forward slash)
- // \ (backslash)
- // | (vertical bar or pipe)
- // ? (question mark)
- // * (asterisk)
- // Do not use chars in UNIX because they have special meaning
- // *&%$|^/\~
- if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') ||
- (c >=0xC0 && c <=0xD6) || (c >=0xD8 && c <=0xF6) ||
- (c >=0xF8 && c <=0x2FF) || (c >=0x370 && c <=0x37D) ||
- (c >=0x37F && c <=0x1FFF) || (c >=0x200C && c <=0x200D) ||
- (c >=0x2070 && c <=0x218F) || (c >=0x2C00 && c <=0x2FEF) ||
- (c >=0x3001 && c <=0xD7FF) || (c >=0xF900 && c <=0xFDCF) ||
- (c >=0xFDF0 && c <=0xFFFD) || (c >=0x10000 && c <=0xEFFFF) ||
- (c == '-') || (c >='0' && c <='9') || c == 0xB7 || (c >=0x300 && c <=0x36F) ||
- (c >=0x203F && c <=0x2040) || (allowSlash && c == '/') ||
- (c == '!') || (c == '#') || (c == '\'') || (c == '(') || (c == ')') ||
- (c == '+') || (c == ',') || (c == ';' ) || (c == '=') ||
- (c == '@') || (c == '[') || (c == ']' ) || (c == '{') || (c == '}'))
- {
- continue;
- }
- else if (c == '.')
- {
- if (i+2 < expression.length())
- {
- char c1 = expression.charAt(i+1);
- char c2 = expression.charAt(i+2);
- if (c == c1 && (c2 == '/' || c2 == '\\' ) )
- {
- return false;
- }
- }
- continue;
- }
- else
- {
- return false;
- }
- }
- if (expression.length() >= 3)
- {
- int length = expression.length();
- if ( (expression.charAt(length-3) == '/' || expression.charAt(length-3) == '\\' ) &&
- expression.charAt(length-2) == '.' &&
- expression.charAt(length-1) == '.' )
- {
- return false;
- }
- }
- return true;
- }
-}
+/*
+ * 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.resource;
+
+public class ResourceValidationUtils
+{
+ public static boolean isValidResourceName(String resourceName)
+ {
+ return validateResourceName(resourceName, true);
+ }
+
+ public static boolean isValidLibraryName(String libraryName)
+ {
+ return validate(libraryName, false);
+ }
+
+ public static boolean isValidLibraryName(String libraryName, boolean allowSlash)
+ {
+ return validate(libraryName, allowSlash);
+ }
+
+ public static boolean isValidLocalePrefix(String localePrefix)
+ {
+ for (int i = 0; i < localePrefix.length(); i++)
+ {
+ char c = localePrefix.charAt(i);
+ if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') || (c >='0' && c <='9') )
+ {
+ continue;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean validate(String expression, boolean allowSlash)
+ {
+ if (expression.length() == 2 &&
+ expression.charAt(0) == '.' &&
+ expression.charAt(1) == '.')
+ {
+ return false;
+ }
+ for (int i = 0; i < expression.length(); i++)
+ {
+ char c = expression.charAt(i);
+
+ // Enforce NameChar convention as specified
+ // http://www.w3.org/TR/REC-xml/#NT-NameChar
+ // Valid characters for NameChar
+ // ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
+ // [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] |
+ // [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
+ // | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
+ // "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
+ // Excluding ":"
+ if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') ||
+ (c >=0xC0 && c <=0xD6) || (c >=0xD8 && c <=0xF6) ||
+ (c >=0xF8 && c <=0x2FF) || (c >=0x370 && c <=0x37D) ||
+ (c >=0x37F && c <=0x1FFF) || (c >=0x200C && c <=0x200D) ||
+ (c >=0x2070 && c <=0x218F) || (c >=0x2C00 && c <=0x2FEF) ||
+ (c >=0x3001 && c <=0xD7FF) || (c >=0xF900 && c <=0xFDCF) ||
+ (c >=0xFDF0 && c <=0xFFFD) || (c >=0x10000 && c <=0xEFFFF) ||
+ c == '-' || (c >='0' && c <='9') || c == 0xB7 || (c >=0x300 && c <=0x36F) ||
+ (c >=0x203F && c <=0x2040) || (allowSlash && c == '/')
+ )
+ {
+ continue;
+ }
+ else if (c == '.')
+ {
+ if (i+2 < expression.length())
+ {
+ char c1 = expression.charAt(i+1);
+ char c2 = expression.charAt(i+2);
+ if (c == c1 && (c2 == '/' || c2 == '\\' ) )
+ {
+ return false;
+ }
+ }
+ continue;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ if (expression.length() >= 3)
+ {
+ int length = expression.length();
+ if ( (expression.charAt(length-3) == '/' || expression.charAt(length-3) == '\\' ) &&
+ expression.charAt(length-2) == '.' &&
+ expression.charAt(length-1) == '.' )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean validateResourceName(String expression, boolean allowSlash)
+ {
+ if (expression.length() == 2 &&
+ expression.charAt(0) == '.' &&
+ expression.charAt(1) == '.')
+ {
+ return false;
+ }
+ for (int i = 0; i < expression.length(); i++)
+ {
+ char c = expression.charAt(i);
+
+ // Enforce NameChar convention as specified
+ // http://www.w3.org/TR/REC-xml/#NT-NameChar
+ // Valid characters for NameChar
+ // ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
+ // [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] |
+ // [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
+ // | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
+ // "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
+ // Excluding ":"
+
+ // Forbidden chars by win
+ // < (less than)
+ // > (greater than)
+ // : (colon)
+ // " (double quote)
+ // / (forward slash)
+ // \ (backslash)
+ // | (vertical bar or pipe)
+ // ? (question mark)
+ // * (asterisk)
+ // Do not use chars in UNIX because they have special meaning
+ // *&%$|^/\~
+ if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') ||
+ (c >=0xC0 && c <=0xD6) || (c >=0xD8 && c <=0xF6) ||
+ (c >=0xF8 && c <=0x2FF) || (c >=0x370 && c <=0x37D) ||
+ (c >=0x37F && c <=0x1FFF) || (c >=0x200C && c <=0x200D) ||
+ (c >=0x2070 && c <=0x218F) || (c >=0x2C00 && c <=0x2FEF) ||
+ (c >=0x3001 && c <=0xD7FF) || (c >=0xF900 && c <=0xFDCF) ||
+ (c >=0xFDF0 && c <=0xFFFD) || (c >=0x10000 && c <=0xEFFFF) ||
+ (c == '-') || (c >='0' && c <='9') || c == 0xB7 || (c >=0x300 && c <=0x36F) ||
+ (c >=0x203F && c <=0x2040) || (allowSlash && c == '/') ||
+ (c == '!') || (c == '#') || (c == '\'') || (c == '(') || (c == ')') ||
+ (c == '+') || (c == ',') || (c == ';' ) || (c == '=') ||
+ (c == '@') || (c == '[') || (c == ']' ) || (c == '{') || (c == '}'))
+ {
+ continue;
+ }
+ else if (c == '.')
+ {
+ if (i+2 < expression.length())
+ {
+ char c1 = expression.charAt(i+1);
+ char c2 = expression.charAt(i+2);
+ if (c == c1 && (c2 == '/' || c2 == '\\' ) )
+ {
+ return false;
+ }
+ }
+ continue;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ if (expression.length() >= 3)
+ {
+ int length = expression.length();
+ if ( (expression.charAt(length-3) == '/' || expression.charAt(length-3) == '\\' ) &&
+ expression.charAt(length-2) == '.' &&
+ expression.charAt(length-1) == '.' )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+}
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java?rev=1307565&r1=1307564&r2=1307565&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java Fri Mar 30 18:14:25 2012
@@ -1,168 +1,168 @@
-/*
- * 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.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ExceptionQueuedEvent;
-import javax.faces.event.ExceptionQueuedEventContext;
-
-import org.apache.myfaces.shared.util.io.DynamicPushbackInputStream;
-
-public class ValueExpressionFilterInputStream extends InputStream
-{
- private PushbackInputStream delegate;
- private String libraryName;
- private String resourceName;
-
- public ValueExpressionFilterInputStream(InputStream in, String libraryName, String resourceName)
- {
- super();
- delegate = new DynamicPushbackInputStream(in,300);
- }
-
- @Override
- public int read() throws IOException
- {
- int c1 = delegate.read();
-
- if (c1 == -1)
- {
- return -1;
- }
-
- if ( ((char)c1) == '#')
- {
- int c2 = delegate.read();
- if (c2 == -1)
- {
- return -1;
- }
- if (((char)c2) == '{')
- {
- //It is a value expression. We need
- //to look for a occurrence of } to
- //extract the expression and evaluate it,
- //the result should be unread.
- List<Integer> expressionList = new ArrayList<Integer>();
- int c3 = delegate.read();
- while ( c3 != -1 && ((char)c3) != '}' )
- {
- expressionList.add(c3);
- c3 = delegate.read();
- }
-
- if (c3 == -1)
- {
- //get back the data, because we can't
- //extract any value expression
- for (int i = 0; i < expressionList.size(); i++)
- {
- delegate.unread(expressionList.get(i));
- }
- delegate.unread(c2);
- return c1;
- }
- else
- {
- //EL expression found. Evaluate it and pushback
- //the result into the stream
- FacesContext context = FacesContext.getCurrentInstance();
- ELContext elContext = context.getELContext();
- try
- {
- ValueExpression ve = context.getApplication().
- getExpressionFactory().createValueExpression(
- elContext,
- "#{"+convertToExpression(expressionList)+"}",
- String.class);
- String value = (String) ve.getValue(elContext);
-
- for (int i = value.length()-1; i >= 0 ; i--)
- {
- delegate.unread((int) value.charAt(i));
- }
- }
- catch(ELException e)
- {
- ExceptionQueuedEventContext equecontext = new ExceptionQueuedEventContext (
- context, e, null);
- context.getApplication().publishEvent (context, ExceptionQueuedEvent.class, equecontext);
-
- Logger log = Logger.getLogger(ResourceImpl.class.getName());
- if (log.isLoggable(Level.SEVERE))
- {
- log.severe("Cannot evaluate EL expression " + convertToExpression(expressionList)
- + " in resource " + (libraryName == null?"":libraryName) + ":" +
- (resourceName == null?"":resourceName));
- }
-
- delegate.unread(c3);
- for (int i = expressionList.size()-1; i >= 0; i--)
- {
- delegate.unread(expressionList.get(i));
- }
- delegate.unread(c2);
- return c1;
- }
-
- //read again
- return delegate.read();
- }
- }
- else
- {
- delegate.unread(c2);
- return c1;
- }
- }
- else
- {
- //just continue
- return c1;
- }
- }
-
- private String convertToExpression(List<Integer> expressionList)
- {
- char[] exprArray = new char[expressionList.size()];
-
- for (int i = 0; i < expressionList.size(); i++)
- {
- exprArray[i] = (char) expressionList.get(i).intValue();
- }
- return String.valueOf(exprArray);
- }
-
- @Override
- public void close() throws IOException
- {
- delegate.close();
- }
-}
+/*
+ * 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.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.faces.event.ExceptionQueuedEventContext;
+
+import org.apache.myfaces.shared.util.io.DynamicPushbackInputStream;
+
+public class ValueExpressionFilterInputStream extends InputStream
+{
+ private PushbackInputStream delegate;
+ private String libraryName;
+ private String resourceName;
+
+ public ValueExpressionFilterInputStream(InputStream in, String libraryName, String resourceName)
+ {
+ super();
+ delegate = new DynamicPushbackInputStream(in,300);
+ }
+
+ @Override
+ public int read() throws IOException
+ {
+ int c1 = delegate.read();
+
+ if (c1 == -1)
+ {
+ return -1;
+ }
+
+ if ( ((char)c1) == '#')
+ {
+ int c2 = delegate.read();
+ if (c2 == -1)
+ {
+ return -1;
+ }
+ if (((char)c2) == '{')
+ {
+ //It is a value expression. We need
+ //to look for a occurrence of } to
+ //extract the expression and evaluate it,
+ //the result should be unread.
+ List<Integer> expressionList = new ArrayList<Integer>();
+ int c3 = delegate.read();
+ while ( c3 != -1 && ((char)c3) != '}' )
+ {
+ expressionList.add(c3);
+ c3 = delegate.read();
+ }
+
+ if (c3 == -1)
+ {
+ //get back the data, because we can't
+ //extract any value expression
+ for (int i = 0; i < expressionList.size(); i++)
+ {
+ delegate.unread(expressionList.get(i));
+ }
+ delegate.unread(c2);
+ return c1;
+ }
+ else
+ {
+ //EL expression found. Evaluate it and pushback
+ //the result into the stream
+ FacesContext context = FacesContext.getCurrentInstance();
+ ELContext elContext = context.getELContext();
+ try
+ {
+ ValueExpression ve = context.getApplication().
+ getExpressionFactory().createValueExpression(
+ elContext,
+ "#{"+convertToExpression(expressionList)+"}",
+ String.class);
+ String value = (String) ve.getValue(elContext);
+
+ for (int i = value.length()-1; i >= 0 ; i--)
+ {
+ delegate.unread((int) value.charAt(i));
+ }
+ }
+ catch(ELException e)
+ {
+ ExceptionQueuedEventContext equecontext = new ExceptionQueuedEventContext (
+ context, e, null);
+ context.getApplication().publishEvent (context, ExceptionQueuedEvent.class, equecontext);
+
+ Logger log = Logger.getLogger(ResourceImpl.class.getName());
+ if (log.isLoggable(Level.SEVERE))
+ {
+ log.severe("Cannot evaluate EL expression " + convertToExpression(expressionList)
+ + " in resource " + (libraryName == null?"":libraryName) + ":" +
+ (resourceName == null?"":resourceName));
+ }
+
+ delegate.unread(c3);
+ for (int i = expressionList.size()-1; i >= 0; i--)
+ {
+ delegate.unread(expressionList.get(i));
+ }
+ delegate.unread(c2);
+ return c1;
+ }
+
+ //read again
+ return delegate.read();
+ }
+ }
+ else
+ {
+ delegate.unread(c2);
+ return c1;
+ }
+ }
+ else
+ {
+ //just continue
+ return c1;
+ }
+ }
+
+ private String convertToExpression(List<Integer> expressionList)
+ {
+ char[] exprArray = new char[expressionList.size()];
+
+ for (int i = 0; i < expressionList.size(); i++)
+ {
+ exprArray[i] = (char) expressionList.get(i).intValue();
+ }
+ return String.valueOf(exprArray);
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ delegate.close();
+ }
+}
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java?rev=1307565&r1=1307564&r2=1307565&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java Fri Mar 30 18:14:25 2012
@@ -1,304 +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);
- }
-
-}
+/*
+ * 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);
+ }
+
+}