Author: nbelaevski
Date: 2009-12-04 15:58:58 -0500 (Fri, 04 Dec 2009)
New Revision: 16076
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
Log:
https://jira.jboss.org/jira/browse/RF-7732
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-12-04
20:55:31 UTC (rev 16075)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-12-04
20:58:58 UTC (rev 16076)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.ajax4jsf.renderkit;
import org.ajax4jsf.Messages;
@@ -28,6 +30,20 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.util.HtmlDimensions;
+import java.io.IOException;
+
+import java.lang.reflect.Array;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
import javax.faces.FacesException;
import javax.faces.application.ViewHandler;
import javax.faces.component.EditableValueHolder;
@@ -42,17 +58,6 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
/**
* Util class for common render operations - render passthru html attributes,
@@ -60,6 +65,7 @@
*
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
+ *
*/
public class RendererUtils {
public static final String DUMMY_FORM_ID = ":_form";
@@ -130,7 +136,6 @@
/**
* Use this method to get singleton instance of RendererUtils
- *
* @return singleton instance
*/
public static RendererUtils getInstance() {
@@ -168,7 +173,7 @@
if (null != clientId) {
context.getResponseWriter().writeAttribute(attribute, clientId,
- (String) getComponentAttributeName(attribute));
+ (String) getComponentAttributeName(attribute));
}
}
@@ -183,7 +188,7 @@
public void encodeCustomId(FacesContext context, UIComponent component) throws
IOException {
if ((component.getId() != null) &&
!component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
context.getResponseWriter().writeAttribute(HTML.ID_ATTRIBUTE,
component.getClientId(context),
- HTML.ID_ATTRIBUTE);
+ HTML.ID_ATTRIBUTE);
}
}
@@ -199,7 +204,7 @@
if (null == name) {
throw new
IllegalArgumentException(Messages.getMessage(Messages.UNNAMED_PARAMETER_ERROR,
- component.getClientId(context)));
+ component.getClientId(context)));
}
boolean escape = true;
@@ -245,7 +250,7 @@
UIComponent component = (UIComponent) behaviorHolder;
ResponseWriter writer = context.getResponseWriter();
Collection<Parameter> parametersList =
HandlersChain.createParametersList(createParametersMap(context,
- component));
+ component));
for (String behaviorEventName : eventNames) {
if (behaviorEventName.equals(defaultEventName)) {
@@ -300,8 +305,8 @@
* @throws IOException
*/
public void encodePassThruWithExclusions(FacesContext context, UIComponent component,
String exclusions,
- String defaultHtmlEvent) throws IOException
{
-
+ String defaultHtmlEvent) throws IOException {
+
if (null != exclusions) {
String[] exclusionsArray = exclusions.split(",");
@@ -310,8 +315,8 @@
}
public void encodePassThruWithExclusionsArray(FacesContext context, UIComponent
component, String[] exclusions,
- String defaultHtmlEvent) throws
IOException {
-
+ String defaultHtmlEvent) throws IOException {
+
ResponseWriter writer = context.getResponseWriter();
Map<String, Object> attributes = component.getAttributes();
@@ -350,7 +355,7 @@
* @throws IOException
*/
public void encodePassThruAttribute(FacesContext context, Map<String, Object>
attributes, ResponseWriter writer,
- String attribute) throws IOException {
+ String attribute) throws IOException {
Object value = attributeValue(attribute,
attributes.get(getComponentAttributeName(attribute)));
@@ -368,7 +373,7 @@
public void encodeAttributesFromArray(FacesContext context, UIComponent component,
String[] attrs)
throws IOException {
-
+
ResponseWriter writer = context.getResponseWriter();
Map<String, Object> attributes = component.getAttributes();
@@ -382,9 +387,12 @@
/**
* Encode attributes given by comma-separated string list.
*
- * @param context current JSF context
- * @param component for with render attributes values
- * @param attrs comma separated list of attributes
+ * @param context
+ * current JSF context
+ * @param component
+ * for with render attributes values
+ * @param attrs
+ * comma separated list of attributes
* @throws IOException
*/
public void encodeAttributes(FacesContext context, UIComponent component, String
attrs) throws IOException {
@@ -400,11 +408,12 @@
* @param component
* @param property
* @param attributeName
+ *
* @throws IOException
*/
public void encodeAttribute(FacesContext context, UIComponent component, Object
property, String attributeName)
throws IOException {
-
+
ResponseWriter writer = context.getResponseWriter();
Object value = component.getAttributes().get(property);
@@ -417,12 +426,6 @@
encodeAttribute(context, component, getComponentAttributeName(attribute),
attribute);
}
- public void writeText(ResponseWriter writer, Object value, String property) throws
IOException {
- if (value != null) {
- writer.writeText(value, property);
- }
- }
-
/**
* Write html-attribute
*
@@ -446,7 +449,7 @@
if (null == attributeVal) {
return false;
} else if ((attributeVal instanceof Boolean)
- && ((Boolean) attributeVal).booleanValue() ==
Boolean.FALSE.booleanValue()) {
+ && ((Boolean) attributeVal).booleanValue() ==
Boolean.FALSE.booleanValue()) {
return false;
} else if (attributeVal.toString().length() == 0) {
return false;
@@ -472,8 +475,8 @@
* with Java primitive types of JSF component return appropriate MIN_VALUE .
*
* @param property -
- * value of property returned from
- * {@link UIComponent#getAttributes()}
+ * value of property returned from
+ * {@link UIComponent#getAttributes()}
* @return true for setted property, false otherthise.
*/
public boolean isValidProperty(Object property) {
@@ -501,15 +504,15 @@
/**
* Checks if the argument passed in is empty or not.
* Object is empty if it is: <br />
- * - <code>null<code><br />
- * - zero-length string<br />
- * - empty collection<br />
- * - empty map<br />
- * - zero-length array<br />
+ * - <code>null<code><br />
+ * - zero-length string<br />
+ * - empty collection<br />
+ * - empty map<br />
+ * - zero-length array<br />
*
* @param o object to check for emptiness
+ * @since 3.3.2
* @return <code>true</code> if the argument is empty,
<code>false</code> otherwise
- * @since 3.3.2
*/
public boolean isEmpty(Object o) {
if (null == o) {
@@ -544,6 +547,7 @@
* @param value
* @param defaultValue
* @param wrapper
+ *
* @since 3.3.2
*/
public void addToScriptHash(Map<String, Object> hash, String name, Object
value, String defaultValue,
@@ -571,6 +575,7 @@
* @param name
* @param value
* @param defaultValue
+ *
* @since 3.3.2
*/
public void addToScriptHash(Map<String, Object> hash, String name, Object
value, String defaultValue) {
@@ -584,6 +589,7 @@
* @param hash
* @param name
* @param value
+ *
* @since 3.3.2
*/
public void addToScriptHash(Map<String, Object> hash, String name, Object
value) {
@@ -611,7 +617,8 @@
* attributes return name for true value, otherthise - null. For non-boolean
* attributes return same value.
*
- * @param name attribute name.
+ * @param name
+ * attribute name.
* @param value
* @return
*/
@@ -635,7 +642,8 @@
* Get boolean value of logical attribute
*
* @param component
- * @param name attribute name
+ * @param name
+ * attribute name
* @return true if attribute is equals Boolean.TRUE or String "true" ,
false
* otherwise.
*/
@@ -733,6 +741,7 @@
* formats given value to
*
* @param value
+ *
* @return
*/
public String encodePctOrPx(String value) {
@@ -796,7 +805,7 @@
*/
public void encodeBeginForm(FacesContext context, UIComponent component,
ResponseWriter writer, String clientId)
throws IOException {
-
+
String actionURL = getActionUrl(context);
String encodeActionURL =
context.getExternalContext().encodeActionURL(actionURL);
@@ -884,39 +893,40 @@
/**
* @param ids
* @param keyword
+ * @since 4.0
+ *
* @return
- * @since 4.0
*/
private static boolean checkKeyword(Collection<String> ids, String keyword) {
- if (ids.contains(keyword)) {
- if (ids.size() != 1) {
- //TODO log
- }
-
- return true;
- }
-
- return false;
+ if (ids.contains(keyword)) {
+ if (ids.size() != 1) {
+ //TODO log
+ }
+
+ return true;
+ }
+
+ return false;
}
/**
* @param context
* @param component
* @param shortIds
+ * @since 4.0
* @return
- * @since 4.0
*/
public Collection<String> findComponentsFor(FacesContext context, UIComponent
component,
- Collection<String> shortIds) {
+ Collection<String> shortIds) {
// TODO - implement
// TODO add support for @*
Set<String> result = new LinkedHashSet<String>(shortIds.size());
if (checkKeyword(shortIds, AjaxRendererUtils.ALL)) {
- result.add(AjaxRendererUtils.ALL);
+ result.add(AjaxRendererUtils.ALL);
} else if (checkKeyword(shortIds, AjaxRendererUtils.NONE)) {
- //do nothing, use empty set
+ //do nothing, use empty set
} else {
for (String id : shortIds) {
if (AjaxRendererUtils.THIS.equals(id)) {
@@ -971,9 +981,9 @@
/**
* If target component contains generated id and for doesn't, correct for id
- *
* @param forAttr
* @param component
+ *
*/
public String correctForIdReference(String forAttr, UIComponent component) {
int contains = forAttr.indexOf(UIViewRoot.UNIQUE_ID_PREFIX);
@@ -993,7 +1003,7 @@
private UIComponent findUIComponentBelow(UIComponent root, String id) {
UIComponent target = null;
- for (Iterator<UIComponent> iter = root.getFacetsAndChildren();
iter.hasNext();) {
+ for (Iterator<UIComponent> iter = root.getFacetsAndChildren();
iter.hasNext(); ) {
UIComponent child = (UIComponent) iter.next();
if (child instanceof NamingContainer) {
@@ -1020,7 +1030,7 @@
public static void writeEventHandlerFunction(FacesContext context, UIComponent
component, String eventName)
throws IOException {
-
+
ResponseWriter writer = context.getResponseWriter();
Object script = component.getAttributes().get(eventName);
@@ -1036,7 +1046,7 @@
}
public JSFunctionDefinition getAsEventHandler(FacesContext context, UIComponent
component, String attributeName,
- String append) {
+ String append) {
String event = (String) component.getAttributes().get(attributeName);
if (event != null) {
@@ -1100,6 +1110,7 @@
*
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
+ *
*/
public interface HTML {
public static final String ACCEPT_ATTRIBUTE = "accept";
@@ -1195,7 +1206,7 @@
"onmousedown", "onmousemove", "onmouseout",
"onmouseover", "onmouseup", "onreset", "onselect",
"onsubmit",
"onunload"
};
- public static final String[] PASS_THRU_STYLES = {"style",
"class",};
+ public static final String[] PASS_THRU_STYLES = {"style",
"class", };
/**
* all HTML attributes with URI value.