JBoss Rich Faces SVN: r20788 - in trunk: core/api/src/main/java/org/richfaces/el/util and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-23 14:24:00 -0500 (Thu, 23 Dec 2010)
New Revision: 20788
Added:
trunk/core/api/src/main/java/org/richfaces/el/GenericsIntrospectionService.java
trunk/core/impl/src/main/java/org/richfaces/el/CapturingELResolver.java
trunk/core/impl/src/main/java/org/richfaces/el/GenericsIntrospectionServiceImpl.java
Removed:
trunk/core/api/src/main/java/org/richfaces/el/util/CapturingELResolver.java
trunk/core/api/src/main/java/org/richfaces/el/util/GenericsIntrospectionCache.java
trunk/core/api/src/main/java/org/richfaces/el/util/ReferenceMap.java
Modified:
trunk/core/api/src/main/java/org/richfaces/el/util/ELUtils.java
trunk/core/impl/src/main/java/org/richfaces/application/DefaultModule.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutocomplete.java
Log:
Legacy 3.x code removal
ELUtils refactoring
Added: trunk/core/api/src/main/java/org/richfaces/el/GenericsIntrospectionService.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/el/GenericsIntrospectionService.java (rev 0)
+++ trunk/core/api/src/main/java/org/richfaces/el/GenericsIntrospectionService.java 2010-12-23 19:24:00 UTC (rev 20788)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.el;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface GenericsIntrospectionService {
+
+ public Class<?> getContainerClass(FacesContext facesContext, ValueExpression expression);
+
+}
Deleted: trunk/core/api/src/main/java/org/richfaces/el/util/CapturingELResolver.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/el/util/CapturingELResolver.java 2010-12-23 17:32:10 UTC (rev 20787)
+++ trunk/core/api/src/main/java/org/richfaces/el/util/CapturingELResolver.java 2010-12-23 19:24:00 UTC (rev 20788)
@@ -1,68 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.el.util;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-
-import org.richfaces.el.ELResolverWrapper;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-public class CapturingELResolver extends ELResolverWrapper {
- private Object base;
- private Object property;
-
- public CapturingELResolver(ELResolver resolver) {
- super(resolver);
- }
-
- @Override
- public Object getValue(ELContext context, Object base, Object property) {
- if ((base != null) && (property != null)) {
- this.base = base;
- this.property = property;
- }
-
- return super.getValue(context, base, property);
- }
-
- @Override
- public Class<?> getType(ELContext context, Object base, Object property) {
- if ((base != null) && (property != null)) {
- this.base = base;
- this.property = property;
- }
-
- return super.getType(context, base, property);
- }
-
- public Object getBase() {
- return base;
- }
-
- public Object getProperty() {
- return property;
- }
-}
Modified: trunk/core/api/src/main/java/org/richfaces/el/util/ELUtils.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/el/util/ELUtils.java 2010-12-23 17:32:10 UTC (rev 20787)
+++ trunk/core/api/src/main/java/org/richfaces/el/util/ELUtils.java 2010-12-23 19:24:00 UTC (rev 20788)
@@ -21,27 +21,7 @@
package org.richfaces.el.util;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.ref.SoftReference;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ResourceBundle;
-import javax.el.ELContext;
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.el.ELContextWrapper;
-import org.richfaces.el.util.GenericsIntrospectionCache.GenericsCacheEntry;
-
/**
* @author asmirnov
*/
@@ -79,130 +59,4 @@
return false;
}
- public static Object evaluateValueExpression(ValueExpression expression, ELContext elContext) {
-
- if (expression.isLiteralText()) {
- return expression.getExpressionString();
- } else {
- return expression.getValue(elContext);
- }
-
- }
-
- public static ValueExpression createValueExpression(String expression) {
-
- return createValueExpression(expression, Object.class);
-
- }
-
- public static ValueExpression createValueExpression(String expression, Class<?> expectedType) {
- FacesContext context = FacesContext.getCurrentInstance();
- return context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), expression, expectedType);
- }
-
- private static Class<?> resolveType(Type type) {
- Class<?> result = Object.class;
-
- if (type instanceof ParameterizedType) {
- ParameterizedType parameterizedType = (ParameterizedType) type;
- Type[] types = parameterizedType.getActualTypeArguments();
-
- if ((types != null) && (types.length != 0)) {
- Type actualType = types[0];
-
- if (actualType instanceof Class) {
- result = (Class<?>) actualType;
- }
- }
- }
-
- return result;
- }
-
- private static BeanInfo getBeanInfo(Class<?> beanClass, GenericsCacheEntry entry) {
- BeanInfo beanInfo = null;
- SoftReference<BeanInfo> beanInfoReference = entry.beanInfoReference;
-
- if (beanInfoReference != null) {
- beanInfo = beanInfoReference.get();
- }
-
- if (beanInfo == null) {
- try {
- beanInfo = Introspector.getBeanInfo(beanClass);
- entry.beanInfoReference = new SoftReference<BeanInfo>(beanInfo);
- } catch (IntrospectionException e) {
- throw new FacesException(e.getMessage(), e);
- }
- }
-
- return beanInfo;
- }
-
- private static Class<?> getGenericCollectionType(FacesContext context, Object base, String propertyName) {
- Class<?> genericPropertyClass = null;
-
- if ((base != null) && (propertyName != null)) {
- Class<? extends Object> beanClass = base.getClass();
-
- // Map and ResourceBundle have special resolvers that we doesn't support
- if (!Map.class.isAssignableFrom(beanClass) && !ResourceBundle.class.isAssignableFrom(beanClass)) {
- GenericsIntrospectionCache introspectionCache = GenericsIntrospectionCache.getInstance(context);
-
- synchronized (introspectionCache) {
- GenericsCacheEntry cacheEntry = introspectionCache.getGenericCacheEntry(beanClass);
-
- if (cacheEntry.genericPropertiesClasses == null) {
- cacheEntry.genericPropertiesClasses = new HashMap<String, Class<?>>();
- } else {
- genericPropertyClass = cacheEntry.genericPropertiesClasses.get(propertyName);
- }
-
- if (genericPropertyClass == null) {
- if (!cacheEntry.genericPropertiesClasses.containsKey(propertyName)) {
- BeanInfo beanInfo = getBeanInfo(beanClass, cacheEntry);
- PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
-
- for (PropertyDescriptor pd : descriptors) {
- if (propertyName.equals(pd.getName())) {
- Method readMethod = pd.getReadMethod();
-
- genericPropertyClass = resolveType(readMethod.getGenericReturnType());
-
- break;
- }
- }
-
- cacheEntry.genericPropertiesClasses.put(propertyName, genericPropertyClass);
- } else {
-
- // property Class has been already resolved as null
- }
- }
- }
- }
- }
-
- return genericPropertyClass;
- }
-
- public static Class<?> getContainerClass(FacesContext facesContext, ValueExpression expression) {
- ELContext initialELContext = facesContext.getELContext();
- CapturingELResolver capturingELResolver = new CapturingELResolver(initialELContext.getELResolver());
- Class<?> type = expression.getType(new ELContextWrapper(initialELContext, capturingELResolver));
- Class<?> containerType = type.getComponentType();
-
- if ((containerType == null) && (type != null)) {
- if (Collection.class.isAssignableFrom(type)) {
- Object base = capturingELResolver.getBase();
- Object property = capturingELResolver.getProperty();
-
- if ((base != null) && (property != null)) {
- containerType = getGenericCollectionType(facesContext, base, property.toString());
- }
- }
- }
-
- return containerType;
- }
}
Deleted: trunk/core/api/src/main/java/org/richfaces/el/util/GenericsIntrospectionCache.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/el/util/GenericsIntrospectionCache.java 2010-12-23 17:32:10 UTC (rev 20787)
+++ trunk/core/api/src/main/java/org/richfaces/el/util/GenericsIntrospectionCache.java 2010-12-23 19:24:00 UTC (rev 20788)
@@ -1,99 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.el.util;
-
-import java.beans.BeanInfo;
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
-import java.util.Collections;
-import java.util.Map;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.util.LRUMap;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-final class GenericsIntrospectionCache {
- private static final String CACHE_SIZE_PARAMETER = "org.richfaces.GenericsIntrospectionCacheSize";
- private static final int DEFAULT_CACHE_SIZE = 256;
- private static final String INSTANCE_ATTRIBUTE_NAME = GenericsIntrospectionCache.class.getName();
- private Map<Class<?>, GenericsCacheEntry> genericsCache;
-
- private GenericsIntrospectionCache(int cacheSize) {
- genericsCache = new ReferenceMap<Class<?>,
- GenericsCacheEntry>(Collections.synchronizedMap(new LRUMap<Class<?>,
- Reference<GenericsCacheEntry>>(cacheSize)));
- }
-
- private static int getSize(ExternalContext externalContext) {
- int cacheSize = DEFAULT_CACHE_SIZE;
- String cacheSizeParameter = externalContext.getInitParameter(CACHE_SIZE_PARAMETER);
-
- if (cacheSizeParameter != null && cacheSizeParameter.length() != 0) {
- try {
- cacheSize = Integer.valueOf(cacheSizeParameter);
- } catch (NumberFormatException e) {
- externalContext.log("Error converting " + CACHE_SIZE_PARAMETER + " init parameter to int: "
- + e.getMessage(), e);
- }
- }
-
- return cacheSize;
- }
-
- public GenericsCacheEntry getGenericCacheEntry(Class<?> beanClass) {
- GenericsCacheEntry cacheEntry = genericsCache.get(beanClass);
-
- if (cacheEntry == null) {
- cacheEntry = new GenericsCacheEntry();
- genericsCache.put(beanClass, cacheEntry);
- }
-
- return cacheEntry;
- }
-
- static GenericsIntrospectionCache getInstance(FacesContext facesContext) {
- ExternalContext externalContext = facesContext.getExternalContext();
- Map<String, Object> applicationMap = externalContext.getApplicationMap();
- GenericsIntrospectionCache instance;
-
- synchronized (applicationMap) {
- instance = (GenericsIntrospectionCache) applicationMap.get(INSTANCE_ATTRIBUTE_NAME);
-
- if (instance == null) {
- instance = new GenericsIntrospectionCache(getSize(externalContext));
- applicationMap.put(INSTANCE_ATTRIBUTE_NAME, instance);
- }
- }
-
- return instance;
- }
-
- static final class GenericsCacheEntry {
- SoftReference<BeanInfo> beanInfoReference;
- Map<String, Class<?>> genericPropertiesClasses;
- }
-}
Deleted: trunk/core/api/src/main/java/org/richfaces/el/util/ReferenceMap.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/el/util/ReferenceMap.java 2010-12-23 17:32:10 UTC (rev 20787)
+++ trunk/core/api/src/main/java/org/richfaces/el/util/ReferenceMap.java 2010-12-23 19:24:00 UTC (rev 20788)
@@ -1,177 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.el.util;
-
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.SoftReference;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Created 17.03.2008
- *
- * @author Nick Belaevski
- * @since 3.2
- */
-public class ReferenceMap<K, V> implements Map<K, V> {
- private ReferenceQueue<V> queue = new ReferenceQueue<V>();
- private Map<K, Reference<V>> map;
-
- public ReferenceMap() {
- this(Collections.synchronizedMap(new HashMap<K, Reference<V>>()));
- }
-
- public ReferenceMap(Map<K, Reference<V>> map) {
- super();
- this.map = map;
- }
-
- private void purge() {
- Reference<? extends V> reference = null;
-
- while ((reference = queue.poll()) != null) {
- ReferenceMapSoftReference<?, ?> entry = (ReferenceMapSoftReference<?, ?>) reference;
-
- entry.clear();
- map.remove(entry.getKey());
- }
- }
-
- public void clear() {
- map.clear();
-
- Reference<? extends V> reference = null;
-
- while ((reference = queue.poll()) != null) {
-
- // release queue entries
- reference.clear();
- }
- }
-
- public boolean containsKey(Object key) {
- purge();
-
- return map.containsKey(key);
- }
-
- public boolean containsValue(Object value) {
- throw new UnsupportedOperationException();
- }
-
- public Set<java.util.Map.Entry<K, V>> entrySet() {
- throw new UnsupportedOperationException();
- }
-
- public V get(Object key) {
- purge();
-
- Reference<V> reference = map.get(key);
-
- if (reference != null) {
- return reference.get();
- }
-
- return null;
- }
-
- public boolean isEmpty() {
- purge();
-
- return map.isEmpty();
- }
-
- public Set<K> keySet() {
- purge();
-
- return map.keySet();
- }
-
- private V doPut(K key, V value) {
- Reference<V> reference = map.put(key, new ReferenceMapSoftReference<K, V>(key, value, queue));
-
- if (reference != null) {
- return reference.get();
- }
-
- return null;
- }
-
- public V put(K key, V value) {
- purge();
-
- V v = doPut(key, value);
-
- purge();
-
- return v;
- }
-
- public void putAll(Map<? extends K, ? extends V> t) {
- purge();
-
- for (Map.Entry<? extends K, ? extends V> entry : t.entrySet()) {
- doPut(entry.getKey(), entry.getValue());
- }
-
- purge();
- }
-
- public V remove(Object key) {
- purge();
-
- Reference<V> reference = map.remove(key);
-
- if (reference != null) {
- return reference.get();
- }
-
- return null;
- }
-
- public int size() {
- purge();
-
- return map.size();
- }
-
- public Collection<V> values() {
- throw new UnsupportedOperationException();
- }
-
- protected static class ReferenceMapSoftReference<K, V> extends SoftReference<V> {
- private K key;
-
- public ReferenceMapSoftReference(K key, V value, ReferenceQueue<? super V> queue) {
- super(value, queue);
- this.key = key;
- }
-
- public K getKey() {
- return key;
- }
- }
-}
Modified: trunk/core/impl/src/main/java/org/richfaces/application/DefaultModule.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-12-23 17:32:10 UTC (rev 20787)
+++ trunk/core/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-12-23 19:24:00 UTC (rev 20788)
@@ -5,6 +5,8 @@
import org.richfaces.application.push.PushContextFactory;
import org.richfaces.application.push.impl.jms.PushContextFactoryImpl;
import org.richfaces.cache.Cache;
+import org.richfaces.el.GenericsIntrospectionService;
+import org.richfaces.el.GenericsIntrospectionServiceImpl;
import org.richfaces.javascript.JavaScriptService;
import org.richfaces.javascript.JavaScriptServiceImpl;
import org.richfaces.l10n.BundleLoader;
@@ -31,7 +33,7 @@
factory.setInstance(ResourceLibraryFactory.class, new ResourceLibraryFactoryImpl());
factory.setInstance(PushContextFactory.class, ServiceLoader.loadService(PushContextFactory.class, PushContextFactoryImpl.class));
factory.setInstance(JavaScriptService.class, new JavaScriptServiceImpl());
-
+ factory.setInstance(GenericsIntrospectionService.class, new GenericsIntrospectionServiceImpl());
}
}
Copied: trunk/core/impl/src/main/java/org/richfaces/el/CapturingELResolver.java (from rev 20785, trunk/core/api/src/main/java/org/richfaces/el/util/CapturingELResolver.java)
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/el/CapturingELResolver.java (rev 0)
+++ trunk/core/impl/src/main/java/org/richfaces/el/CapturingELResolver.java 2010-12-23 19:24:00 UTC (rev 20788)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.el;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class CapturingELResolver extends ELResolverWrapper {
+ private Object base;
+ private Object property;
+
+ public CapturingELResolver(ELResolver resolver) {
+ super(resolver);
+ }
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property) {
+ if ((base != null) && (property != null)) {
+ this.base = base;
+ this.property = property;
+ }
+
+ return super.getValue(context, base, property);
+ }
+
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property) {
+ if ((base != null) && (property != null)) {
+ this.base = base;
+ this.property = property;
+ }
+
+ return super.getType(context, base, property);
+ }
+
+ public Object getBase() {
+ return base;
+ }
+
+ public Object getProperty() {
+ return property;
+ }
+}
Added: trunk/core/impl/src/main/java/org/richfaces/el/GenericsIntrospectionServiceImpl.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/el/GenericsIntrospectionServiceImpl.java (rev 0)
+++ trunk/core/impl/src/main/java/org/richfaces/el/GenericsIntrospectionServiceImpl.java 2010-12-23 19:24:00 UTC (rev 20788)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.el;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+import com.google.common.base.Function;
+import com.google.common.collect.MapMaker;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class GenericsIntrospectionServiceImpl implements GenericsIntrospectionService {
+
+ private static final class GenericsCacheEntry {
+
+ private Class<?> beanClass;
+
+ private Map<String, Class<?>> containerClassesMap = new MapMaker().initialCapacity(2).makeComputingMap(new Function<String, Class<?>>() {
+
+ public Class<?> apply(String input) {
+ PropertyDescriptor propertyDescriptor = getPropertyDescriptor(input);
+ return getGenericContainerClass(propertyDescriptor);
+ }
+
+ });
+
+ public GenericsCacheEntry(Class<?> beanClass) {
+ this.beanClass = beanClass;
+ }
+
+ private Class<?> resolveType(Type type) {
+ Class<?> result = Object.class;
+
+ if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType) type;
+ Type[] types = parameterizedType.getActualTypeArguments();
+
+ if (types != null && types.length != 0) {
+ Type actualType = types[0];
+
+ if (actualType instanceof Class) {
+ result = (Class<?>) actualType;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private Class<?> getGenericContainerClass(PropertyDescriptor pd) {
+ if (pd == null) {
+ return null;
+ }
+
+ Method readMethod = pd.getReadMethod();
+ if (readMethod == null) {
+ return null;
+ }
+
+ return resolveType(readMethod.getGenericReturnType());
+ }
+
+ private PropertyDescriptor getPropertyDescriptor(String propertyName) {
+ BeanInfo beanInfo = null;
+ try {
+ beanInfo = Introspector.getBeanInfo(beanClass);
+ } catch (IntrospectionException e) {
+ throw new FacesException(e.getMessage(), e);
+ } finally {
+ Introspector.flushFromCaches(beanClass);
+ }
+
+ if (beanInfo == null) {
+ return null;
+ }
+
+ PropertyDescriptor[] propertyDescriptorsArray = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor pd : propertyDescriptorsArray) {
+ if (propertyName.equals(pd.getName())) {
+ return pd;
+ }
+ }
+
+ return null;
+ }
+
+ public Class<?> getContainerClass(String propertyName) {
+ return containerClassesMap.get(propertyName);
+ }
+
+ }
+
+ private final Map<Class<?>, GenericsCacheEntry> cache = new MapMaker().weakKeys().softValues().makeComputingMap(new Function<Class<?>, GenericsCacheEntry>() {
+ public GenericsCacheEntry apply(java.lang.Class<?> input) {
+ return new GenericsCacheEntry(input);
+ };
+ });
+
+ private Class<?> getGenericCollectionType(FacesContext context, Object base, String propertyName) {
+ Class<?> genericPropertyClass = null;
+
+ if ((base != null) && (propertyName != null)) {
+ Class<? extends Object> beanClass = base.getClass();
+
+ // Map and ResourceBundle have special resolvers that we doesn't support
+ if (!Map.class.isAssignableFrom(beanClass) && !ResourceBundle.class.isAssignableFrom(beanClass)) {
+ return cache.get(beanClass).getContainerClass(propertyName);
+ }
+ }
+
+ return genericPropertyClass;
+ }
+
+ public Class<?> getContainerClass(FacesContext facesContext, ValueExpression expression) {
+ ELContext initialELContext = facesContext.getELContext();
+ CapturingELResolver capturingELResolver = new CapturingELResolver(initialELContext.getELResolver());
+ Class<?> type = expression.getType(new ELContextWrapper(initialELContext, capturingELResolver));
+ Class<?> containerType = type.getComponentType();
+
+ if ((containerType == null) && (type != null)) {
+ if (Collection.class.isAssignableFrom(type)) {
+ Object base = capturingELResolver.getBase();
+ Object property = capturingELResolver.getProperty();
+
+ if ((base != null) && (property != null)) {
+ containerType = getGenericCollectionType(facesContext, base, property.toString());
+ }
+ }
+ }
+
+ return containerType;
+ }
+
+}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutocomplete.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutocomplete.java 2010-12-23 17:32:10 UTC (rev 20787)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutocomplete.java 2010-12-23 19:24:00 UTC (rev 20788)
@@ -34,6 +34,7 @@
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+import org.richfaces.application.ServiceTracker;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
@@ -43,7 +44,7 @@
import org.richfaces.cdk.annotations.TagType;
import org.richfaces.context.ExtendedVisitContext;
import org.richfaces.context.ExtendedVisitContextMode;
-import org.richfaces.el.util.ELUtils;
+import org.richfaces.el.GenericsIntrospectionService;
import org.richfaces.renderkit.MetaComponentRenderer;
/**
@@ -221,7 +222,7 @@
ValueExpression expression = this.getValueExpression("value");
if (expression != null) {
- Class<?> containerClass = ELUtils.getContainerClass(context, expression);
+ Class<?> containerClass = ServiceTracker.getService(context, GenericsIntrospectionService.class).getContainerClass(context, expression);
converter = getConverterForType(context, containerClass);
}
13 years, 5 months
JBoss Rich Faces SVN: r20787 - in branches/RF-9323: archetypes/rf-gae-sample/src/main/resources/archetype-resources/src/main/webapp/WEB-INF and 43 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-12-23 12:32:10 -0500 (Thu, 23 Dec 2010)
New Revision: 20787
Added:
branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/io/FastBufferOutputStreamTest.java
branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/io/FastBufferWriterTest.java
Removed:
branches/RF-9323/core/api/src/main/java/org/ajax4jsf/model/SerializableDataModel.java
branches/RF-9323/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent2.java
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/application/
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/cache/
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/config/
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/css/
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/event/
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/javascript/
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/renderkit/
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/request/
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/resource/image/animatedgif/
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/resource/image/package-info.java
branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/webapp/
branches/RF-9323/core/impl/src/main/java/org/richfaces/webapp/taglib/
branches/RF-9323/core/impl/src/main/resources/org/ajax4jsf/javascript/
branches/RF-9323/core/impl/src/main/resources/org/ajax4jsf/org/
branches/RF-9323/core/impl/src/main/resources/org/ajax4jsf/webapp/
branches/RF-9323/core/impl/src/main/resources/org/ajax4jsf/xml/
branches/RF-9323/core/impl/src/main/resources/org/richfaces/component/
branches/RF-9323/core/impl/src/main/resources/org/richfaces/renderkit/html/images/
branches/RF-9323/core/impl/src/main/resources/org/richfaces/renderkit/html/scripts/
branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/config/
branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/context/
branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/io/parser/
branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/javascript/
branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/renderkit/
branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/resource/
branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/util/
branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/MethodBindingMethodExpressionAdaptor.java
branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/MethodExpressionMethodBindingAdaptor.java
Modified:
branches/RF-9323/
branches/RF-9323/archetypes/rf-gae-sample/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/archetypes/richfaces-archetype-simpleapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/bom/pom.xml
branches/RF-9323/core/api/src/main/java/org/ajax4jsf/model/ExtendedDataModel.java
branches/RF-9323/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java
branches/RF-9323/core/impl/src/main/resources/META-INF/faces-config.xml
branches/RF-9323/core/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
branches/RF-9323/core/impl/src/main/resources/META-INF/resources/richfaces.js
branches/RF-9323/examples/core-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/examples/input-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/examples/input-demo/src/main/webapp/examples/calendar.xhtml
branches/RF-9323/examples/iteration-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/examples/misc-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/examples/output-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/examples/parent/pom.xml
branches/RF-9323/examples/push-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/examples/repeater-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/examples/richfaces-showcase/pom.xml
branches/RF-9323/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java
branches/RF-9323/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java
branches/RF-9323/examples/richfaces-showcase/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/examples/richfaces-showcase/src/main/webapp/WEB-INF/web.xml
branches/RF-9323/examples/validator-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
branches/RF-9323/parent/pom.xml
branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java
branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java
branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/MediaOutputHandler.java
branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java
branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java
branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java
branches/RF-9323/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
branches/RF-9323/ui/input/ui/src/main/templates/calendar.template.xml
branches/RF-9323/ui/input/ui/src/main/templates/select.template.xml
branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestDefault.xmlunit.xml
branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestEdit.xmlunit.xml
branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestWithControls.xmlunit.xml
branches/RF-9323/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
branches/RF-9323/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js
branches/RF-9323/ui/iteration/ui/src/test/java/org/richfaces/renderkit/ExtendedDataTableRendererTest.java
branches/RF-9323/ui/misc/ui/src/test/java/org/richfaces/function/RichFunctionTest.java
Log:
Merged revisions 20763-20765,20768,20770-20778,20780-20785 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r20763 | ilya_shaikovsky | 2010-12-23 04:22:24 -0800 (Thu, 23 Dec 2010) | 1 line
build corrections
.......
r20764 | pyaschenko | 2010-12-23 04:43:08 -0800 (Thu, 23 Dec 2010) | 1 line
Base class for ui components was added
.......
r20765 | pyaschenko | 2010-12-23 04:44:56 -0800 (Thu, 23 Dec 2010) | 1 line
http://jira.jboss.com/jira/browse/RF-8622
.......
r20768 | nbelaevski | 2010-12-23 06:08:01 -0800 (Thu, 23 Dec 2010) | 3 lines
Fixed Unit test failure with JSF 2.1.0
Removed validation-api from showcase pom.xml
Removed mime-type mapping for *.ecss files
.......
r20770 | abelevich | 2010-12-23 06:18:13 -0800 (Thu, 23 Dec 2010) | 1 line
fix inplaceSelectTests, RF-9735, RF-9737
.......
r20771 | nbelaevski | 2010-12-23 06:27:11 -0800 (Thu, 23 Dec 2010) | 4 lines
RF environment updates:
- MyFaces versions changed to 2.0.3 & 2.0.4-SNAPSHOT
- Guava updated to r07
- Added jsf_profile=jsf_ri_2_1 for Mojarra 2.1.0-b09
.......
r20772 | nbelaevski | 2010-12-23 06:53:40 -0800 (Thu, 23 Dec 2010) | 1 line
https://issues.jboss.org/browse/RF-10077
.......
r20773 | ilya_shaikovsky | 2010-12-23 06:54:40 -0800 (Thu, 23 Dec 2010) | 1 line
checkstyle
.......
r20774 | pyaschenko | 2010-12-23 07:32:50 -0800 (Thu, 23 Dec 2010) | 1 line
http://jira.jboss.com/jira/browse/RF-10046
.......
r20775 | konstantin.mishin | 2010-12-23 07:45:04 -0800 (Thu, 23 Dec 2010) | 1 line
RF-8691
.......
r20776 | nbelaevski | 2010-12-23 07:55:58 -0800 (Thu, 23 Dec 2010) | 1 line
https://issues.jboss.org/browse/RF-2968
.......
r20777 | nbelaevski | 2010-12-23 08:01:59 -0800 (Thu, 23 Dec 2010) | 1 line
Legacy 3.x code removal
.......
r20778 | nbelaevski | 2010-12-23 08:06:35 -0800 (Thu, 23 Dec 2010) | 1 line
Legacy 3.x code removal
.......
r20780 | pyaschenko | 2010-12-23 08:09:52 -0800 (Thu, 23 Dec 2010) | 1 line
http://jira.jboss.com/jira/browse/RF-10046
.......
r20781 | nbelaevski | 2010-12-23 08:14:34 -0800 (Thu, 23 Dec 2010) | 1 line
Legacy 3.x code removal
.......
r20782 | nbelaevski | 2010-12-23 08:19:44 -0800 (Thu, 23 Dec 2010) | 1 line
Legacy 3.x code removal
.......
r20783 | nbelaevski | 2010-12-23 08:50:19 -0800 (Thu, 23 Dec 2010) | 1 line
Legacy 3.x code removal
.......
r20784 | nbelaevski | 2010-12-23 09:02:11 -0800 (Thu, 23 Dec 2010) | 1 line
Legacy 3.x code removal
.......
r20785 | amarkhel | 2010-12-23 09:08:07 -0800 (Thu, 23 Dec 2010) | 2 lines
RF-9482 rich:calendar backed by String not using custom converter
- unused comment was removed in calendar.template.xml
.......
Property changes on: branches/RF-9323
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-20758
+ /trunk:1-20785
Modified: branches/RF-9323/archetypes/rf-gae-sample/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/archetypes/rf-gae-sample/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/archetypes/rf-gae-sample/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -8,7 +8,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/archetypes/richfaces-archetype-simpleapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/archetypes/richfaces-archetype-simpleapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/archetypes/richfaces-archetype-simpleapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/bom/pom.xml
===================================================================
--- branches/RF-9323/bom/pom.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/bom/pom.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -149,12 +149,12 @@
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
- <version>2.0.2</version>
+ <version>2.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
- <version>2.0.2</version>
+ <version>2.0.3</version>
</dependency>
<!-- Misc -->
@@ -181,7 +181,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>r05</version>
+ <version>r07</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
Modified: branches/RF-9323/core/api/src/main/java/org/ajax4jsf/model/ExtendedDataModel.java
===================================================================
--- branches/RF-9323/core/api/src/main/java/org/ajax4jsf/model/ExtendedDataModel.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/api/src/main/java/org/ajax4jsf/model/ExtendedDataModel.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -53,18 +53,6 @@
public abstract Object getRowKey();
/**
- * Iteration component can support save data for use at decoding/validation/update phases to avoid
- * unnessesary calls to original models,
- * for example - to avoid requests to database until all data is validated.
- * @return
- */
- public SerializableDataModel getSerializableModel(Range range) {
-
- // By default, model not serializable.
- return null;
- }
-
- /**
* Iterate over model by "visitor" pattern, for given range
* @param context current JSF context.
* @param visitor instance of {@link DataVisitor}, for process each row.
Deleted: branches/RF-9323/core/api/src/main/java/org/ajax4jsf/model/SerializableDataModel.java
===================================================================
--- branches/RF-9323/core/api/src/main/java/org/ajax4jsf/model/SerializableDataModel.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/api/src/main/java/org/ajax4jsf/model/SerializableDataModel.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,42 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.model;
-
-import java.io.Serializable;
-
-/**
- * Serializable version of {@link ExtendedDataModel}, for save lightweight version of data
- *
- * @author shura
- *
- */
-@SuppressWarnings("serial")
-public abstract class SerializableDataModel extends ExtendedDataModel implements Serializable {
-
- /**
- * Method called after update all model values. For example, developer can update
- * database with new values of modified rows.
- */
- public abstract void update();
-}
Modified: branches/RF-9323/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java
===================================================================
--- branches/RF-9323/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -25,7 +25,7 @@
import java.util.Date;
-import javax.faces.el.MethodBinding;
+import javax.el.MethodExpression;
/**
* @author shura (latest modification by $Author: alexsmirnov $)
@@ -113,14 +113,20 @@
public abstract void setValue(Object newvalue);
/**
- * Get El binding to method in user bean to send resource. Method will called with two parameters - restored data object and servlet output stream.
- * @return
+ * Get MethodExpression to method in user bean to send resource. Method will
+ * called with two parameters - restored data object and servlet output
+ * stream.
+ *
+ * @return MethodExpression
*/
- public abstract MethodBinding getCreateContent();
+ public abstract MethodExpression getCreateContent();
/**
- * Set El binding to method in user bean to send resource. Method will called with two parameters - restored data object and servlet output stream.
- * @param newvalue
+ * Set MethodExpression to method in user bean to send resource. Method will
+ * called with two parameters - restored data object and servlet output
+ * stream.
+ *
+ * @param newvalue - new MethodExpression value
*/
- public abstract void setCreateContent(MethodBinding newvalue);
+ public abstract void setCreateContent(MethodExpression newvalue);
}
Deleted: branches/RF-9323/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent2.java
===================================================================
--- branches/RF-9323/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent2.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent2.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,54 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.resource;
-
-import javax.el.MethodExpression;
-
-/**
- * Interface for the ResourceComponent introduced after refactoring
- * to support MethodExpression. Old interface is left for the
- * compatibility.
- *
- * @author Vladislav Baranov
- */
-public interface ResourceComponent2 extends ResourceComponent {
-
- /**
- * Get MethodExpression to method in user bean to send resource. Method will
- * called with two parameters - restored data object and servlet output
- * stream.
- *
- * @return MethodExpression
- */
- public abstract MethodExpression getCreateContentExpression();
-
- /**
- * Set MethodExpression to method in user bean to send resource. Method will
- * called with two parameters - restored data object and servlet output
- * stream.
- *
- * @param newvalue - new MethodExpression value
- */
- public abstract void setCreateContentExpression(MethodExpression newvalue);
-}
Deleted: branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
===================================================================
--- branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,131 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.context;
-
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-/**
- * This class hold all methods for get application init parameters. Created for
- * single access point to all parameters - simplest for a documentation.
- *
- * @author asmirnov
- */
-public final class ContextInitParameters {
-
- private static final String INIT_PARAM_PREFIX = ContextInitParameters.class.getSimpleName() + ":";
- private static final Object NULL = new Object() {
-
- public String toString() {
- return ContextInitParameters.class.getSimpleName() + ": null Object";
- };
-
- };
-
- /**
- *
- */
- private ContextInitParameters() {
-
- // this is a only static methods for a access to Web app Init
- // parameters. Do not Instantiate !
- }
-
- static int getInteger(FacesContext context, String[] paramNames, int defaultValue) {
- String initParameter = getInitParameter(context, paramNames);
-
- if (null == initParameter) {
- return defaultValue;
- } else {
- try {
- return Integer.parseInt(initParameter);
- } catch (NumberFormatException e) {
- throw new FacesException("Context parameter " + paramNames + " must have integer value");
- }
- }
- }
-
- static String getString(FacesContext context, String[] paramNames, String defaultValue) {
- String initParameter = getInitParameter(context, paramNames);
-
- if (null == initParameter) {
- return defaultValue;
- } else {
- return initParameter;
- }
- }
-
- static boolean getBoolean(FacesContext context, String[] paramNames, boolean defaultValue) {
- String initParameter = getInitParameter(context, paramNames);
-
- if (null == initParameter) {
- return defaultValue;
- } else if ("true".equalsIgnoreCase(initParameter) || "yes".equalsIgnoreCase(initParameter)) {
- return true;
- } else if ("false".equalsIgnoreCase(initParameter) || "no".equalsIgnoreCase(initParameter)) {
- return false;
- } else {
- throw new FacesException("Illegal value [" + initParameter + "] for a init parameter +" + paramNames
- + ", only logical values 'true' or 'false' is allowed");
- }
- }
-
- static String getInitParameter(FacesContext context, String[] paramNames) {
- ExternalContext externalContext = context.getExternalContext();
- String value = null;
-
- for (int i = 0; (i < paramNames.length) && (null == value); i++) {
- value = externalContext.getInitParameter(paramNames[i]);
- }
-
- return value;
- }
-
- private static boolean getBooleanValue(Object value, boolean defaultValue) {
- if (value == null) {
- return defaultValue;
- }
-
- if (value instanceof Boolean) {
- return ((Boolean) value).booleanValue();
- }
-
- String stringValue = (String) value;
-
- return ("true".equalsIgnoreCase(stringValue) || "yes".equalsIgnoreCase(stringValue));
- }
-
- private static Object evaluateInitParameterExpression(FacesContext context, Object parameterValue) {
- if (parameterValue == NULL || parameterValue == null) {
- return null;
- } else if (parameterValue instanceof ValueExpression) {
- ValueExpression expression = (ValueExpression) parameterValue;
-
- return (String) expression.getValue(context.getELContext());
- } else {
- return parameterValue.toString();
- }
- }
-
-}
\ No newline at end of file
Deleted: branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java
===================================================================
--- branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.context;
-
-import javax.faces.component.ContextCallback;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * Callback Interface
- * for invoke lifecycle methods ( processDecodes, processValidators ... encodeEnd ).
- *
- * @author shura
- */
-public interface InvokerCallback extends ContextCallback {
-
- /**
- * Process method on given component.
- *
- * @param context
- * @param component
- */
- public void invokeContextCallback(FacesContext context, UIComponent component);
-
- /**
- * Default processing on UIVewRoot
- *
- * @param context
- */
- public void invokeRoot(FacesContext context);
-}
Deleted: branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
===================================================================
--- branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,120 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.context;
-
-import javax.faces.FacesException;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.richfaces.renderkit.HtmlConstants;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-class ResponseWriterContentHandler implements ContentHandler {
- private String linkClass;
- private Node node;
-
- public ResponseWriterContentHandler(String linkClass) {
- super();
-
- try {
- Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
-
- node = document.createElement("head");
- document.appendChild(node);
- } catch (ParserConfigurationException e) {
- throw new FacesException(e.getLocalizedMessage(), e);
- }
-
- this.linkClass = linkClass;
- }
-
- public void characters(char[] ch, int start, int length) throws SAXException {
- node.appendChild(node.getOwnerDocument().createTextNode(new String(ch, start, length)));
- }
-
- public void endDocument() throws SAXException {
- }
-
- public void endElement(String uri, String localName, String name) throws SAXException {
- node = node.getParentNode();
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- throw new UnsupportedOperationException();
- }
-
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- }
-
- public void processingInstruction(String target, String data) throws SAXException {
- throw new UnsupportedOperationException();
- }
-
- public void setDocumentLocator(Locator locator) {
- throw new UnsupportedOperationException();
- }
-
- public void skippedEntity(String name) throws SAXException {
- throw new UnsupportedOperationException();
- }
-
- public void startDocument() throws SAXException {
- }
-
- public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
- Document document = node.getOwnerDocument();
- Element element = document.createElement(localName);
- int length = atts.getLength();
-
- for (int i = 0; i < length; i++) {
- element.setAttribute(atts.getLocalName(i), atts.getValue(i));
- }
-
- if (HtmlConstants.LINK_ELEMENT.equals(localName)) {
- element.setAttribute(HtmlConstants.CLASS_ATTRIBUTE, linkClass);
- }
-
- node = node.appendChild(element);
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- throw new UnsupportedOperationException();
- }
-
- public Node[] getNodes() {
- NodeList childNodes = node.getChildNodes();
- Node[] list = new Node[childNodes.getLength()];
-
- for (int i = 0; i < list.length; i++) {
- list[i] = childNodes.item(i);
- }
-
- return list;
- }
-}
Deleted: branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
===================================================================
--- branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,593 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.context;
-
-/**
- * @author Nick Belaevski
- */
-
-//TODO remove - https://jira.jboss.org/jira/browse/RFPL-42
-public class ViewResources {
-
-// private static final String INIT_PARAMETER_PREFIX = "_init_parameter_";
-// private static final Object NULL = new Object();
-//
-// private String scriptStrategy;
-//
-// private String styleStrategy;
-//
-// private boolean useStdControlsSkinning;
-//
-// private boolean useStdControlsSkinningClasses;
-//
-// private HeadResponseWriter componentWriter;
-//
-// private HeadResponseWriter userWriter;
-//
-// private RenderKit renderKit;
-//
-// private Node[] headNodes = null;
-//
-// private static final String EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY = ViewResources.class.getName() + "EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY";
-//
-// private static final InternetResource EXTENDED_SKINNING_ON_RESOURCE = new InternetResourceBase() {
-//
-// private final String RESOURCE_KEY = this.getClass().getName();
-//
-// @Override
-// public void encode(FacesContext context, Object data)
-// throws IOException {
-//
-// encode(context, data, Collections.EMPTY_MAP);
-// }
-//
-// @Override
-// public void encode(FacesContext context, Object data,
-// Map<String, Object> attributes) throws IOException {
-//
-// Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-// if (requestMap.get(RESOURCE_KEY) == null) {
-// ResponseWriter writer = context.getResponseWriter();
-// writer.startElement(HTML.SCRIPT_ELEM, null);
-//
-// if (!attributes.containsKey(HTML.TYPE_ATTR)) {
-// writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
-// }
-//
-// for (Map.Entry<String, Object> entry : attributes.entrySet()) {
-// writer.writeAttribute(entry.getKey(), entry.getValue(), null);
-// }
-//
-// writer.writeText("window.RICH_FACES_EXTENDED_SKINNING_ON=true;", null);
-//
-// writer.endElement(HTML.SCRIPT_ELEM);
-//
-// requestMap.put(RESOURCE_KEY, Boolean.TRUE);
-// }
-// }
-// };
-//
-// public void setScriptStrategy(String scriptsStrategy) {
-// this.scriptStrategy = scriptsStrategy;
-// }
-//
-// public void setStyleStrategy(String stylesStrategy) {
-// this.styleStrategy = stylesStrategy;
-// }
-//
-// public void setUseStdControlsSkinning(boolean stdControlsSkinning) {
-// this.useStdControlsSkinning = stdControlsSkinning;
-// }
-//
-// public void setUseStdControlsSkinningClasses(boolean stdControlsSkinningClasses) {
-// this.useStdControlsSkinningClasses = stdControlsSkinningClasses;
-// }
-//
-// public void setExtendedSkinningAllowed(boolean extendedSkinningAllowed) {
-// this.extendedSkinningAllowed = extendedSkinningAllowed;
-// }
-//
-// private static String SCRIPT = HTML.SCRIPT_ELEM;
-// private static String SCRIPT_UC = SCRIPT.toUpperCase(Locale.US);
-//
-// private static String SRC = HTML.SRC_ATTRIBUTE;
-// private static String SRC_UC = SRC.toUpperCase(Locale.US);
-//
-// private void mergeHeadResourceNode(List<Node> nodes, Set<String> renderedScripts, Node node) {
-// boolean shouldAdd = true;
-//
-// String nodeName = node.getNodeName();
-// if (SCRIPT.equals(nodeName) || SCRIPT_UC.equals(nodeName)) {
-// if (node.getFirstChild() == null) {
-// //no text content etc.
-//
-// NamedNodeMap attributes = node.getAttributes();
-// if (attributes != null) {
-// Node item = attributes.getNamedItem(SRC);
-// if (item == null) {
-// attributes.getNamedItem(SRC_UC);
-// }
-//
-// if (item != null) {
-// String src = item.getNodeValue();
-// if (src != null) {
-// if (renderedScripts.contains(src)) {
-// shouldAdd = false;
-// } else {
-// renderedScripts.add(src);
-// }
-// }
-// }
-// }
-// }
-// }
-//
-// if (shouldAdd) {
-// nodes.add(node);
-// }
-// }
-//
-// private Node[] mergeHeadResourceNodes() {
-// List<Node> result = new ArrayList<Node>();
-//
-// Set<String> scripts = new HashSet<String>();
-//
-// for (Node node : componentWriter.getNodes()) {
-// mergeHeadResourceNode(result, scripts, node);
-// }
-//
-// for (Node node : userWriter.getNodes()) {
-// mergeHeadResourceNode(result, scripts, node);
-// }
-//
-// return result.toArray(new Node[result.size()]);
-// }
-//
-// public Node[] getHeadEvents() {
-// if (headNodes == null) {
-// headNodes = mergeHeadResourceNodes();
-// }
-//
-// return headNodes;
-// }
-//
-// private static final Log log = LogFactory.getLog(ViewResources.class);
-//
-// //todo
-//
-// private static final Map<String, Object> EXTENDED_SKINNING = new HashMap<String, Object>(1);
-//
-// static {
-// EXTENDED_SKINNING.put(HTML.MEDIA_ATTRIBUTE, "rich-extended-skinning");
-// }
-//
-// public static final String SKINNING_STYLES_PATH = "/org/richfaces/renderkit/html/css/";
-//
-// public static final String QUEUE_SCRIPT_RESOURCE = "org.ajax4jsf.renderkit.html.scripts.QueueScript";
-//
-// private boolean extendedSkinningAllowed;
-//
-// private boolean processScripts;
-//
-// private boolean processStyles;
-//
-// private boolean useSkinning;
-//
-// private InternetResourceBuilder resourceBuilder;
-//
-// private boolean ajaxRequest;
-//
-// public static final String COMPONENT_RESOURCE_LINK_CLASS = "component";
-//
-// public static final String USER_RESOURCE_LINK_CLASS = "user";
-//
-// class HeadResponseWriter extends SAXResponseWriter {
-//
-// public Node[] getNodes() {
-// return ((ResponseWriterContentHandler) getXmlConsumer()).getNodes();
-// }
-//
-// public HeadResponseWriter(String linkClass) {
-// super(new ResponseWriterContentHandler(linkClass));
-//
-// }
-// }
-//
-// private void encodeResources(FacesContext context, ResourceRenderer renderer, Set<String> set) throws IOException {
-//
-// if (set != null) {
-// URIInternetResource resourceImpl = new URIInternetResource();
-//
-// for (String uri : set) {
-// resourceImpl.setUri(uri);
-// renderer.encode(resourceImpl, context, null);
-// }
-// }
-// }
-//
-// private boolean encodeSkinningResources(FacesContext context, InternetResourceBuilder resourceBuilder) throws IOException, FacesException {
-// String resourceSuffix = null;
-//
-// if (useStdControlsSkinning) {
-// if (useStdControlsSkinningClasses) {
-// resourceSuffix = "_both.xcss";
-// } else {
-// resourceSuffix = ".xcss";
-// }
-// } else {
-// if (useStdControlsSkinningClasses) {
-// resourceSuffix = "_classes.xcss";
-// } else {
-// //no resources
-// }
-// }
-//
-// if (resourceSuffix != null) {
-// resourceBuilder.createResource(
-// this, SKINNING_STYLES_PATH.concat("basic").concat(resourceSuffix)).encode(context, null);
-//
-// if (extendedSkinningAllowed) {
-// resourceBuilder.createResource(
-// this, SKINNING_STYLES_PATH.concat("extended").concat(resourceSuffix)).encode(context, null, EXTENDED_SKINNING);
-// }
-//
-// return true;
-// }
-//
-// return false;
-// }
-//
-// /**
-// * Find renderer for given component.
-// *
-// * @param context
-// * @param comp
-// * @param renderKit
-// * @return
-// */
-// private Renderer getRenderer(FacesContext context, UIComponent comp) {
-//
-// String rendererType = comp.getRendererType();
-// if (rendererType != null) {
-// return (renderKit.getRenderer(comp.getFamily(), rendererType));
-// } else {
-// return (null);
-// }
-// }
-//
-// public void processHeadResources(FacesContext context) throws FacesException {
-//
-// RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
-// .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-// renderKit = rkFactory.getRenderKit(context, context
-// .getViewRoot().getRenderKitId());
-//
-// boolean scriptsOff = false;
-//
-// processStyles = true;
-// processScripts = true;
-// useSkinning = false;
-//
-// ajaxRequest = AjaxContext.getCurrentInstance(context).isAjaxRequest(context);
-//
-// if (log.isDebugEnabled()) {
-// log
-// .debug("Process component tree for collect used scripts and styles");
-// }
-//
-// String skinStyleSheetUri = null;
-// String skinExtendedStyleSheetUri = null;
-//
-// Skin skin = null;
-// try {
-// skin = SkinFactory.getInstance().getSkin(context);
-// // For a "NULL" skin, do not collect components stylesheets
-// if ("false".equals(skin.getParameter(context,
-// Skin.LOAD_STYLE_SHEETS))) {
-// processStyles = false;
-// }
-// // Set default style sheet for current skin.
-// skinStyleSheetUri = (String) skin.getParameter(context,
-// Skin.GENERAL_STYLE_SHEET);
-// // Set default style sheet for current skin.
-// skinExtendedStyleSheetUri = (String) skin.getParameter(context,
-// Skin.EXTENDED_STYLE_SHEET);
-// } catch (SkinNotFoundException e) {
-// if (log.isWarnEnabled()) {
-// log.warn("Current Skin is not found", e);
-// }
-// }
-//
-// resourceBuilder = InternetResourceBuilder.getInstance();
-//
-// ResponseWriter oldResponseWriter = context.getResponseWriter();
-//
-// componentWriter = new HeadResponseWriter("component");
-// userWriter = new HeadResponseWriter("user");
-//
-// try {
-// componentWriter.startDocument();
-// userWriter.startDocument();
-//
-// context.setResponseWriter(componentWriter);
-//
-// // Check init parameters for a resources processing.
-// if (null != scriptStrategy) {
-// if (InternetResourceBuilder.LOAD_NONE
-// .equals(scriptStrategy)) {
-// scriptsOff = true;
-// processScripts = false;
-// } else if (InternetResourceBuilder.LOAD_ALL
-// .equals(scriptStrategy)) {
-// processScripts = false;
-// // For an "ALL" strategy, it is not necessary to load scripts in the ajax request
-// if (!ajaxRequest) {
-// try {
-// resourceBuilder
-// .createResource(
-// this,
-// InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT).encode(context, null);
-// resourceBuilder
-// .createResource(
-// this,
-// InternetResourceBuilder.COMMON_UI_SCRIPT).encode(context, null);
-//
-// } catch (ResourceNotFoundException e) {
-// if (log.isWarnEnabled()) {
-// log
-// .warn("No aggregated javaScript library found "
-// + e.getMessage());
-// }
-// }
-//
-// }
-// }
-// }
-//
-// if (InternetResourceBuilder.LOAD_NONE.equals(styleStrategy)) {
-// processStyles = false;
-// } else if (InternetResourceBuilder.LOAD_ALL
-// .equals(styleStrategy)) {
-// processStyles = false;
-// // For an "ALL" strategy, it is not necessary to load styles
-// // in the ajax request
-// if (!ajaxRequest) {
-//
-// try {
-// useSkinning = encodeSkinningResources(context, resourceBuilder);
-//
-// resourceBuilder
-// .createResource(this, InternetResourceBuilder.COMMON_STYLE).encode(context, null);
-//
-// } catch (ResourceNotFoundException e) {
-// if (log.isWarnEnabled()) {
-// log.warn("No stylesheet found "
-// + e.getMessage());
-// }
-// }
-//
-// }
-// } else {
-// useSkinning = encodeSkinningResources(context, resourceBuilder);
-// }
-//
-// //traverse components
-// //traverse(context, context.getViewRoot());
-//
-// context.setResponseWriter(componentWriter);
-//
-// QueueRegistry queueRegistry = QueueRegistry.getInstance(context);
-// if (Boolean.valueOf(getInitParameterValue(context, "org.richfaces.queue.global.enabled"))) {
-// queueRegistry.setShouldCreateDefaultGlobalQueue();
-// }
-//
-// if (queueRegistry.hasQueuesToEncode()) {
-// InternetResource queueScriptResource = resourceBuilder.getResource(QUEUE_SCRIPT_RESOURCE);
-// queueScriptResource.encode(context, null);
-// }
-//
-// // Append Skin StyleSheet after a
-// if (null != skinStyleSheetUri) {
-// String resourceURL = context.getApplication()
-// .getViewHandler().getResourceURL(context,
-// skinStyleSheetUri);
-//
-// URIInternetResource resourceImpl = new URIInternetResource();
-// resourceImpl.setUri(resourceURL);
-// resourceImpl.setRenderer(resourceBuilder.getStyleRenderer());
-// resourceImpl.encode(context, null);
-//
-// useSkinning = true;
-// }
-//
-// if (null != skinExtendedStyleSheetUri && extendedSkinningAllowed) {
-// String resourceURL = context.getApplication().getViewHandler().getResourceURL(context,
-// skinExtendedStyleSheetUri);
-//
-// URIInternetResource resourceImpl = new URIInternetResource();
-// resourceImpl.setUri(resourceURL);
-// resourceImpl.setRenderer(resourceBuilder.getStyleRenderer());
-// resourceImpl.encode(context, null, EXTENDED_SKINNING);
-//
-// useSkinning = true;
-// }
-//
-// if (useSkinning && extendedSkinningAllowed) {
-// if (!ajaxRequest) {
-// if (!scriptsOff) {
-// //skinning levels aren't dynamic, page-level setting cannot be changed
-// //by AJAX request
-// EXTENDED_SKINNING_ON_RESOURCE.encode(context, null);
-// } else {
-//
-// Map<String, Object> applicationMap = context.getExternalContext().getApplicationMap();
-// if (applicationMap.get(EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY) == null) {
-// //do it once per application life - strategies can be changed dynamically
-// ResponseWriter writer = context.getResponseWriter();
-// try {
-// StringWriter stringWriter = new StringWriter();
-//
-// if (oldResponseWriter != null) {
-// context.setResponseWriter(oldResponseWriter.cloneWithWriter(stringWriter));
-// } else {
-// context.setResponseWriter(this.renderKit.createResponseWriter(
-// stringWriter, "text/html",
-// "US-ASCII"));
-// }
-//
-//
-// EXTENDED_SKINNING_ON_RESOURCE.encode(context, null);
-//
-// stringWriter.flush();
-//
-// if (log.isInfoEnabled()) {
-// log.info("Extended skinning is on and NONE scripts loading strategy was detected. " +
-// "Do not forget that one of " + InternetResourceBuilder.SKINNING_SCRIPT + " or " +
-// InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT + " resources should be presented " +
-// "on the page together with the following code: \n" + stringWriter.getBuffer().toString() +
-// "\nfor extended level of skinning to work.");
-// }
-// } finally {
-// if (writer != null) {
-// context.setResponseWriter(writer);
-// }
-// }
-//
-// applicationMap.put(EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY, Boolean.TRUE);
-// }
-// }
-// }
-//
-// if (processScripts) {
-// InternetResource resource = resourceBuilder.createResource(null,
-// InternetResourceBuilder.SKINNING_SCRIPT);
-//
-// resource.encode(context, null);
-// }
-// }
-//
-// componentWriter.endDocument();
-// userWriter.endDocument();
-// } catch (IOException e) {
-// throw new FacesException(e.getLocalizedMessage(), e);
-// } finally {
-// if (oldResponseWriter != null) {
-// context.setResponseWriter(oldResponseWriter);
-// }
-// }
-// }
-//
-// private static String getInitParameterValue(FacesContext context, String parameterName) {
-//
-// String key = INIT_PARAMETER_PREFIX + parameterName;
-//
-// ExternalContext externalContext = context.getExternalContext();
-// Map<String, Object> applicationMap = externalContext.getApplicationMap();
-// Object mutex = externalContext.getRequest();
-// Object parameterValue = null;
-//
-// synchronized (mutex) {
-// parameterValue = applicationMap.get(key);
-//
-// if (parameterValue == null) {
-//
-// String initParameter = externalContext.getInitParameter(parameterName);
-// if (initParameter != null) {
-//
-// if (ELUtils.isValueReference(initParameter)) {
-// Application application = context.getApplication();
-// ExpressionFactory expressionFactory = application.getExpressionFactory();
-//
-// parameterValue = expressionFactory.createValueExpression(context.getELContext(),
-// initParameter,
-// String.class);
-// } else {
-// parameterValue = initParameter;
-// }
-//
-// } else {
-// parameterValue = NULL;
-// }
-//
-// applicationMap.put(key, parameterValue);
-// }
-// }
-//
-// return evaluate(context, parameterValue);
-// }
-//
-// private static String evaluate(FacesContext context, Object parameterValue) {
-// if (parameterValue == NULL || parameterValue == null) {
-// return null;
-// } else if (parameterValue instanceof ValueExpression) {
-// ValueExpression expression = (ValueExpression) parameterValue;
-//
-// return (String) expression.getValue(context.getELContext());
-// } else {
-// return parameterValue.toString();
-// }
-// }
-//
-// public void initialize(FacesContext context) {
-// boolean extendedSkinningAllowed = true;
-// String skinningLevel = getInitParameterValue(context, InternetResourceBuilder.CONTROL_SKINNING_LEVEL);
-// if (skinningLevel != null && skinningLevel.length() > 0) {
-// if (InternetResourceBuilder.BASIC.equals(skinningLevel)) {
-// extendedSkinningAllowed = false;
-// } else if (!InternetResourceBuilder.EXTENDED.equals(skinningLevel)) {
-// throw new IllegalArgumentException("Value: " + skinningLevel +
-// " of " + InternetResourceBuilder.CONTROL_SKINNING_LEVEL
-// + " init parameter is invalid! Only " + InternetResourceBuilder.EXTENDED
-// + ", " + InternetResourceBuilder.BASIC + " can be used");
-// }
-// }
-//
-// this.setExtendedSkinningAllowed(extendedSkinningAllowed);
-//
-// this.setScriptStrategy(getInitParameterValue(context,
-// InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM));
-//
-// boolean useStdControlsSkinning = false;
-//
-// String stdControlsSkinning = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_PARAM);
-// if (stdControlsSkinning != null) {
-// useStdControlsSkinning = InternetResourceBuilder.ENABLE.equals(stdControlsSkinning);
-// }
-//
-// this.setUseStdControlsSkinning(useStdControlsSkinning);
-//
-// boolean useStdControlsSkinningClasses = true;
-//
-// String stdControlsSkinningClasses = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_CLASSES_PARAM);
-// if (stdControlsSkinningClasses != null) {
-// useStdControlsSkinningClasses = InternetResourceBuilder.ENABLE.equals(stdControlsSkinningClasses);
-// }
-//
-// this.setUseStdControlsSkinningClasses(useStdControlsSkinningClasses);
-//
-// this.setStyleStrategy(getInitParameterValue(context,
-// InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM));
-//
-//
-// }
-//
-}
Deleted: branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java
===================================================================
--- branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,1443 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-/*
-* ImageInfo.java
-*
-* Version 1.5
-*
-* A Java class to determine image width, height and color depth for
-* a number of image file formats.
-*
-* Written by Marco Schmidt
-* <http://www.geocities.com/marcoschmidt.geo/contact.html>.
-*
-* Contributed to the Public Domain.
-*
-* Last modification 2004-02-29
-*/
-package org.ajax4jsf.resource.image;
-
-import org.ajax4jsf.Messages;
-
-import java.io.DataInput;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Vector;
-
-/**
- * Get file format, image resolution, number of bits per pixel and optionally
- * number of images, comments and physical resolution from
- * JPEG, GIF, BMP, PCX, PNG, IFF, RAS, PBM, PGM, PPM, PSD and SWF files
- * (or input streams).
- * <p/>
- * Use the class like this:
- * <pre>
- * ImageInfo ii = new ImageInfo();
- * ii.setInput(in); // in can be InputStream or RandomAccessFile
- * ii.setDetermineImageNumber(true); // default is false
- * ii.setCollectComments(true); // default is false
- * if (!ii.check()) {
- * System.err.println("Not a supported image file format.");
- * return;
- * }
- * System.out.println(ii.getFormatName() + ", " + ii.getMimeType() +
- * ", " + ii.getWidth() + " x " + ii.getHeight() + " pixels, " +
- * ii.getBitsPerPixel() + " bits per pixel, " + ii.getNumberOfImages() +
- * " image(s), " + ii.getNumberOfComments() + " comment(s).");
- * // there are other properties, check out the API documentation
- * </pre>
- * You can also use this class as a command line program.
- * Call it with a number of image file names and URLs as parameters:
- * <pre>
- * java ImageInfo *.jpg *.png *.gif http://somesite.tld/image.jpg
- * </pre>
- * or call it without parameters and pipe data to it:
- * <pre>
- * java ImageInfo < image.jpg
- * </pre>
- * <p/>
- * Known limitations:
- * <ul>
- * <li>When the determination of the number of images is turned off, GIF bits
- * per pixel are only read from the global header.
- * For some GIFs, local palettes change this to a typically larger
- * value. To be certain to get the correct color depth, call
- * setDetermineImageNumber(true) before calling check().
- * The complete scan over the GIF file will take additional time.</li>
- * <li>Transparency information is not included in the bits per pixel count.
- * Actually, it was my decision not to include those bits, so it's a feature! ;-)</li>
- * </ul>
- * <p/>
- * Requirements:
- * <ul>
- * <li>Java 1.1 or higher</li>
- * </ul>
- * <p/>
- * The latest version can be found at <a href="http://www.geocities.com/marcoschmidt.geo/image-info.html">
- * http://www.geocities.com/marcoschmidt.geo/image-info.html</a>.
- * <p/>
- * Written by <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">Marco Schmidt</a>.
- * <p/>
- * This class is contributed to the Public Domain.
- * Use it at your own risk.
- * <p/>
- * Last modification 2004-02-29.
- * <p/>
- * History:
- * <ul>
- * <li><strong>2001-08-24</strong> Initial version.</li>
- * <li><strong>2001-10-13</strong> Added support for the file formats BMP and PCX.</li>
- * <li><strong>2001-10-16</strong> Fixed bug in read(int[], int, int) that returned
- * <li><strong>2002-01-22</strong> Added support for file formats Amiga IFF and Sun Raster (RAS).</li>
- * <li><strong>2002-01-24</strong> Added support for file formats Portable Bitmap / Graymap / Pixmap (PBM, PGM, PPM)
- * and Adobe Photoshop (PSD).
- * Added new method getMimeType() to return the MIME type associated with a particular file format.</li>
- * <li><strong>2002-03-15</strong> Added support to recognize number of images in file. Only works with GIF.
- * Use {@link #setDetermineImageNumber} with <code>true</code> as argument to identify animated GIFs
- * ({@link #getNumberOfImages()} will return a value larger than <code>1</code>).</li>
- * <li><strong>2002-04-10</strong> Fixed a bug in the feature 'determine number of images in animated GIF' introduced
- * with version 1.1.
- * Thanks to Marcelo P. Lima for sending in the bug report.
- * Released as 1.1.1.</li>
- * <li><strong>2002-04-18</strong> Added {@link #setCollectComments(boolean)}.
- * That new method lets the user specify whether textual comments are to be
- * stored in an internal list when encountered in an input image file / stream.
- * Added two methods to return the physical width and height of the image in dpi:
- * {@link #getPhysicalWidthDpi()} and {@link #getPhysicalHeightDpi()}.
- * If the physical resolution could not be retrieved, these methods return <code>-1</code>.
- * </li>
- * <li><strong>2002-04-23</strong> Added support for the new properties physical resolution and
- * comments for some formats. Released as 1.2.</li>
- * <li><strong>2002-06-17</strong> Added support for SWF, sent in by Michael Aird.
- * Changed checkJpeg() so that other APP markers than APP0 will not lead to a failure anymore.
- * Released as 1.3.</li>
- * <li><strong>2003-07-28</strong> Bug fix - skip method now takes return values into consideration.
- * Less bytes than necessary may have been skipped, leading to flaws in the retrieved information in some cases.
- * Thanks to Bernard Bernstein for pointing that out.
- * Released as 1.4.</li>
- * <li><strong>2004-02-29</strong> Added support for recognizing progressive JPEG and
- * interlaced PNG and GIF. A new method {@link #isProgressive()} returns whether ImageInfo
- * has found that the storage type is progressive (or interlaced).
- * Thanks to Joe Germuska for suggesting the feature.
- * Bug fix: BMP physical resolution is now correctly determined.
- * Released as 1.5.</li>
- * </ul>
- */
-public class ImageInfo {
- public static final int COLOR_TYPE_BLACK_AND_WHITE = 3;
- public static final int COLOR_TYPE_GRAYSCALE = 2;
- public static final int COLOR_TYPE_PALETTED = 1;
- public static final int COLOR_TYPE_TRUECOLOR_RGB = 0;
- public static final int COLOR_TYPE_UNKNOWN = -1;
-
- /**
- * Return value of {@link #getFormat()} for BMP streams.
- * BMP only supports one image per file.
- * BMP does not allow for comments.
- * The physical resolution can be stored.
- */
- public static final int FORMAT_BMP = 3;
-
- /**
- * Return value of {@link #getFormat()} for GIF streams.
- * ImageInfo can extract comments from GIFs and count the number
- * of images (GIFs with more than one image are animations).
- * If you know of a place where GIFs store the physical resolution
- * of an image, please
- * <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">send me a mail</a>!
- * It is determined whether the GIF stream is interlaced (see {@link #isProgressive()}).
- */
- public static final int FORMAT_GIF = 1;
-
- /**
- * Return value of {@link #getFormat()} for IFF streams.
- */
- public static final int FORMAT_IFF = 5;
-
- /**
- * Return value of {@link #getFormat()} for JPEG streams.
- * ImageInfo can extract physical resolution and comments
- * from JPEGs (only from APP0 headers).
- * Only one image can be stored in a file.
- * It is determined whether the JPEG stream is progressive
- * (see {@link #isProgressive()}).
- */
- public static final int FORMAT_JPEG = 0;
-
- /**
- * Return value of {@link #getFormat()} for PBM streams.
- */
- public static final int FORMAT_PBM = 7;
-
- /**
- * Return value of {@link #getFormat()} for PCX streams.
- * PCX does not allow for comments or more than one image per file.
- * However, the physical resolution can be stored.
- */
- public static final int FORMAT_PCX = 4;
-
- /**
- * Return value of {@link #getFormat()} for PGM streams.
- */
- public static final int FORMAT_PGM = 8;
-
- /**
- * Return value of {@link #getFormat()} for PNG streams.
- * PNG only supports one image per file.
- * Both physical resolution and comments can be stored with PNG,
- * but ImageInfo is currently not able to extract those.
- * It is determined whether the PNG stream is interlaced (see {@link #isProgressive()}).
- */
- public static final int FORMAT_PNG = 2;
-
- /**
- * Return value of {@link #getFormat()} for PPM streams.
- */
- public static final int FORMAT_PPM = 9;
-
- /**
- * Return value of {@link #getFormat()} for PSD streams.
- */
- public static final int FORMAT_PSD = 10;
-
- /**
- * Return value of {@link #getFormat()} for RAS streams.
- * Sun Raster allows for one image per file only and is not able to
- * store physical resolution or comments.
- */
- public static final int FORMAT_RAS = 6;
-
- /**
- * Return value of {@link #getFormat()} for SWF (Shockwave) streams.
- */
- public static final int FORMAT_SWF = 11;
-
- /**
- * The names of all supported file formats.
- * The FORMAT_xyz int constants can be used as index values for
- * this array.
- */
- private static final String[] FORMAT_NAMES = {
- "JPEG", "GIF", "PNG", "BMP", "PCX", "IFF", "RAS", "PBM", "PGM", "PPM", "PSD", "SWF"
- };
-
- /**
- * The names of the MIME types for all supported file formats.
- * The FORMAT_xyz int constants can be used as index values for
- * this array.
- */
- private static final String[] MIME_TYPE_STRINGS = {
- "image/jpeg", "image/gif", "image/png", "image/bmp", "image/pcx", "image/iff", "image/ras",
- "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", "image/psd",
- "application/x-shockwave-flash"
- };
- private int colorType = COLOR_TYPE_UNKNOWN;
- private boolean collectComments = true;
- private int bitBuf;
- private int bitPos;
- private int bitsPerPixel;
- private Vector comments;
- private boolean determineNumberOfImages;
- private DataInput din;
- private int format;
- private int height;
- private InputStream in;
- private int numberOfImages;
- private int physicalHeightDpi;
- private int physicalWidthDpi;
- private boolean progressive;
- private int width;
-
- private void addComment(String s) {
- if (comments == null) {
- comments = new Vector();
- }
-
- comments.addElement(s);
- }
-
- /**
- * Call this method after you have provided an input stream or file
- * using {@link #setInput(InputStream)} or {@link #setInput(DataInput)}.
- * If true is returned, the file format was known and information
- * on the file's content can be retrieved using the various getXyz methods.
- *
- * @return if information could be retrieved from input
- */
- public boolean check() {
- format = -1;
- width = -1;
- height = -1;
- bitsPerPixel = -1;
- numberOfImages = 1;
- physicalHeightDpi = -1;
- physicalWidthDpi = -1;
- comments = null;
-
- try {
- int b1 = read() & 0xff;
- int b2 = read() & 0xff;
-
- if ((b1 == 0x47) && (b2 == 0x49)) {
- return checkGif();
- } else if ((b1 == 0x89) && (b2 == 0x50)) {
- return checkPng();
- } else if ((b1 == 0xff) && (b2 == 0xd8)) {
- return checkJpeg();
- } else if ((b1 == 0x42) && (b2 == 0x4d)) {
- return checkBmp();
- } else if ((b1 == 0x0a) && (b2 < 0x06)) {
- return checkPcx();
- } else if ((b1 == 0x46) && (b2 == 0x4f)) {
- return checkIff();
- } else if ((b1 == 0x59) && (b2 == 0xa6)) {
- return checkRas();
- } else if ((b1 == 0x50) && (b2 >= 0x31) && (b2 <= 0x36)) {
- return checkPnm(b2 - '0');
- } else if ((b1 == 0x38) && (b2 == 0x42)) {
- return checkPsd();
- } else if ((b1 == 0x46) && (b2 == 0x57)) {
- return checkSwf();
- } else {
- return false;
- }
- } catch (IOException ioe) {
- return false;
- }
- }
-
- private boolean checkBmp() throws IOException {
- byte[] a = new byte[44];
-
- if (read(a) != a.length) {
- return false;
- }
-
- width = getIntLittleEndian(a, 16);
- height = getIntLittleEndian(a, 20);
-
- if ((width < 1) || (height < 1)) {
- return false;
- }
-
- bitsPerPixel = getShortLittleEndian(a, 26);
-
- if ((bitsPerPixel != 1) && (bitsPerPixel != 4) && (bitsPerPixel != 8) && (bitsPerPixel != 16)
- && (bitsPerPixel != 24) && (bitsPerPixel != 32)) {
- return false;
- }
-
- int x = (int) (getIntLittleEndian(a, 36) * 0.0254);
-
- if (x > 0) {
- setPhysicalWidthDpi(x);
- }
-
- int y = (int) (getIntLittleEndian(a, 40) * 0.0254);
-
- if (y > 0) {
- setPhysicalHeightDpi(y);
- }
-
- format = FORMAT_BMP;
-
- return true;
- }
-
- private boolean checkGif() throws IOException {
- final byte[] gifMagic87a = {0x46, 0x38, 0x37, 0x61};
- final byte[] gifMagic89a = {0x46, 0x38, 0x39, 0x61};
- byte[] a = new byte[11]; // 4 from the GIF signature + 7 from the global header
-
- if (read(a) != 11) {
- return false;
- }
-
- if ((!equals(a, 0, gifMagic89a, 0, 4)) && (!equals(a, 0, gifMagic87a, 0, 4))) {
- return false;
- }
-
- format = FORMAT_GIF;
- width = getShortLittleEndian(a, 4);
- height = getShortLittleEndian(a, 6);
-
- int flags = a[8] & 0xff;
-
- bitsPerPixel = ((flags >> 4) & 0x07) + 1;
- progressive = (flags & 0x02) != 0;
-
- if (!determineNumberOfImages) {
- return true;
- }
-
- // skip global color palette
- if ((flags & 0x80) != 0) {
- int tableSize = (1 << ((flags & 7) + 1)) * 3;
-
- skip(tableSize);
- }
-
- numberOfImages = 0;
-
- int blockType;
-
- do {
- blockType = read();
-
- switch (blockType) {
- case 0x2c: // image separator
- {
- if (read(a, 0, 9) != 9) {
- return false;
- }
-
- flags = a[8] & 0xff;
-
- int localBitsPerPixel = (flags & 0x07) + 1;
-
- if (localBitsPerPixel > bitsPerPixel) {
- bitsPerPixel = localBitsPerPixel;
- }
-
- if ((flags & 0x80) != 0) {
- skip((1 << localBitsPerPixel) * 3);
- }
-
- skip(1); // initial code length
-
- int n;
-
- do {
- n = read();
-
- if (n > 0) {
- skip(n);
- } else if (n == -1) {
- return false;
- }
- } while (n > 0);
-
- numberOfImages++;
-
- break;
- }
-
- case 0x21: // extension
- {
- int extensionType = read();
-
- if (collectComments && (extensionType == 0xfe)) {
- StringBuffer sb = new StringBuffer();
- int n;
-
- do {
- n = read();
-
- if (n == -1) {
- return false;
- }
-
- if (n > 0) {
- for (int i = 0; i < n; i++) {
- int ch = read();
-
- if (ch == -1) {
- return false;
- }
-
- sb.append((char) ch);
- }
- }
- } while (n > 0);
- } else {
- int n;
-
- do {
- n = read();
-
- if (n > 0) {
- skip(n);
- } else if (n == -1) {
- return false;
- }
- } while (n > 0);
- }
-
- break;
- }
-
- case 0x3b: // end of file
- break;
-
- default: {
- return false;
- }
- }
- } while (blockType != 0x3b);
-
- return true;
- }
-
- private boolean checkIff() throws IOException {
- byte[] a = new byte[10];
-
- // read remaining 2 bytes of file id, 4 bytes file size
- // and 4 bytes IFF subformat
- if (read(a, 0, 10) != 10) {
- return false;
- }
-
- final byte[] iffRm = {0x52, 0x4d};
-
- if (!equals(a, 0, iffRm, 0, 2)) {
- return false;
- }
-
- int type = getIntBigEndian(a, 6);
-
- if ((type != 0x494c424d) && // type must be ILBM...
- (type != 0x50424d20)) { // ...or PBM
- return false;
- }
-
- // loop chunks to find BMHD chunk
- do {
- if (read(a, 0, 8) != 8) {
- return false;
- }
-
- int chunkId = getIntBigEndian(a, 0);
- int size = getIntBigEndian(a, 4);
-
- if ((size & 1) == 1) {
- size++;
- }
-
- if (chunkId == 0x424d4844) { // BMHD chunk
- if (read(a, 0, 9) != 9) {
- return false;
- }
-
- format = FORMAT_IFF;
- width = getShortBigEndian(a, 0);
- height = getShortBigEndian(a, 2);
- bitsPerPixel = a[8] & 0xff;
-
- return (width > 0) && (height > 0) && (bitsPerPixel > 0) && (bitsPerPixel < 33);
- } else {
- skip(size);
- }
- } while (true);
- }
-
- private boolean checkJpeg() throws IOException {
- byte[] data = new byte[12];
-
- while (true) {
- if (read(data, 0, 4) != 4) {
- return false;
- }
-
- int marker = getShortBigEndian(data, 0);
- int size = getShortBigEndian(data, 2);
-
- if ((marker & 0xff00) != 0xff00) {
- return false; // not a valid marker
- }
-
- if (marker == 0xffe0) { // APPx
- if (size < 14) {
- return false; // APPx header must be >= 14 bytes
- }
-
- if (read(data, 0, 12) != 12) {
- return false;
- }
-
- final byte[] app0Id = {0x4a, 0x46, 0x49, 0x46, 0x00};
-
- if (equals(app0Id, 0, data, 0, 5)) {
-
- // System.out.println("data 7=" + data[7]);
- if (data[7] == 1) {
- setPhysicalWidthDpi(getShortBigEndian(data, 8));
- setPhysicalHeightDpi(getShortBigEndian(data, 10));
- } else if (data[7] == 2) {
- int x = getShortBigEndian(data, 8);
- int y = getShortBigEndian(data, 10);
-
- setPhysicalWidthDpi((int) (x * 2.54f));
- setPhysicalHeightDpi((int) (y * 2.54f));
- }
- }
-
- skip(size - 14);
- } else if (collectComments && (size > 2) && (marker == 0xfffe)) { // comment
- size -= 2;
-
- byte[] chars = new byte[size];
-
- if (read(chars, 0, size) != size) {
- return false;
- }
-
- String comment = new String(chars, "iso-8859-1");
-
- comment = comment.trim();
- addComment(comment);
- } else if ((marker >= 0xffc0) && (marker <= 0xffcf) && (marker != 0xffc4) && (marker != 0xffc8)) {
- if (read(data, 0, 6) != 6) {
- return false;
- }
-
- format = FORMAT_JPEG;
- bitsPerPixel = (data[0] & 0xff) * (data[5] & 0xff);
- progressive = (marker == 0xffc2) || (marker == 0xffc6) || (marker == 0xffca) || (marker == 0xffce);
- width = getShortBigEndian(data, 3);
- height = getShortBigEndian(data, 1);
-
- return true;
- } else {
- skip(size - 2);
- }
- }
- }
-
- private boolean checkPcx() throws IOException {
- byte[] a = new byte[64];
-
- if (read(a) != a.length) {
- return false;
- }
-
- if (a[0] != 1) { // encoding, 1=RLE is only valid value
- return false;
- }
-
- // width / height
- int x1 = getShortLittleEndian(a, 2);
- int y1 = getShortLittleEndian(a, 4);
- int x2 = getShortLittleEndian(a, 6);
- int y2 = getShortLittleEndian(a, 8);
-
- if ((x1 < 0) || (x2 < x1) || (y1 < 0) || (y2 < y1)) {
- return false;
- }
-
- width = x2 - x1 + 1;
- height = y2 - y1 + 1;
-
- // color depth
- int bits = a[1];
- int planes = a[63];
-
- if ((planes == 1) && ((bits == 1) || (bits == 2) || (bits == 4) || (bits == 8))) {
-
- // paletted
- bitsPerPixel = bits;
- } else if ((planes == 3) && (bits == 8)) {
-
- // RGB truecolor
- bitsPerPixel = 24;
- } else {
- return false;
- }
-
- setPhysicalWidthDpi(getShortLittleEndian(a, 10));
- setPhysicalHeightDpi(getShortLittleEndian(a, 10));
- format = FORMAT_PCX;
-
- return true;
- }
-
- private boolean checkPng() throws IOException {
- final byte[] pngMagic = {
- 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a
- };
- byte[] a = new byte[27];
-
- if (read(a) != 27) {
- return false;
- }
-
- if (!equals(a, 0, pngMagic, 0, 6)) {
- return false;
- }
-
- format = FORMAT_PNG;
- width = getIntBigEndian(a, 14);
- height = getIntBigEndian(a, 18);
- bitsPerPixel = a[22] & 0xff;
-
- int colorType = a[23] & 0xff;
-
- if ((colorType == 2) || (colorType == 6)) {
- bitsPerPixel *= 3;
- }
-
- progressive = (a[26] & 0xff) != 0;
-
- return true;
- }
-
- private boolean checkPnm(int id) throws IOException {
- if ((id < 1) || (id > 6)) {
- return false;
- }
-
- final int[] pnmFormats = {FORMAT_PBM, FORMAT_PGM, FORMAT_PPM};
-
- format = pnmFormats[(id - 1) % 3];
-
- boolean hasPixelResolution = false;
- String s;
-
- while (true) {
- s = readLine();
-
- if (s != null) {
- s = s.trim();
- }
-
- if ((s == null) || (s.length() < 1)) {
- continue;
- }
-
- if (s.charAt(0) == '#') { // comment
- if (collectComments && (s.length() > 1)) {
- addComment(s.substring(1));
- }
-
- continue;
- }
-
- if (!hasPixelResolution) { // split "343 966" into width=343, height=966
- int spaceIndex = s.indexOf(' ');
-
- if (spaceIndex == -1) {
- return false;
- }
-
- String widthString = s.substring(0, spaceIndex);
-
- spaceIndex = s.lastIndexOf(' ');
-
- if (spaceIndex == -1) {
- return false;
- }
-
- String heightString = s.substring(spaceIndex + 1);
-
- try {
- width = Integer.parseInt(widthString);
- height = Integer.parseInt(heightString);
- } catch (NumberFormatException nfe) {
- return false;
- }
-
- if ((width < 1) || (height < 1)) {
- return false;
- }
-
- if (format == FORMAT_PBM) {
- bitsPerPixel = 1;
-
- return true;
- }
-
- hasPixelResolution = true;
- } else {
- int maxSample;
-
- try {
- maxSample = Integer.parseInt(s);
- } catch (NumberFormatException nfe) {
- return false;
- }
-
- if (maxSample < 0) {
- return false;
- }
-
- for (int i = 0; i < 25; i++) {
- if (maxSample < (1 << (i + 1))) {
- bitsPerPixel = i + 1;
-
- if (format == FORMAT_PPM) {
- bitsPerPixel *= 3;
- }
-
- return true;
- }
- }
-
- return false;
- }
- }
- }
-
- private boolean checkPsd() throws IOException {
- byte[] a = new byte[24];
-
- if (read(a) != a.length) {
- return false;
- }
-
- final byte[] psdMagic = {0x50, 0x53};
-
- if (!equals(a, 0, psdMagic, 0, 2)) {
- return false;
- }
-
- format = FORMAT_PSD;
- width = getIntBigEndian(a, 16);
- height = getIntBigEndian(a, 12);
-
- int channels = getShortBigEndian(a, 10);
- int depth = getShortBigEndian(a, 20);
-
- bitsPerPixel = channels * depth;
-
- return (width > 0) && (height > 0) && (bitsPerPixel > 0) && (bitsPerPixel <= 64);
- }
-
- private boolean checkRas() throws IOException {
- byte[] a = new byte[14];
-
- if (read(a) != a.length) {
- return false;
- }
-
- final byte[] rasMagic = {0x6a, (byte) 0x95};
-
- if (!equals(a, 0, rasMagic, 0, 2)) {
- return false;
- }
-
- format = FORMAT_RAS;
- width = getIntBigEndian(a, 2);
- height = getIntBigEndian(a, 6);
- bitsPerPixel = getIntBigEndian(a, 10);
-
- return (width > 0) && (height > 0) && (bitsPerPixel > 0) && (bitsPerPixel <= 24);
- }
-
- // Written by Michael Aird.
- private boolean checkSwf() throws IOException {
-
- // get rid of the last byte of the signature, the byte of the version and 4 bytes of the size
- byte[] a = new byte[6];
-
- if (read(a) != a.length) {
- return false;
- }
-
- format = FORMAT_SWF;
-
- int bitSize = (int) readUBits(5);
- int minX = (int) readSBits(bitSize);
- int maxX = (int) readSBits(bitSize);
- int minY = (int) readSBits(bitSize);
- int maxY = (int) readSBits(bitSize);
-
- width = maxX / 20; // cause we're in twips
- height = maxY / 20; // cause we're in twips
- setPhysicalWidthDpi(72);
- setPhysicalHeightDpi(72);
-
- return (width > 0) && (height > 0);
- }
-
- /**
- * Run over String list, return false iff at least one of the arguments
- * equals <code>-c</code>.
- */
- private static boolean determineVerbosity(String[] args) {
- if ((args != null) && (args.length > 0)) {
- for (int i = 0; i < args.length; i++) {
- if ("-c".equals(args[i])) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- private boolean equals(byte[] a1, int offs1, byte[] a2, int offs2, int num) {
- while (num-- > 0) {
- if (a1[offs1++] != a2[offs2++]) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * If {@link #check()} was successful, returns the image's number of bits per pixel.
- * Does not include transparency information like the alpha channel.
- *
- * @return number of bits per image pixel
- */
- public int getBitsPerPixel() {
- return bitsPerPixel;
- }
-
- /**
- * Returns the index'th comment retrieved from the image.
- *
- * @throws IllegalArgumentException if index is smaller than 0 or larger than or equal
- * to the number of comments retrieved
- * @see #getNumberOfComments
- */
- public String getComment(int index) {
- if ((comments == null) || (index < 0) || (index >= comments.size())) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_COMMENT_INDEX, "" + index));
- }
-
- return (String) comments.elementAt(index);
- }
-
- /**
- * If {@link #check()} was successful, returns the image format as one
- * of the FORMAT_xyz constants from this class.
- * Use {@link #getFormatName()} to get a textual description of the file format.
- *
- * @return file format as a FORMAT_xyz constant
- */
- public int getFormat() {
- return format;
- }
-
- /**
- * If {@link #check()} was successful, returns the image format's name.
- * Use {@link #getFormat()} to get a unique number.
- *
- * @return file format name
- */
- public String getFormatName() {
- if ((format >= 0) && (format < FORMAT_NAMES.length)) {
- return FORMAT_NAMES[format];
- } else {
- return "?";
- }
- }
-
- /**
- * If {@link #check()} was successful, returns one the image's vertical
- * resolution in pixels.
- *
- * @return image height in pixels
- */
- public int getHeight() {
- return height;
- }
-
- private int getIntBigEndian(byte[] a, int offs) {
- return (a[offs] & 0xff) << 24 | (a[offs + 1] & 0xff) << 16 | (a[offs + 2] & 0xff) << 8 | a[offs + 3] & 0xff;
- }
-
- private int getIntLittleEndian(byte[] a, int offs) {
- return (a[offs + 3] & 0xff) << 24 | (a[offs + 2] & 0xff) << 16 | (a[offs + 1] & 0xff) << 8 | a[offs] & 0xff;
- }
-
- /**
- * If {@link #check()} was successful, returns a String with the
- * MIME type of the format.
- *
- * @return MIME type, e.g. <code>image/jpeg</code>
- */
- public String getMimeType() {
- if ((format >= 0) && (format < MIME_TYPE_STRINGS.length)) {
- if ((format == FORMAT_JPEG) && progressive) {
- return "image/pjpeg";
- }
-
- return MIME_TYPE_STRINGS[format];
- } else {
- return null;
- }
- }
-
- /**
- * If {@link #check()} was successful and {@link #setCollectComments(boolean)} was called with
- * <code>true</code> as argument, returns the number of comments retrieved
- * from the input image stream / file.
- * Any number >= 0 and smaller than this number of comments is then a
- * valid argument for the {@link #getComment(int)} method.
- *
- * @return number of comments retrieved from input image
- */
- public int getNumberOfComments() {
- if (comments == null) {
- return 0;
- } else {
- return comments.size();
- }
- }
-
- /**
- * Returns the number of images in the examined file.
- * Assumes that <code>setDetermineImageNumber(true);</code> was called before
- * a successful call to {@link #check()}.
- * This value can currently be only different from <code>1</code> for GIF images.
- *
- * @return number of images in file
- */
- public int getNumberOfImages() {
- return numberOfImages;
- }
-
- /**
- * Returns the physical height of this image in dots per inch (dpi).
- * Assumes that {@link #check()} was successful.
- * Returns <code>-1</code> on failure.
- *
- * @return physical height (in dpi)
- * @see #getPhysicalWidthDpi()
- * @see #getPhysicalHeightInch()
- */
- public int getPhysicalHeightDpi() {
- return physicalHeightDpi;
- }
-
- /**
- * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
- * or -1 if no value could be found.
- *
- * @return physical height (in dpi)
- * @see #getPhysicalHeightDpi()
- * @see #getPhysicalWidthDpi()
- * @see #getPhysicalWidthInch()
- */
- public float getPhysicalHeightInch() {
- int h = getHeight();
- int ph = getPhysicalHeightDpi();
-
- if ((h > 0) && (ph > 0)) {
- return ((float) h) / ((float) ph);
- } else {
- return -1.0f;
- }
- }
-
- /**
- * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
- * or -1 if no value could be found.
- *
- * @return physical width (in dpi)
- * @see #getPhysicalHeightDpi()
- * @see #getPhysicalWidthInch()
- * @see #getPhysicalHeightInch()
- */
- public int getPhysicalWidthDpi() {
- return physicalWidthDpi;
- }
-
- /**
- * Returns the physical width of an image in inches, or
- * <code>-1.0f</code> if width information is not available.
- * Assumes that {@link #check} has been called successfully.
- *
- * @return physical width in inches or <code>-1.0f</code> on failure
- * @see #getPhysicalWidthDpi
- * @see #getPhysicalHeightInch
- */
- public float getPhysicalWidthInch() {
- int w = getWidth();
- int pw = getPhysicalWidthDpi();
-
- if ((w > 0) && (pw > 0)) {
- return ((float) w) / ((float) pw);
- } else {
- return -1.0f;
- }
- }
-
- private int getShortBigEndian(byte[] a, int offs) {
- return (a[offs] & 0xff) << 8 | (a[offs + 1] & 0xff);
- }
-
- private int getShortLittleEndian(byte[] a, int offs) {
- return (a[offs] & 0xff) | (a[offs + 1] & 0xff) << 8;
- }
-
- /**
- * If {@link #check()} was successful, returns one the image's horizontal
- * resolution in pixels.
- *
- * @return image width in pixels
- */
- public int getWidth() {
- return width;
- }
-
- /**
- * Returns whether the image is stored in a progressive (also called: interlaced) way.
- *
- * @return true for progressive/interlaced, false otherwise
- */
- public boolean isProgressive() {
- return progressive;
- }
-
- /**
- * To use this class as a command line application, give it either
- * some file names as parameters (information on them will be
- * printed to standard output, one line per file) or call
- * it with no parameters. It will then check data given to it
- * via standard input.
- *
- * @param args the program arguments which must be file names
- */
- public static void main(String[] args) {
- ImageInfo imageInfo = new ImageInfo();
-
- imageInfo.setDetermineImageNumber(true);
-
- boolean verbose = determineVerbosity(args);
-
- if (args.length == 0) {
- run(null, System.in, imageInfo, verbose);
- } else {
- int index = 0;
-
- while (index < args.length) {
- InputStream in = null;
-
- try {
- String name = args[index++];
-
- System.out.print(name + ";");
-
- if (name.startsWith("http://")) {
- in = new URL(name).openConnection().getInputStream();
- } else {
- in = new FileInputStream(name);
- }
-
- run(name, in, imageInfo, verbose);
- in.close();
- } catch (Exception e) {
- System.out.println(e);
-
- try {
- in.close();
- } catch (Exception ee) {
-
- // TODO Refactoring
- }
- }
- }
- }
- }
-
- private static void print(String sourceName, ImageInfo ii, boolean verbose) {
- if (verbose) {
- printVerbose(sourceName, ii);
- } else {
- printCompact(sourceName, ii);
- }
- }
-
- private static void printCompact(String sourceName, ImageInfo imageInfo) {
- System.out.println(imageInfo.getFormatName() + ";" + imageInfo.getMimeType() + ";" + imageInfo.getWidth() + ";"
- + imageInfo.getHeight() + ";" + imageInfo.getBitsPerPixel() + ";"
- + imageInfo.getNumberOfImages() + ";" + imageInfo.getPhysicalWidthDpi() + ";"
- + imageInfo.getPhysicalHeightDpi() + ";" + imageInfo.getPhysicalWidthInch() + ";"
- + imageInfo.getPhysicalHeightInch() + ";" + imageInfo.isProgressive());
- }
-
- private static void printLine(int indentLevels, String text, float value, float minValidValue) {
- if (value < minValidValue) {
- return;
- }
-
- printLine(indentLevels, text, Float.toString(value));
- }
-
- private static void printLine(int indentLevels, String text, int value, int minValidValue) {
- if (value >= minValidValue) {
- printLine(indentLevels, text, Integer.toString(value));
- }
- }
-
- private static void printLine(int indentLevels, String text, String value) {
- if ((value == null) || (value.length() == 0)) {
- return;
- }
-
- while (indentLevels-- > 0) {
- System.out.print("\t");
- }
-
- if ((text != null) && (text.length() > 0)) {
- System.out.print(text);
- System.out.print(" ");
- }
-
- System.out.println(value);
- }
-
- private static void printVerbose(String sourceName, ImageInfo ii) {
- printLine(0, null, sourceName);
- printLine(1, "File format: ", ii.getFormatName());
- printLine(1, "MIME type: ", ii.getMimeType());
- printLine(1, "Width (pixels): ", ii.getWidth(), 1);
- printLine(1, "Height (pixels): ", ii.getHeight(), 1);
- printLine(1, "Bits per pixel: ", ii.getBitsPerPixel(), 1);
- printLine(1, "Progressive: ", Boolean.toString(ii.isProgressive()));
- printLine(1, "Number of images: ", ii.getNumberOfImages(), 1);
- printLine(1, "Physical width (dpi): ", ii.getPhysicalWidthDpi(), 1);
- printLine(1, "Physical height (dpi): ", ii.getPhysicalHeightDpi(), 1);
- printLine(1, "Physical width (inches): ", ii.getPhysicalWidthInch(), 1.0f);
- printLine(1, "Physical height (inches): ", ii.getPhysicalHeightInch(), 1.0f);
-
- int numComments = ii.getNumberOfComments();
-
- printLine(1, "Number of textual comments: ", numComments, 1);
-
- if (numComments > 0) {
- for (int i = 0; i < numComments; i++) {
- printLine(2, null, ii.getComment(i));
- }
- }
- }
-
- private int read() throws IOException {
- if (in != null) {
- return in.read();
- } else {
- return din.readByte();
- }
- }
-
- private int read(byte[] a) throws IOException {
- if (in != null) {
- return in.read(a);
- } else {
- din.readFully(a);
-
- return a.length;
- }
- }
-
- private int read(byte[] a, int offset, int num) throws IOException {
- if (in != null) {
- return in.read(a, offset, num);
- } else {
- din.readFully(a, offset, num);
-
- return num;
- }
- }
-
- private String readLine() throws IOException {
- return readLine(new StringBuffer());
- }
-
- private String readLine(StringBuffer sb) throws IOException {
- boolean finished;
-
- do {
- int value = read();
-
- finished = (value == -1) || (value == 10);
-
- if (!finished) {
- sb.append((char) value);
- }
- } while (!finished);
-
- return sb.toString();
- }
-
- private long readUBits(int numBits) throws IOException {
- if (numBits == 0) {
- return 0;
- }
-
- int bitsLeft = numBits;
- long result = 0;
-
- if (bitPos == 0) { // no value in the buffer - read a byte
- if (in != null) {
- bitBuf = in.read();
- } else {
- bitBuf = din.readByte();
- }
-
- bitPos = 8;
- }
-
- while (true) {
- int shift = bitsLeft - bitPos;
-
- if (shift > 0) {
-
- // Consume the entire buffer
- result |= bitBuf << shift;
- bitsLeft -= bitPos;
-
- // Get the next byte from the input stream
- if (in != null) {
- bitBuf = in.read();
- } else {
- bitBuf = din.readByte();
- }
-
- bitPos = 8;
- } else {
-
- // Consume a portion of the buffer
- result |= bitBuf >> -shift;
- bitPos -= bitsLeft;
- bitBuf &= 0xff >> (8 - bitPos); // mask off the consumed bits
-
- return result;
- }
- }
- }
-
- /**
- * Read a signed value from the given number of bits
- */
- private int readSBits(int numBits) throws IOException {
-
- // Get the number as an unsigned value.
- long uBits = readUBits(numBits);
-
- // Is the number negative?
- if ((uBits & (1L << (numBits - 1))) != 0) {
-
- // Yes. Extend the sign.
- uBits |= -1L << numBits;
- }
-
- return (int) uBits;
- }
-
- private void synchBits() {
- bitBuf = 0;
- bitPos = 0;
- }
-
- private String readLine(int firstChar) throws IOException {
- StringBuffer result = new StringBuffer();
-
- result.append((char) firstChar);
-
- return readLine(result);
- }
-
- private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
- imageInfo.setInput(in);
- imageInfo.setDetermineImageNumber(false);
- imageInfo.setCollectComments(verbose);
-
- if (imageInfo.check()) {
- print(sourceName, imageInfo, verbose);
- }
- }
-
- /**
- * Specify whether textual comments are supposed to be extracted from input.
- * Default is <code>false</code>.
- * If enabled, comments will be added to an internal list.
- *
- * @param newValue if <code>true</code>, this class will read comments
- * @see #getNumberOfComments
- * @see #getComment
- */
- public void setCollectComments(boolean newValue) {
- collectComments = newValue;
- }
-
- /**
- * Specify whether the number of images in a file is to be
- * determined - default is <code>false</code>.
- * This is a special option because some file formats require running over
- * the entire file to find out the number of images, a rather time-consuming
- * task.
- * Not all file formats support more than one image.
- * If this method is called with <code>true</code> as argument,
- * the actual number of images can be queried via
- * {@link #getNumberOfImages()} after a successful call to
- * {@link #check()}.
- *
- * @param newValue will the number of images be determined?
- * @see #getNumberOfImages
- */
- public void setDetermineImageNumber(boolean newValue) {
- determineNumberOfImages = newValue;
- }
-
- /**
- * Set the input stream to the argument stream (or file).
- * Note that {@link java.io.RandomAccessFile} implements
- * {@link java.io.DataInput}.
- *
- * @param dataInput the input stream to read from
- */
- public void setInput(DataInput dataInput) {
- din = dataInput;
- in = null;
- }
-
- /**
- * Set the input stream to the argument stream (or file).
- *
- * @param inputStream the input stream to read from
- */
- public void setInput(InputStream inputStream) {
- in = inputStream;
- din = null;
- }
-
- private void setPhysicalHeightDpi(int newValue) {
- physicalWidthDpi = newValue;
- }
-
- private void setPhysicalWidthDpi(int newValue) {
- physicalHeightDpi = newValue;
- }
-
- private void skip(int num) throws IOException {
- while (num > 0) {
- long result;
-
- if (in != null) {
- result = in.skip(num);
- } else {
- result = din.skipBytes(num);
- }
-
- if (result > 0) {
- num -= result;
- }
- }
- }
-}
Deleted: branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/resource/image/package-info.java
===================================================================
--- branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/resource/image/package-info.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/impl/src/main/java/org/ajax4jsf/resource/image/package-info.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,4 +0,0 @@
-/**
- * Image resources support classes
- */
-package org.ajax4jsf.resource.image;
Modified: branches/RF-9323/core/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- branches/RF-9323/core/impl/src/main/resources/META-INF/faces-config.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/impl/src/main/resources/META-INF/faces-config.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -2,11 +2,6 @@
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0">
- <factory>
- <!--
- <lifecycle-factory>org.ajax4jsf.application.DebugLifecycleFactory</lifecycle-factory>
- -->
- </factory>
<application>
<!-- system-event-listener>
<system-event-listener-class>org.ajax4jsf.component.RenderPhaseUIDataAdaptorVisitor</system-event-listener-class>
@@ -23,9 +18,6 @@
<system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
</system-event-listener>
</application>
- <!-- lifecycle>
- <phase-listener>org.ajax4jsf.event.AjaxPhaseListener</phase-listener>
- </lifecycle -->
<managed-bean>
<managed-bean-name>a4j</managed-bean-name>
<managed-bean-class>org.richfaces.VersionBean</managed-bean-class>
Modified: branches/RF-9323/core/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
===================================================================
--- branches/RF-9323/core/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-12-23 17:32:10 UTC (rev 20787)
@@ -297,4 +297,36 @@
};
})(params));
+})(jQuery, window.RichFaces || (window.RichFaces={}));
+
+// RichFaces Base class for ui components
+(function($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ // Constructor definition
+ rf.ui.Base = function(componentId, options, defaultOptions) {
+ this.namespace = "."+rf.Event.createNamespace(this.name, componentId);
+ // call constructor of parent class
+ $super.constructor.call(this, componentId);
+ this.options = $.extend(this.options, defaultOptions, options);
+ this.attachToDom();
+ this.__bindEventHandlers();
+ };
+
+ // Extend component class and add protected methods from parent class to our container
+ rf.BaseComponent.extend(rf.ui.Base);
+
+ // define super class link
+ var $super = rf.ui.Base.$super;
+
+ $.extend(rf.ui.Base.prototype, {
+ __bindEventHandlers: function () {
+ },
+ destroy: function () {
+ rf.Event.unbind(this.id, this.namespace);
+ $super.destroy.call(this);
+ }
+ });
+
})(jQuery, window.RichFaces || (window.RichFaces={}));
\ No newline at end of file
Modified: branches/RF-9323/core/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
--- branches/RF-9323/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-12-23 17:32:10 UTC (rev 20787)
@@ -78,13 +78,13 @@
if (e) {
var elements = e.getElementsByTagName("*");
if (elements.length) {
- jQuery.cleanData(elements);
- jQuery.cleanData([e]);
jQuery.each(elements, function(index) {
richfaces.cleanComponent(this);
});
- richfaces.cleanComponent(e);
+ jQuery.cleanData(elements);
}
+ richfaces.cleanComponent(e);
+ jQuery.cleanData([e]);
}
};
Copied: branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/io/FastBufferOutputStreamTest.java (from rev 20785, trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferOutputStreamTest.java)
===================================================================
--- branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/io/FastBufferOutputStreamTest.java (rev 0)
+++ branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/io/FastBufferOutputStreamTest.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -0,0 +1,84 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.ajax4jsf.io;
+
+import junit.framework.TestCase;
+
+import org.ajax4jsf.io.ByteBuffer;
+import org.ajax4jsf.io.FastBufferOutputStream;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class FastBufferOutputStreamTest extends TestCase {
+
+ /**
+ * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
+ */
+ public void testResetOneBuffer() throws Exception {
+ FastBufferOutputStream stream = new FastBufferOutputStream(256);
+
+ for (int i = 0; i < 255; i++) {
+ stream.write(i);
+ }
+
+ assertEquals(255, stream.getLength());
+
+ ByteBuffer firstBuffer = stream.getFirstBuffer();
+
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ stream.reset();
+ assertEquals(0, stream.getLength());
+ firstBuffer = stream.getFirstBuffer();
+ assertEquals(0, firstBuffer.getUsedSize());
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
+ */
+ public void testResetTwoBuffers() throws Exception {
+ FastBufferOutputStream stream = new FastBufferOutputStream(256);
+
+ for (int i = 0; i < 257; i++) {
+ stream.write(i);
+ }
+
+ assertEquals(257, stream.getLength());
+
+ ByteBuffer firstBuffer = stream.getFirstBuffer();
+
+ assertNotNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ stream.reset();
+ assertEquals(0, stream.getLength());
+ firstBuffer = stream.getFirstBuffer();
+ assertEquals(0, firstBuffer.getUsedSize());
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ }
+}
Copied: branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/io/FastBufferWriterTest.java (from rev 20785, trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferWriterTest.java)
===================================================================
--- branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/io/FastBufferWriterTest.java (rev 0)
+++ branches/RF-9323/core/impl/src/test/java/org/ajax4jsf/io/FastBufferWriterTest.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -0,0 +1,118 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.ajax4jsf.io;
+
+import junit.framework.TestCase;
+
+import org.ajax4jsf.io.CharBuffer;
+import org.ajax4jsf.io.FastBufferReader;
+import org.ajax4jsf.io.FastBufferWriter;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class FastBufferWriterTest extends TestCase {
+
+ /**
+ * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
+ */
+ public void testResetOneBuffer() throws Exception {
+ FastBufferWriter stream = new FastBufferWriter(256);
+
+ for (int i = 0; i < 255; i++) {
+ stream.write(i);
+ }
+
+ assertEquals(255, stream.getLength());
+
+ CharBuffer firstBuffer = stream.getFirstBuffer();
+
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ stream.reset();
+ assertEquals(0, stream.getLength());
+ firstBuffer = stream.getFirstBuffer();
+ assertEquals(0, firstBuffer.getUsedSize());
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
+ */
+ public void testResetTwoBuffers() throws Exception {
+ FastBufferWriter stream = new FastBufferWriter(256);
+
+ for (int i = 0; i < 257; i++) {
+ stream.write(i);
+ }
+
+ assertEquals(257, stream.getLength());
+
+ CharBuffer firstBuffer = stream.getFirstBuffer();
+
+ assertNotNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ stream.reset();
+ assertEquals(0, stream.getLength());
+ firstBuffer = stream.getFirstBuffer();
+ assertEquals(0, firstBuffer.getUsedSize());
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ }
+
+ public void testCompact() throws Exception {
+ int itemsTowWrite = 16384 + 16000;
+ FastBufferWriter writer = new FastBufferWriter(16384);
+
+ for (int i = 0; i < itemsTowWrite; i++) {
+ writer.write(i);
+ }
+
+ writer.close();
+
+ CharBuffer firstBuffer = writer.getFirstBuffer();
+
+ assertNotNull(firstBuffer);
+
+ CharBuffer nextBuffer = firstBuffer.getNext();
+
+ assertNotNull(nextBuffer);
+ assertNull(nextBuffer.getNext());
+ assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
+ assertTrue(nextBuffer.getUsedSize() < nextBuffer.getCacheSize());
+ firstBuffer.compact();
+ assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
+ assertTrue(nextBuffer.getUsedSize() == nextBuffer.getCacheSize());
+
+ FastBufferReader reader = new FastBufferReader(firstBuffer);
+
+ for (int i = 0; i < itemsTowWrite; i++) {
+ assertEquals(i, reader.read());
+ }
+
+ reader.close();
+ }
+}
Modified: branches/RF-9323/examples/core-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/examples/core-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/core-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/examples/input-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/examples/input-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/input-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- branches/RF-9323/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -32,6 +32,11 @@
-->
<h:head>
<title>Richfaces Calendar Demo</title>
+ <script>
+ var myFunction = function(event){
+ ;
+ }
+ </script>
</h:head>
<h:body>
<h:form id="form">
@@ -44,8 +49,8 @@
dataModel="#{calendarDataModel}"
mode="#{calendarBean.mode}"
disabled="false"
- showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
- cellHeight="22px" style="width:200px" minDaysInFirstWeek="3"
+ cellWidth="24px"
+ cellHeight="22px" minDaysInFirstWeek="3"
oncollapse="return onEvent.call(this, event);"
onexpand="return onEvent.call(this, event);"
oncurrentdateselect="return onEvent.call(this, event);"
@@ -60,9 +65,13 @@
ondatemouseover="return onEvent.call(this, event);"
firstWeekDay="4"
horizontalOffset="#{calendarBean.horizontalOffset}"
- verticalOffset="#{calendarBean.verticalOffset}"
+ verticalOffset="#{calendarBean.verticalOffset}" defaultTime="11:22:01"
valueChangeListener="#{calendarBean.doValueChangeListener}"
- currentDataChangeListener="#{calendarBean.doCurrentDataChangeListener}"
+ currentDataChangeListener="#{calendarBean.doCurrentDataChangeListener}"
+ onbeforedateselect="myFunction(event)"
+ style="width:200px;border:10px solid #000000"
+ styleClass="hello"
+ boundaryDatesMode = "scroll"
>
</calendar:calendar>
@@ -93,6 +102,8 @@
<f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy HH:mm" />
<f:selectItem itemLabel="dd/M/yy hh:mm a"
itemValue="dd/M/yy hh:mm a" />
+ <f:selectItem itemLabel="dd/M/yy hh:mm:ss"
+ itemValue="dd/M/yy hh:mm:ss" />
<f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
<f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy" />
</h:selectOneMenu>
Modified: branches/RF-9323/examples/iteration-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/examples/iteration-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/iteration-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/examples/misc-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/examples/misc-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/misc-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/examples/output-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/examples/output-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/output-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/examples/parent/pom.xml
===================================================================
--- branches/RF-9323/examples/parent/pom.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/parent/pom.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -206,6 +206,27 @@
</dependencies>
</profile>
<profile>
+ <id>jsf_ri_2_1</id>
+ <activation>
+ <property>
+ <name>jsf_profile</name>
+ <value>jsf_ri_2_1</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.1.0-b09</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>2.1.0-b09</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
<id>myfaces_snapshot</id>
<activation>
<property>
@@ -217,12 +238,12 @@
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
- <version>2.0.3-SNAPSHOT</version>
+ <version>2.0.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
- <version>2.0.3-SNAPSHOT</version>
+ <version>2.0.4-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
Modified: branches/RF-9323/examples/push-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/examples/push-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/push-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/examples/repeater-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/examples/repeater-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/repeater-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/examples/richfaces-showcase/pom.xml
===================================================================
--- branches/RF-9323/examples/richfaces-showcase/pom.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/richfaces-showcase/pom.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -36,10 +36,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- </dependency>
- <dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
Modified: branches/RF-9323/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java
===================================================================
--- branches/RF-9323/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -36,13 +36,13 @@
if (current.before(today)) {
modelItem.setEnabled(false);
modelItem.setStyleClass(BOUNDARY_DAY_CLASS);
- } else if (checkBusyDay(current)){
+ } else if (checkBusyDay(current)) {
modelItem.setEnabled(false);
modelItem.setStyleClass(BUSY_DAY_CLASS);
- }else if (checkWeekend(current)){
+ } else if (checkWeekend(current)) {
modelItem.setEnabled(false);
modelItem.setStyleClass(WEEKEND_DAY_CLASS);
- }else{
+ } else {
modelItem.setEnabled(true);
modelItem.setStyleClass("");
}
@@ -51,4 +51,10 @@
return modelItems;
}
+
+ @Override
+ public Object getToolTip(Date date) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified: branches/RF-9323/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java
===================================================================
--- branches/RF-9323/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -2,11 +2,10 @@
import org.richfaces.model.CalendarDataModelItem;
-public class CalendarModelItem implements CalendarDataModelItem{
+public class CalendarModelItem implements CalendarDataModelItem {
private boolean enabled;
private String styleClass;
-
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@@ -22,4 +21,28 @@
public String getStyleClass() {
return styleClass;
}
+
+ @Override
+ public Object getData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean hasToolTip() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Object getToolTip() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getDay() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
Modified: branches/RF-9323/examples/richfaces-showcase/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/examples/richfaces-showcase/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/richfaces-showcase/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/examples/richfaces-showcase/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/RF-9323/examples/richfaces-showcase/src/main/webapp/WEB-INF/web.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/richfaces-showcase/src/main/webapp/WEB-INF/web.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -40,10 +40,6 @@
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
- <mime-mapping>
- <extension>ecss</extension>
- <mime-type>text/css</mime-type>
- </mime-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
Modified: branches/RF-9323/examples/validator-demo/src/main/webapp/WEB-INF/jboss-scanning.xml
===================================================================
--- branches/RF-9323/examples/validator-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/examples/validator-demo/src/main/webapp/WEB-INF/jboss-scanning.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -5,7 +5,7 @@
-->
<path name="WEB-INF/classes"></path>
- <path name="WEB-INF/lib/guava-r05.jar">
+ <path name="WEB-INF/lib/guava-r07.jar">
<exclude name="com.google.common.collect" />
</path>
</scanning>
\ No newline at end of file
Modified: branches/RF-9323/parent/pom.xml
===================================================================
--- branches/RF-9323/parent/pom.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/parent/pom.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -345,7 +345,7 @@
</dependencies>
</profile>
<profile>
- <id>jsf_ri_snapshot</id>
+ <id>jsf_ri_2_1_snapshot</id>
<activation>
<property>
<name>jsf_profile</name>
@@ -368,6 +368,29 @@
</dependencies>
</profile>
<profile>
+ <id>jsf_ri_2_1</id>
+ <activation>
+ <property>
+ <name>jsf_profile</name>
+ <value>jsf_ri_2_1</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.1.0-b09</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>2.1.0-b09</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
<id>myfaces_snapshot</id>
<activation>
<property>
@@ -379,13 +402,13 @@
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
- <version>2.0.3-SNAPSHOT</version>
+ <version>2.0.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
- <version>2.0.3-SNAPSHOT</version>
+ <version>2.0.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
Deleted: branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/MethodBindingMethodExpressionAdaptor.java
===================================================================
--- branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/MethodBindingMethodExpressionAdaptor.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/MethodBindingMethodExpressionAdaptor.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,100 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.el.ELException;
-import javax.el.MethodExpression;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.MethodNotFoundException;
-
-/**
- * Maps {@link MethodExpression} to {@link MethodBinding}
- *
- * @author Maksim Kaszynski
- */
-@SuppressWarnings("deprecation")
-public class MethodBindingMethodExpressionAdaptor extends MethodBinding implements StateHolder {
- private MethodExpression expression;
- private boolean tranzient;
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.MethodBinding#getType(javax.faces.context.FacesContext)
- */
- public MethodBindingMethodExpressionAdaptor() {
-
- // TODO Auto-generated constructor stub
- }
-
- public MethodBindingMethodExpressionAdaptor(MethodExpression expression) {
- super();
- this.expression = expression;
- }
-
- @Override
- public Class<?> getType(FacesContext context) throws MethodNotFoundException {
- try {
- return expression.getMethodInfo(context.getELContext()).getReturnType();
- } catch (javax.el.MethodNotFoundException e) {
- throw new MethodNotFoundException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.MethodBinding#invoke(javax.faces.context.FacesContext, java.lang.Object[])
- */
- @Override
- public Object invoke(FacesContext context, Object[] params) throws EvaluationException, MethodNotFoundException {
- try {
- return expression.invoke(context.getELContext(), params);
- } catch (javax.el.MethodNotFoundException e) {
- throw new MethodNotFoundException(e);
- } catch (ELException e) {
- throw new EvaluationException(e);
- }
- }
-
- public boolean isTransient() {
- return tranzient;
- }
-
- public void restoreState(FacesContext context, Object state) {
- expression = (MethodExpression) state;
- }
-
- public Object saveState(FacesContext context) {
- return expression;
- }
-
- public void setTransient(boolean newTransientValue) {
- tranzient = newTransientValue;
- }
-
- @Override
- public String getExpressionString() {
- return expression.getExpressionString();
- }
-}
Deleted: branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/MethodExpressionMethodBindingAdaptor.java
===================================================================
--- branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/MethodExpressionMethodBindingAdaptor.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/MethodExpressionMethodBindingAdaptor.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,202 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.MethodExpression;
-import javax.el.MethodInfo;
-import javax.faces.FacesException;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.MethodNotFoundException;
-import java.io.Serializable;
-
-/**
- * @author Maksim Kaszynski
- */
-@SuppressWarnings("deprecation")
-public class MethodExpressionMethodBindingAdaptor extends MethodExpression implements StateHolder, Serializable {
- private static final long serialVersionUID = 1L;
- private MethodBinding binding;
- private boolean tranzient;
-
- public MethodExpressionMethodBindingAdaptor() {
- }
-
- public MethodExpressionMethodBindingAdaptor(MethodBinding binding) {
- this.binding = binding;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.el.MethodExpression#getMethodInfo(javax.el.ELContext)
- */
- @Override
- public MethodInfo getMethodInfo(ELContext context) {
- FacesContext context2 = (FacesContext) context.getContext(FacesContext.class);
-
- try {
- return new MethodInfo(null, binding.getType(context2), null);
- } catch (MethodNotFoundException e) {
- throw new javax.el.MethodNotFoundException(e);
- } catch (EvaluationException e) {
- throw new ELException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.el.MethodExpression#invoke(javax.el.ELContext, java.lang.Object[])
- */
- @Override
- public Object invoke(ELContext context, Object[] params) {
- FacesContext context2 = (FacesContext) context.getContext(FacesContext.class);
-
- try {
- return binding.invoke(context2, params);
- } catch (MethodNotFoundException e) {
- throw new javax.el.MethodNotFoundException(e);
- } catch (EvaluationException e) {
- throw new ELException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.el.Expression#getExpressionString()
- */
- @Override
- public String getExpressionString() {
- return binding.getExpressionString();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
-
- result = prime * result + ((binding == null) ? 0 : binding.hashCode());
-
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- MethodExpressionMethodBindingAdaptor other = (MethodExpressionMethodBindingAdaptor) obj;
-
- if (binding == null) {
- if (other.binding != null) {
- return false;
- }
- } else if (!binding.equals(other.binding)) {
- return false;
- }
-
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.el.Expression#isLiteralText()
- */
- @Override
- public boolean isLiteralText() {
- String expr = binding.getExpressionString();
-
- return !(expr.startsWith("#{") && expr.endsWith("}"));
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.StateHolder#isTransient()
- */
- public boolean isTransient() {
- return tranzient;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- if (state instanceof MethodBinding) {
- binding = (MethodBinding) state;
- } else {
- Object[] states = (Object[]) state;
- String className = states[0].toString();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- if (loader == null) {
- loader = this.getClass().getClassLoader();
- }
-
- try {
- Class<?> bindingClass = Class.forName(className, true, loader);
-
- binding = (MethodBinding) bindingClass.newInstance();
- ((StateHolder) binding).restoreState(context, states[1]);
- } catch (Exception e) {
- throw new FacesException(e);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- if (binding instanceof StateHolder) {
- Object[] state = new Object[2];
-
- state[0] = binding.getClass().getName();
- state[1] = ((StateHolder) binding).saveState(context);
-
- return state;
- } else {
- return binding;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.StateHolder#setTransient(boolean)
- */
- public void setTransient(boolean newTransientValue) {
- tranzient = newTransientValue;
- }
-
- public MethodBinding getBinding() {
- return binding;
- }
-}
Modified: branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
--- branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -69,7 +69,6 @@
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SerializableDataModel;
import org.richfaces.context.ExtendedVisitContext;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -104,7 +103,7 @@
private boolean componentStateIsStateHolder;
- private ExtendedDataModel<?> dataModel;
+ private transient ExtendedDataModel<?> dataModel;
public IterationState() {
super();
@@ -154,18 +153,10 @@
}
}
- Object savedSerializableModel = null;
-
- if (componentState != null && dataModel != null) {
- // TODO handle model serialization - "execute" model
- savedSerializableModel = dataModel.getSerializableModel(componentState.getRange());
- }
-
- if (localSavedComponentState != null || savedSerializableModel != null) {
+ if (localSavedComponentState != null) {
return new Object[] {
localComponentStateIsHolder,
- localSavedComponentState,
- savedSerializableModel
+ localSavedComponentState
};
} else {
return null;
@@ -183,8 +174,6 @@
} else {
componentState = (DataComponentState) localSavedComponentState;
}
-
- dataModel = (ExtendedDataModel<?>) state[2];
}
}
@@ -961,16 +950,6 @@
preUpdate(faces);
this.iterate(faces, updateVisitor);
- ExtendedDataModel<?> dataModel = getExtendedDataModel();
-
- // If no validation errors, update values for serializable model,
- // restored from view.
- if ((dataModel instanceof SerializableDataModel) && (!isKeepSaved())) {
- SerializableDataModel serializableModel = (SerializableDataModel) dataModel;
-
- serializableModel.update();
- }
-
doUpdate();
popComponentFromEL(faces);
Modified: branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java
===================================================================
--- branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -23,21 +23,17 @@
package org.richfaces.component;
-import java.io.OutputStream;
import java.util.Date;
-import javax.el.MethodExpression;
import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
import javax.faces.component.UIOutput;
-import javax.faces.el.MethodBinding;
-import org.ajax4jsf.resource.ResourceComponent2;
+import org.ajax4jsf.resource.ResourceComponent;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
import org.richfaces.resource.MediaOutputResource;
@@ -50,7 +46,7 @@
tag = @Tag(generate = false, handler = "org.richfaces.view.facelets.html.MediaOutputHandler", type = TagType.Facelets),
renderer = @JsfRenderer(type = "org.richfaces.MediaOutputRenderer")
)
-public abstract class AbstractMediaOutput extends UIOutput implements ResourceComponent2 {
+public abstract class AbstractMediaOutput extends UIOutput implements ResourceComponent {
public static final String COMPONENT_TYPE = "org.richfaces.MediaOutput";
@@ -70,53 +66,6 @@
@Attribute
public abstract String getElement();
- /**
- * Get EL binding to method in user bean to send resource. Method will
- * called with two parameters - restored data object and servlet output
- * stream.
- *
- * @return MethodBinding to createContent
- */
- @Attribute(signature = @Signature(parameters = {OutputStream.class, Object.class}))
- public MethodBinding getCreateContent() {
- MethodBinding result = null;
- MethodExpression me = getCreateContentExpression();
-
- if (me != null) {
-
- // if the MethodExpression is an instance of our private
- // wrapper class.
- if (me instanceof MethodExpressionMethodBindingAdaptor) {
- result = ((MethodExpressionMethodBindingAdaptor) me).getBinding();
- } else {
-
- // otherwise, this is a real MethodExpression. Wrap it
- // in a MethodBinding.
- result = new MethodBindingMethodExpressionAdaptor(me);
- }
- }
-
- return result;
- }
-
- /**
- * Set EL binding to method in user bean to send resource. Method will
- * called with two parameters - restored data object and servlet output
- * stream.
- *
- * @param newvalue - new value of createContent method binding
- */
- public void setCreateContent(MethodBinding newvalue) {
- MethodExpressionMethodBindingAdaptor adapter;
-
- if (newvalue != null) {
- adapter = new MethodExpressionMethodBindingAdaptor(newvalue);
- setCreateContentExpression(adapter);
- } else {
- setCreateContentExpression(null);
- }
- }
-
public Resource getResource() {
ResourceHandler resourceHandler = getFacesContext().getApplication().getResourceHandler();
return resourceHandler.createResource(MediaOutputResource.class.getName());
@@ -152,8 +101,6 @@
@Attribute
public abstract String getCoords();
- public abstract MethodExpression getCreateContentExpression();
-
@Attribute
public abstract String getDeclare();
Modified: branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java
===================================================================
--- branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -105,7 +105,7 @@
this.setCacheable(uiMediaOutput.isCacheable());
this.setContentType(uiMediaOutput.getMimeType());
this.userData = uiMediaOutput.getValue();
- this.contentProducer = uiMediaOutput.getCreateContentExpression();
+ this.contentProducer = uiMediaOutput.getCreateContent();
this.lastModifiedExpression = uiMediaOutput.getValueExpression("lastModfied");
this.expiresExpression = uiMediaOutput.getValueExpression("expires");
this.timeToLiveExpression = uiMediaOutput.getValueExpression("timeToLive");
Modified: branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/MediaOutputHandler.java
===================================================================
--- branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/MediaOutputHandler.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/MediaOutputHandler.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -22,8 +22,7 @@
package org.richfaces.view.facelets.html;
-import org.richfaces.component.AbstractMediaOutput;
-import org.richfaces.view.facelets.MethodMetadata;
+import java.io.OutputStream;
import javax.faces.view.facelets.ComponentConfig;
import javax.faces.view.facelets.ComponentHandler;
@@ -33,8 +32,10 @@
import javax.faces.view.facelets.Metadata;
import javax.faces.view.facelets.MetadataTarget;
import javax.faces.view.facelets.TagAttribute;
-import java.io.OutputStream;
+import org.richfaces.component.AbstractMediaOutput;
+import org.richfaces.view.facelets.MethodMetadata;
+
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
@@ -62,7 +63,7 @@
if ("createContent".equals(name)) {
return new MethodMetadata(attribute, OutputStream.class, Object.class) {
public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractMediaOutput) instance).setCreateContentExpression(getMethodExpression(ctx));
+ ((AbstractMediaOutput) instance).setCreateContent(getMethodExpression(ctx));
}
};
}
Modified: branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java
===================================================================
--- branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -32,5 +32,14 @@
@Attribute(defaultValue="true")
public abstract boolean isShowButton();
+
+ @Attribute(defaultValue="20px")
+ public abstract String getMinListHeight();
+
+ @Attribute(defaultValue="100px")
+ public abstract String getMaxListHeight();
+ @Attribute(defaultValue="auto")
+ public abstract String getListHeight();
+
}
Modified: branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java
===================================================================
--- branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -34,7 +34,7 @@
public abstract class AbstractSelectComponent extends UISelectOne {
- @Attribute(defaultValue="250px")
+ @Attribute(defaultValue="200px")
public abstract String getListWidth();
@Attribute(defaultValue="100px")
Modified: branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
===================================================================
--- branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -30,6 +30,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.richfaces.component.AbstractSelect;
import org.richfaces.component.AbstractSelectComponent;
/**
@@ -62,6 +63,40 @@
return SelectHelper.getSelectInputLabel(facesContext, component);
}
+ public String getListWidth(UIComponent component) {
+ AbstractSelect select = (AbstractSelect)component;
+ String width = select.getListWidth();
+ return (width != null && width.trim().length() != 0) ? ("width: " + width) : "";
+ }
+
+ public String encodeHeightAndWidth(UIComponent component) {
+ AbstractSelect select = (AbstractSelect)component;
+
+ String height = select.getListHeight();
+ if(!"auto".equals(height)) {
+ height = (height != null && height.trim().length() != 0) ? ("height: " + height) : "";
+ } else {
+ String minHeight = select.getMinListHeight();
+ minHeight = (minHeight != null && minHeight.trim().length() != 0) ? ("min-height: " + minHeight) : "";
+
+ String maxHeight = select.getMaxListHeight();
+ maxHeight = (maxHeight != null && maxHeight.trim().length() != 0) ? ("max-height: " + maxHeight) : "";
+ height = concatStyles(minHeight, maxHeight);
+ }
+
+ String width = select.getListWidth();
+ width = (width != null && width.trim().length() != 0) ? ("width: " + width) : "";
+
+ return concatStyles(height, width);
+ }
+
+ public String getListCss(UIComponent component) {
+ AbstractSelect inplaceSelect = (AbstractSelect)component;
+ String css = inplaceSelect.getListClass();
+ css = (css != null) ? concatClasses("rf-sel-lst-cord", css) : "rf-sel-lst-cord";
+ return css;
+ }
+
public String getSelectLabel(FacesContext facesContext, UIComponent component) {
AbstractSelectComponent select = (AbstractSelectComponent) component;
String label = getSelectInputLabel(facesContext, select);
Modified: branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java
===================================================================
--- branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -53,25 +53,22 @@
if (date == null) {
return null;
}
-
Date value = null;
-
+ Converter converter = calendar.getConverter();
+ if (converter == null) {
+ Application application = facesContext.getApplication();
+ converter = application.createConverter(date.getClass());
+ }
if (date instanceof Date) {
value = (Date) date;
- } else if (date instanceof String) {
- value = convertStringToDate(facesContext, calendar, (String) date);
} else if (date instanceof Calendar) {
value = ((Calendar) date).getTime();
- } else {
- Converter converter = calendar.getConverter();
- if (converter == null) {
- Application application = facesContext.getApplication();
- converter = application.createConverter(date.getClass());
- if (converter == null) {
- throw new FacesException("Wrong attibute type or there is no converter for custom attibute type");
- }
- }
+ } else if (converter != null){
value = convertStringToDate(facesContext, calendar, converter.getAsString(facesContext, calendar, date));
+ } else if (date instanceof String) {
+ value = convertStringToDate(facesContext, calendar, (String) date);
+ } else {
+ throw new FacesException("Wrong attibute type or there is no converter for custom attibute type");
}
return value;
Modified: branches/RF-9323/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
===================================================================
--- branches/RF-9323/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-12-23 17:32:10 UTC (rev 20787)
@@ -308,6 +308,7 @@
// "inactive" or undefined - no action (default)
// "scroll" - change current month
// "select" - change current month and select date
+ // "hidden" - does not render content for boundary dates
//
// todayControlMode - today control onclick action:
// "scroll"
@@ -349,6 +350,7 @@
//
this.options.boundaryDatesMode = this.options.boundaryDatesMode.toLowerCase();
+ this.hideBoundaryDatesContent = this.options.boundaryDatesMode == "hidden";
this.options.todayControlMode = this.options.todayControlMode.toLowerCase();
// time
@@ -1319,7 +1321,7 @@
}
contentElement = (this.customDayListMarkup ? element.firstChild : element);
- contentElement.innerHTML = this.evaluateMarkup(this.options.dayListMarkup, dataobj );
+ contentElement.innerHTML = this.hideBoundaryDatesContent && dataobj._month!=0 ? "" : this.evaluateMarkup(this.options.dayListMarkup, dataobj );
if (weekdaycounter==6) weekdaycounter=0; else weekdaycounter++;
Modified: branches/RF-9323/ui/input/ui/src/main/templates/calendar.template.xml
===================================================================
--- branches/RF-9323/ui/input/ui/src/main/templates/calendar.template.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/main/templates/calendar.template.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -86,7 +86,7 @@
new RichFaces.ui.Calendar("#{clientId}", "#{getAsLocale(facesContext, component).toString()}",
#{toScriptArgs(options)}).load(#{writePreloadBody(facesContext, component)});
- --></script>
+ </script>
</span>
</span>
</cc:implementation>
Modified: branches/RF-9323/ui/input/ui/src/main/templates/select.template.xml
===================================================================
--- branches/RF-9323/ui/input/ui/src/main/templates/select.template.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/main/templates/select.template.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -47,7 +47,7 @@
</c:if>
</div>
- <div id="#{clientId}List" class="rf-sel-lst-cord">
+ <div id="#{clientId}List" class="#{getListCss(component)}">
<cdk:call expression="renderListHandlers(facesContext, component);"/>
<div class="rf-sel-shdw">
<div class="rf-sel-shdw-t"></div>
@@ -56,7 +56,7 @@
<div class="rf-sel-shdw-b"></div>
<div class="rf-sel-lst-dcrtn">
- <div class="rf-sel-lst-scrl">
+ <div class="rf-sel-lst-scrl" style="#{encodeHeightAndWidth(component)}">
<div id="#{clientId}Items" >
<cdk:call expression="encodeItems(facesContext, component, clientSelectItems);"/>
</div>
@@ -67,9 +67,8 @@
<script type="text/javascript">
<cdk:scriptObject name="options">
<cdk:scriptOption name="items" value="#{clientSelectItems}" />
- <cdk:scriptOption name="itemCss" value="#{concatClasses('rf-sel-opt', component.attributes['itemClass'])}" />
+ <cdk:scriptOption name="itemCss" value="rf-sel-opt" />
<cdk:scriptOption name="selectItemCss" value="#{concatClasses('rf-sel-sel', component.attributes['selectItemClass'])}" />
- <cdk:scriptOption name="listCss" value="#{concatClasses('rf-sel-lst-cord', component.attributes['listClass'])}" />
<cdk:scriptOption attributes="onbegin oncomplete onerror onbeforedomupdate onchange onblur onselectitem onfocus" wrapper="eventHandler"/>
<cdk:scriptOption attributes="showControl defaultLabel enableManualInput selectFirst" />
</cdk:scriptObject>
Modified: branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestDefault.xmlunit.xml
===================================================================
--- branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestDefault.xmlunit.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestDefault.xmlunit.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,45 +1,31 @@
<span class="rf-is-d-s" id="form:inplaceSelectDefault">
- <span class="rf-is-lbl" id="form:inplaceSelectDefaultLabel">
- Edit Text
- </span>
- <input class="rf-is-none" id="form:inplaceSelectDefaultFocus" name="form:inplaceSelectDefaultFocus" style="position: absolute; top: 0px; left: 0px; outline-style: none;" type="image"/>
- <span class="rf-is-edit rf-is-none" id="form:inplaceSelectDefaultEdit">
- <input id="form:inplaceSelectDefaultselValue" name="form:inplaceSelectDefault" type="hidden"/>
- <input autocomplete="off" class="rf-is-fld" id="form:inplaceSelectDefaultInput" name="form:inplaceSelectDefaultInput" readonly="readonly" style="width: ;" type="text"/>
- <span class="rf-is-lst-cord" id="form:inplaceSelectDefaultList" style="display: none">
- <span class="rf-is-lst-pos" style="width: 250px">
- <span class="rf-is-shdw">
- <span class="rf-is-shdw-t">
- </span>
- <span class="rf-is-shdw-l">
- </span>
- <span class="rf-is-shdw-r">
- </span>
- <span class="rf-is-shdw-b">
- </span>
- <span class="rf-is-lst-dec">
- <span class="rf-is-lst-scrl" style="height: 100px">
- <span id="form:inplaceSelectDefaultItems">
- <span id="form:inplaceSelectDefaultItem0" class="rf-is-opt">
- Label#1
- </span>
- <span id="form:inplaceSelectDefaultItem1" class="rf-is-opt">
- Label#2
- </span>
- <span id="form:inplaceSelectDefaultItem2" class="rf-is-opt">
- Label#3
- </span>
- <span id="form:inplaceSelectDefaultItem3" class="rf-is-opt">
- Label#4
- </span>
- </span>
- </span>
- </span>
- </span>
- </span>
- </span>
- </span>
- <script type="text/javascript">
- //ignored
- </script>
+ <span class="rf-is-lbl" id="form:inplaceSelectDefaultLabel">Edit Text</span>
+ <input class="rf-is-none" id="form:inplaceSelectDefaultFocus" name="form:inplaceSelectDefaultFocus" style="position: absolute; top: 0px; left: 0px; outline-style: none;" type="image" />
+ <span class="rf-is-edit rf-is-none" id="form:inplaceSelectDefaultEdit">
+ <input id="form:inplaceSelectDefaultselValue" name="form:inplaceSelectDefault" type="hidden" />
+ <input autocomplete="off" class="rf-is-fld" id="form:inplaceSelectDefaultInput" name="form:inplaceSelectDefaultInput" readonly="readonly" style="width: ;" type="text" />
+ <span class="rf-is-lst-cord" id="form:inplaceSelectDefaultList" style="display: none">
+ <span class="rf-is-lst-pos" style="width: 200px">
+ <span class="rf-is-shdw">
+ <span class="rf-is-shdw-t"></span>
+ <span class="rf-is-shdw-l"></span>
+ <span class="rf-is-shdw-r"></span>
+ <span class="rf-is-shdw-b"></span>
+ <span class="rf-is-lst-dec">
+ <span class="rf-is-lst-scrl" style="height: 100px">
+ <span id="form:inplaceSelectDefaultItems">
+ <span id="form:inplaceSelectDefaultItem0" class="rf-is-opt">Label#1</span>
+ <span id="form:inplaceSelectDefaultItem1" class="rf-is-opt">Label#2</span>
+ <span id="form:inplaceSelectDefaultItem2" class="rf-is-opt">Label#3</span>
+ <span id="form:inplaceSelectDefaultItem3" class="rf-is-opt">Label#4</span>
+ </span>
+ </span>
+ </span>
+ </span>
+ </span>
+ </span>
+ </span>
+ <script type="text/javascript">
+ //ignored
+ </script>
</span>
Modified: branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestEdit.xmlunit.xml
===================================================================
--- branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestEdit.xmlunit.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestEdit.xmlunit.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,64 +1,46 @@
<span class="rf-is-d-s rf-is-e-s" id="form:inplaceSelectEdit">
- <span class="rf-is-lbl" id="form:inplaceSelectEditLabel">
- Edit Text
- </span>
- <input class="rf-is-none" id="form:inplaceSelectEditFocus" name="form:inplaceSelectEditFocus" style="position: absolute; top: 0px; left: 0px; outline-style: none;" type="image"/>
- <span class="rf-is-edit" id="form:inplaceSelectEditEdit">
- <input id="form:inplaceSelectEditselValue" name="form:inplaceSelectEdit" type="hidden"/>
- <input autocomplete="off" class="rf-is-fld" id="form:inplaceSelectEditInput" name="form:inplaceSelectEditInput" readonly="readonly" style="width: ;" type="text"/>
- <span class="rf-is-btn-prepos">
- <span class="rf-is-btn-pos">
- <span class="rf-is-shdw" id="form:inplaceSelectEditBtnshadow">
- <span class="rf-is-shdw-t">
- </span>
- <span class="rf-is-shdw-l">
- </span>
- <span class="rf-is-shdw-r">
- </span>
- <span class="rf-is-shdw-b">
- </span>
- <span id="form:inplaceSelectEditBtn" style="position : relative;">
- <input class="rf-is-btn" id="form:inplaceSelectEditOkbtn" name="form:inplaceSelectEditOkbtn" onmousedown="this.className='rf-is-btn-press'" onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" src="/javax.faces.resource/ico_ok.gif.jsf?ln=org.richfaces" type="image"/>
- <input class="rf-is-btn" id="form:inplaceSelectEditCancelbtn" name="form:inplaceSelectEditOkbtn" onmousedown="this.className='rf-is-btn-press'" onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" src="/javax.faces.resource/ico_cancel.gif.jsf?ln=org.richfaces" type="image"/>
- <br/>
- </span>
- </span>
- </span>
- </span>
- <span class="rf-is-lst-cord" id="form:inplaceSelectEditList" style="display: none">
- <span class="rf-is-lst-pos" style="width: 250px">
- <span class="rf-is-shdw">
- <span class="rf-is-shdw-t">
- </span>
- <span class="rf-is-shdw-l">
- </span>
- <span class="rf-is-shdw-r">
- </span>
- <span class="rf-is-shdw-b">
- </span>
- <span class="rf-is-lst-dec">
- <span class="rf-is-lst-scrl" style="height: 100px">
- <span id="form:inplaceSelectEditItems">
- <span id="form:inplaceSelectEditItem0" class="rf-is-opt">
- Label#1
- </span>
- <span id="form:inplaceSelectEditItem1" class="rf-is-opt">
- Label#2
- </span>
- <span id="form:inplaceSelectEditItem2" class="rf-is-opt">
- Label#3
- </span>
- <span id="form:inplaceSelectEditItem3" class="rf-is-opt">
- Label#4
- </span>
- </span>
- </span>
- </span>
- </span>
- </span>
- </span>
- </span>
- <script type="text/javascript">
- //ignored
- </script>
+ <span class="rf-is-lbl" id="form:inplaceSelectEditLabel">Edit Text</span>
+ <input class="rf-is-none" id="form:inplaceSelectEditFocus" name="form:inplaceSelectEditFocus" style="position: absolute; top: 0px; left: 0px; outline-style: none;" type="image" />
+ <span class="rf-is-edit" id="form:inplaceSelectEditEdit">
+ <input id="form:inplaceSelectEditselValue" name="form:inplaceSelectEdit" type="hidden" />
+ <input autocomplete="off" class="rf-is-fld" id="form:inplaceSelectEditInput" name="form:inplaceSelectEditInput" readonly="readonly" style="width: ;" type="text" />
+ <span class="rf-is-btn-prepos">
+ <span class="rf-is-btn-pos">
+ <span class="rf-is-shdw" id="form:inplaceSelectEditBtnshadow">
+ <span class="rf-is-shdw-t"></span>
+ <span class="rf-is-shdw-l"></span>
+ <span class="rf-is-shdw-r"></span>
+ <span class="rf-is-shdw-b"></span>
+ <span id="form:inplaceSelectEditBtn" style="position : relative;">
+ <input class="rf-is-btn" id="form:inplaceSelectEditOkbtn" onmousedown="this.className='rf-is-btn-press'" onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" src="/javax.faces.resource/ico_ok.gif.jsf?ln=org.richfaces" type="image" />
+ <input class="rf-is-btn" id="form:inplaceSelectEditCancelbtn" onmousedown="this.className='rf-is-btn-press'" onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" src="/javax.faces.resource/ico_cancel.gif.jsf?ln=org.richfaces" type="image" />
+ <br />
+ </span>
+ </span>
+ </span>
+ </span>
+ <span class="rf-is-lst-cord" id="form:inplaceSelectEditList" style="display: none">
+ <span class="rf-is-lst-pos" style="width: 200px">
+ <span class="rf-is-shdw">
+ <span class="rf-is-shdw-t"></span>
+ <span class="rf-is-shdw-l"></span>
+ <span class="rf-is-shdw-r"></span>
+ <span class="rf-is-shdw-b"></span>
+ <span class="rf-is-lst-dec">
+ <span class="rf-is-lst-scrl" style="height: 100px">
+ <span id="form:inplaceSelectEditItems">
+ <span id="form:inplaceSelectEditItem0" class="rf-is-opt">Label#1</span>
+ <span id="form:inplaceSelectEditItem1" class="rf-is-opt">Label#2</span>
+ <span id="form:inplaceSelectEditItem2" class="rf-is-opt">Label#3</span>
+ <span id="form:inplaceSelectEditItem3" class="rf-is-opt">Label#4</span>
+ </span>
+ </span>
+ </span>
+ </span>
+ </span>
+ </span>
+ </span>
+ <script type="text/javascript">
+ //ignore
+ </script>
</span>
Modified: branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestWithControls.xmlunit.xml
===================================================================
--- branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestWithControls.xmlunit.xml 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestWithControls.xmlunit.xml 2010-12-23 17:32:10 UTC (rev 20787)
@@ -1,64 +1,46 @@
<span class="rf-is-d-s" id="form:inplaceSelectWithControls">
- <span class="rf-is-lbl" id="form:inplaceSelectWithControlsLabel">
- Edit Text
- </span>
- <input class="rf-is-none" id="form:inplaceSelectWithControlsFocus" name="form:inplaceSelectWithControlsFocus" style="position: absolute; top: 0px; left: 0px; outline-style: none;" type="image"/>
- <span class="rf-is-edit rf-is-none" id="form:inplaceSelectWithControlsEdit">
- <input id="form:inplaceSelectWithControlsselValue" name="form:inplaceSelectWithControls" type="hidden"/>
- <input autocomplete="off" class="rf-is-fld" id="form:inplaceSelectWithControlsInput" name="form:inplaceSelectWithControlsInput" readonly="readonly" style="width: ;" type="text"/>
- <span class="rf-is-btn-prepos">
- <span class="rf-is-btn-pos">
- <span class="rf-is-shdw" id="form:inplaceSelectWithControlsBtnshadow">
- <span class="rf-is-shdw-t">
- </span>
- <span class="rf-is-shdw-l">
- </span>
- <span class="rf-is-shdw-r">
- </span>
- <span class="rf-is-shdw-b">
- </span>
- <span id="form:inplaceSelectWithControlsBtn" style="position : relative;">
- <input class="rf-is-btn" id="form:inplaceSelectWithControlsOkbtn" name="form:inplaceSelectWithControlsOkbtn" onmousedown="this.className='rf-is-btn-press'" onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" src="/javax.faces.resource/ico_ok.gif.jsf?ln=org.richfaces" type="image"/>
- <input class="rf-is-btn" id="form:inplaceSelectWithControlsCancelbtn" name="form:inplaceSelectWithControlsOkbtn" onmousedown="this.className='rf-is-btn-press'" onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" src="/javax.faces.resource/ico_cancel.gif.jsf?ln=org.richfaces" type="image"/>
- <br/>
- </span>
- </span>
- </span>
- </span>
- <span class="rf-is-lst-cord" id="form:inplaceSelectWithControlsList" style="display: none">
- <span class="rf-is-lst-pos" style="width: 250px">
- <span class="rf-is-shdw">
- <span class="rf-is-shdw-t">
- </span>
- <span class="rf-is-shdw-l">
- </span>
- <span class="rf-is-shdw-r">
- </span>
- <span class="rf-is-shdw-b">
- </span>
- <span class="rf-is-lst-dec">
- <span class="rf-is-lst-scrl" style="height: 100px">
- <span id="form:inplaceSelectWithControlsItems">
- <span id="form:inplaceSelectWithControlsItem0" class="rf-is-opt">
- Label#1
- </span>
- <span id="form:inplaceSelectWithControlsItem1" class="rf-is-opt">
- Label#2
- </span>
- <span id="form:inplaceSelectWithControlsItem2" class="rf-is-opt">
- Label#3
- </span>
- <span id="form:inplaceSelectWithControlsItem3" class="rf-is-opt">
- Label#4
- </span>
- </span>
- </span>
- </span>
- </span>
- </span>
- </span>
- </span>
- <script type="text/javascript">
- //ignored
- </script>
+ <span class="rf-is-lbl" id="form:inplaceSelectWithControlsLabel">Edit Text</span>
+ <input class="rf-is-none" id="form:inplaceSelectWithControlsFocus" name="form:inplaceSelectWithControlsFocus" style="position: absolute; top: 0px; left: 0px; outline-style: none;" type="image" />
+ <span class="rf-is-edit rf-is-none" id="form:inplaceSelectWithControlsEdit">
+ <input id="form:inplaceSelectWithControlsselValue" name="form:inplaceSelectWithControls" type="hidden" />
+ <input autocomplete="off" class="rf-is-fld" id="form:inplaceSelectWithControlsInput" name="form:inplaceSelectWithControlsInput" readonly="readonly" style="width: ;" type="text" />
+ <span class="rf-is-btn-prepos">
+ <span class="rf-is-btn-pos">
+ <span class="rf-is-shdw" id="form:inplaceSelectWithControlsBtnshadow">
+ <span class="rf-is-shdw-t"></span>
+ <span class="rf-is-shdw-l"></span>
+ <span class="rf-is-shdw-r"></span>
+ <span class="rf-is-shdw-b"></span>
+ <span id="form:inplaceSelectWithControlsBtn" style="position : relative;">
+ <input class="rf-is-btn" id="form:inplaceSelectWithControlsOkbtn" onmousedown="this.className='rf-is-btn-press'" onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" src="/javax.faces.resource/ico_ok.gif.jsf?ln=org.richfaces" type="image" />
+ <input class="rf-is-btn" id="form:inplaceSelectWithControlsCancelbtn" onmousedown="this.className='rf-is-btn-press'" onmouseout="this.className='rf-is-btn'" onmouseup="this.className='rf-is-btn'" src="/javax.faces.resource/ico_cancel.gif.jsf?ln=org.richfaces" type="image" />
+ <br />
+ </span>
+ </span>
+ </span>
+ </span>
+ <span class="rf-is-lst-cord" id="form:inplaceSelectWithControlsList" style="display: none">
+ <span class="rf-is-lst-pos" style="width: 200px">
+ <span class="rf-is-shdw">
+ <span class="rf-is-shdw-t"></span>
+ <span class="rf-is-shdw-l"></span>
+ <span class="rf-is-shdw-r"></span>
+ <span class="rf-is-shdw-b"></span>
+ <span class="rf-is-lst-dec">
+ <span class="rf-is-lst-scrl" style="height: 100px">
+ <span id="form:inplaceSelectWithControlsItems">
+ <span id="form:inplaceSelectWithControlsItem0" class="rf-is-opt">Label#1</span>
+ <span id="form:inplaceSelectWithControlsItem1" class="rf-is-opt">Label#2</span>
+ <span id="form:inplaceSelectWithControlsItem2" class="rf-is-opt">Label#3</span>
+ <span id="form:inplaceSelectWithControlsItem3" class="rf-is-opt">Label#4</span>
+ </span>
+ </span>
+ </span>
+ </span>
+ </span>
+ </span>
+ </span>
+ <script type="text/javascript">
+ // ignore
+ </script>
</span>
\ No newline at end of file
Modified: branches/RF-9323/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
--- branches/RF-9323/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -69,6 +69,7 @@
@ResourceDependencies({
@ResourceDependency(library="org.richfaces", name = "extendedDataTable.ecss"),
@ResourceDependency(library="org.richfaces", name = "ajax.reslib"),
+ @ResourceDependency(library="org.richfaces", name = "base-component.reslib"),
@ResourceDependency(name = "jquery.position.js"),
@ResourceDependency(library="org.richfaces", name = "extendedDataTable.js")
})
@@ -675,7 +676,7 @@
component, EVENT_ATTRIBUTES.get("onbeforeselectionchange")), null, ScriptHashVariableWrapper.eventHandler);
addToScriptHash(options, "onselectionchange", RenderKitUtils.getAttributeAndBehaviorsValue(context,
component, EVENT_ATTRIBUTES.get("onselectionchange")), null, ScriptHashVariableWrapper.eventHandler);
- StringBuilder builder = new StringBuilder("new RichFaces.ExtendedDataTable('");
+ StringBuilder builder = new StringBuilder("new RichFaces.ui.ExtendedDataTable('");
builder.append(component.getClientId(context)).append("', ").append(getRowCount(component))
.append(", function(event, clientParams) {").append(ajaxFunction.toScript()).append(";}");
if (!options.isEmpty()) {
Modified: branches/RF-9323/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js
===================================================================
--- branches/RF-9323/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/extendedDataTable.js 2010-12-23 17:32:10 UTC (rev 20787)
@@ -131,413 +131,497 @@
}
};
- richfaces.ExtendedDataTable = function(id, rowCount, ajaxFunction, options) {
- var WIDTH_CLASS_NAME_BASE = "rf-edt-c-";
- var MIN_WIDTH = 20;
+ var WIDTH_CLASS_NAME_BASE = "rf-edt-c-";
+ var MIN_WIDTH = 20;
+
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.ExtendedDataTable = richfaces.BaseComponent.extendClass({
- options = options || {};
- var ranges = new richfaces.utils.Ranges();
- var element = document.getElementById(id);
- var bodyElement, contentElement, spacerElement, dataTableElement, normalPartStyle, rows, rowHeight, parts, tbodies,
- shiftIndex, activeIndex, selectionFlag;
- var dragElement = document.getElementById(id + ":d");
- var reorderElement = document.getElementById(id + ":r");
- var reorderMarkerElement = document.getElementById(id + ":rm");
- var widthInput = document.getElementById(id + ":wi");
- var selectionInput = document.getElementById(id + ":si");
- var header = jQuery(element).children(".rf-edt-hdr");
- var resizerHolders = header.find(".rf-edt-rsz-cntr");
+ name: "ExtendedDataTable",
+
+ ranges: new richfaces.utils.Ranges(),
+ resizeData: {},
+ idOfReorderingColumn: "",
+ newWidths: {},
+ timeoutId: null,
+
+ init: function (id, rowCount, ajaxFunction, options) {
+ $super.constructor.call(this, id);
+ this.rowCount = rowCount;
+ this.ajaxFunction = ajaxFunction;
+ this.options = options || {};
+ this.element = this.attachToDom();
+// var bodyElement, contentElement, spacerElement, dataTableElement, normalPartStyle, rows, rowHeight, parts, tbodies,
+// shiftIndex, activeIndex, selectionFlag;
+ this.dragElement = document.getElementById(id + ":d");
+ this.reorderElement = document.getElementById(id + ":r");
+ this.reorderMarkerElement = document.getElementById(id + ":rm");
+ this.widthInput = document.getElementById(id + ":wi");
+ this.selectionInput = document.getElementById(id + ":si");
+ this.header = jQuery(this.element).children(".rf-edt-hdr");
+ this.resizerHolders = this.header.find(".rf-edt-rsz-cntr");
+
+ this.frozenHeaderPartElement = document.getElementById(id + ":frozenHeader");
+ this.frozenColumnCount = this.frozenHeaderPartElement ? this.frozenHeaderPartElement.firstChild.rows[0].cells.length : 0;//TODO Richfaces.firstDescendant;
+
+ this.scrollElement = document.getElementById(id + ":footer");
+
+ jQuery(document).ready(jQuery.proxy(this.initialize, this));
+ jQuery(window).bind("resize", jQuery.proxy(this.updateLayout, this));
+ jQuery(this.scrollElement).bind("scroll", jQuery.proxy(this.updateScrollPosition, this));
+ this.bindHeaderHandlers();
+ jQuery(this.element).bind("rich:onajaxcomplete", jQuery.proxy(this.ajaxComplete, this));
+ },
+
+ getColumnPosition: function(id) {
+ var position;
+ var headers = this.header.find(".rf-edt-hdr-c");
+ for (var i = 0; i < headers.length; i++) {
+ if (id == headers[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1]) {
+ position = i;
+ }
+ }
+ return position;
+ },
+
+ setColumnPosition: function(id, position) {
+ var colunmsOrder = "";
+ var before;
+ var headers = this.header.find(".rf-edt-hdr-c");
+ for (var i = 0; i < headers.length; i++) {
+ var current = headers[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
+ if (i == position) {
+ if (before) {
+ colunmsOrder += current + "," + id + ",";
+ } else {
+ colunmsOrder += id + "," + current + ",";
+ }
+ } else {
+ if (id != current) {
+ colunmsOrder += current + ",";
+ } else {
+ before = true;
+ }
+ }
+ }
+ this.ajaxFunction(null, {"rich:columnsOrder" : colunmsOrder}); // TODO Maybe, event model should be used here.
+ },
- var frozenHeaderPartElement = document.getElementById(id + ":frozenHeader");
- var frozenColumnCount = frozenHeaderPartElement ? frozenHeaderPartElement.firstChild.rows[0].cells.length : 0;//TODO Richfaces.firstDescendant;
+ setColumnWidth: function(id, width) {
+ width = width + "px";
+ richfaces.utils.getCSSRule("." + WIDTH_CLASS_NAME_BASE + id).style.width = width;
+ this.newWidths[id] = width;
+ var widthsArray = new Array();
+ for (var id in this.newWidths) {
+ widthsArray.push(id + ":" + this.newWidths[id]);
+ }
+ this.widthInput.value = widthsArray.toString();
+ this.updateLayout();
+ this.adjustResizers();
+ this.ajaxFunction(); // TODO Maybe, event model should be used here.
+ },
- var scrollElement = document.getElementById(id + ":footer");
+ filter: function(colunmId, filterValue, isClear) {
+ if (typeof(filterValue) == "undefined" || filterValue == null) {
+ filterValue = "";
+ }
+ var map = {};
+ map[id + "rich:filtering"] = colunmId + ":" + filterValue + ":" + isClear;
+ this.ajaxFunction(null, map); // TODO Maybe, event model should be used here.
+ },
- var resizeData = {};
- var idOfReorderingColumn = "";
- var newWidths = {};
+ clearFiltering: function() {
+ this.filter("", "", true);
+ },
- var timeoutId = null;
+ sort: function(colunmId, sortOrder, isClear) {
+ if (typeof(sortOrder) == "string") {
+ sortOrder = sortOrder.toUpperCase();
+ }
+ var map = {}
+ map[this.id + "rich:sorting"] = colunmId + ":" + sortOrder + ":" + isClear;
+ this.ajaxFunction(null, map); // TODO Maybe, event model should be used here.
+ },
- var sendAjax = function(event, map) {
- ajaxFunction(event, map);
- };
+ clearSorting: function() {
+ this.sort("", "", true);
+ },
+
+ destroy: function() {
+ jQuery(window).unbind("resize", this.updateLayout);
+ jQuery(richfaces.getDomElement(this.id + ':st')).remove();
+ $super.destroy.call(this);
+ },
- var updateLayout = function() {
- normalPartStyle.width = "auto";
- var offsetWidth = frozenHeaderPartElement ? frozenHeaderPartElement.offsetWidth : 0;
- var width = Math.max(0, element.clientWidth - offsetWidth);
+ bindHeaderHandlers: function() {
+ this.header.find(".rf-edt-rsz").bind("mousedown", jQuery.proxy(this.beginResize, this));
+ this.header.find(".rf-edt-hdr-c").bind("mousedown", jQuery.proxy(this.beginReorder, this));
+ },
+
+ updateLayout: function() {
+ this.normalPartStyle.width = "auto";
+ var offsetWidth = this.frozenHeaderPartElement ? this.frozenHeaderPartElement.offsetWidth : 0;
+ var width = Math.max(0, this.element.clientWidth - offsetWidth);
if (width) {
- if (parts.width() > width) {
- normalPartStyle.width = width + "px";
+ if (this.parts.width() > width) {
+ this.normalPartStyle.width = width + "px";
}
- normalPartStyle.display = "block";
- scrollElement.style.overflowX = "";
- if (scrollElement.clientWidth < scrollElement.scrollWidth
- && scrollElement.scrollHeight == scrollElement.offsetHeight) {
- scrollElement.style.overflowX = "scroll";
+ this.normalPartStyle.display = "block";
+ this.scrollElement.style.overflowX = "";
+ if (this.scrollElement.clientWidth < this.scrollElement.scrollWidth
+ && this.scrollElement.scrollHeight == this.scrollElement.offsetHeight) {
+ this.scrollElement.style.overflowX = "scroll";
}
- var delta = scrollElement.firstChild.offsetHeight - scrollElement.clientHeight;
+ var delta = this.scrollElement.firstChild.offsetHeight - this.scrollElement.clientHeight;
if (delta) {
- scrollElement.style.height = scrollElement.offsetHeight + delta;
+ this.scrollElement.style.height = this.scrollElement.offsetHeight + delta;
}
} else {
- normalPartStyle.display = "none";
+ this.normalPartStyle.display = "none";
}
- var height = element.clientHeight;
- var el = element.firstChild;
+ var height = this.element.clientHeight;
+ var el = this.element.firstChild;
while (el && (!el.nodeName || el.nodeName.toUpperCase() != "TABLE")) {
- if(el.nodeName && el.nodeName.toUpperCase() == "DIV" && el != bodyElement) {
+ if(el.nodeName && el.nodeName.toUpperCase() == "DIV" && el != this.bodyElement) {
height -= el.offsetHeight;
}
el = el.nextSibling;
}
- if (bodyElement.offsetHeight > height) {
- bodyElement.style.height = height + "px";
+ if (this.bodyElement.offsetHeight > height) {
+ this.bodyElement.style.height = height + "px";
}
- };
+ },
- var adjustResizers = function() {
- var scrollLeft = scrollElement ? scrollElement.scrollLeft : 0;
- var clientWidth = element.clientWidth - 3;
+ adjustResizers: function() { //For IE7 only.
+ var scrollLeft = this.scrollElement ? this.scrollElement.scrollLeft : 0;
+ var clientWidth = this.element.clientWidth - 3;
var i = 0;
- for (; i < frozenColumnCount; i++) {
+ for (; i < this.frozenColumnCount; i++) {
if (clientWidth > 0) {
- resizerHolders[i].style.display = "none";
- resizerHolders[i].style.display = "";
- clientWidth -= resizerHolders[i].offsetWidth;
+ this.resizerHolders[i].style.display = "none";
+ this.resizerHolders[i].style.display = "";
+ clientWidth -= this.resizerHolders[i].offsetWidth;
}
if (clientWidth <= 0) {
- resizerHolders[i].style.display = "none";
+ this.resizerHolders[i].style.display = "none";
}
}
scrollLeft -= 3;
- for (; i < resizerHolders.length; i++) {
+ for (; i < this.resizerHolders.length; i++) {
if (clientWidth > 0) {
- resizerHolders[i].style.display = "none";
+ this.resizerHolders[i].style.display = "none";
if (scrollLeft > 0) {
- resizerHolders[i].style.display = "";
- scrollLeft -= resizerHolders[i].offsetWidth;
+ this.resizerHolders[i].style.display = "";
+ scrollLeft -= this.resizerHolders[i].offsetWidth;
if (scrollLeft > 0) {
- resizerHolders[i].style.display = "none";
+ this.resizerHolders[i].style.display = "none";
} else {
clientWidth += scrollLeft;
}
} else {
- resizerHolders[i].style.display = "";
- clientWidth -= resizerHolders[i].offsetWidth;
+ this.resizerHolders[i].style.display = "";
+ clientWidth -= this.resizerHolders[i].offsetWidth;
}
}
if (clientWidth <= 0) {
- resizerHolders[i].style.display = "none";
+ this.resizerHolders[i].style.display = "none";
}
}
- };
-
- var updateScrollPosition = function() {
- if (scrollElement) {
- var scrollLeft = scrollElement.scrollLeft;
- parts.each(function() {
+ },
+
+ updateScrollPosition: function() {
+ if (this.scrollElement) {
+ var scrollLeft = this.scrollElement.scrollLeft;
+ this.parts.each(function() {
this.scrollLeft = scrollLeft;
});
}
- adjustResizers();
- };
-
- var initialize = function() {
- bodyElement = document.getElementById(id + ":b");
- bodyElement.tabIndex = -1; //TODO don't use tabIndex.
- normalPartStyle = richfaces.utils.getCSSRule("div.rf-edt-cnt").style;
- var bodyJQuery = jQuery(bodyElement);
- contentElement = bodyJQuery.children("div:first")[0];
- if (contentElement) {
- spacerElement = contentElement.firstChild;//TODO this.marginElement = Richfaces.firstDescendant(this.contentElement);
- dataTableElement = contentElement.lastChild;//TODO this.dataTableElement = Richfaces.lastDescendant(this.contentElement);
- tbodies = jQuery(document.getElementById(id + ":tbf")).add(document.getElementById(id + ":tbn"));
- rows = tbodies[0].rows.length;
- rowHeight = dataTableElement.offsetHeight / rows;
- if (rowCount != rows) {
- contentElement.style.height = (rowCount * rowHeight) + "px";
+ this.adjustResizers();
+ },
+
+ initialize: function() {
+ this.bodyElement = document.getElementById(this.id + ":b");
+ this.bodyElement.tabIndex = -1; //TODO don't use tabIndex.
+ this.normalPartStyle = richfaces.utils.getCSSRule("div.rf-edt-cnt").style;
+ var bodyJQuery = jQuery(this.bodyElement);
+ this.contentElement = bodyJQuery.children("div:first")[0];
+ if (this.contentElement) {
+ this.spacerElement = this.contentElement.firstChild;//TODO this.marginElement = Richfaces.firstDescendant(this.contentElement);
+ this.dataTableElement = this.contentElement.lastChild;//TODO this.dataTableElement = Richfaces.lastDescendant(this.contentElement);
+ this.tbodies = jQuery(document.getElementById(this.id + ":tbf")).add(document.getElementById(this.id + ":tbn"));
+ this.rows = this.tbodies[0].rows.length;
+ this.rowHeight = this.dataTableElement.offsetHeight / this.rows;
+ if (this.rowCount != this.rows) {
+ this.contentElement.style.height = (this.rowCount * this.rowHeight) + "px";
}
- bodyJQuery.bind("scroll", bodyScrollListener);
- if (options.selectionMode != "none") {
- tbodies.bind("click", selectionClickListener);
- bodyJQuery.bind(window.opera ? "keypress" : "keydown", selectionKeyDownListener);
- initializeSelection();
+ bodyJQuery.bind("scroll", jQuery.proxy(this.bodyScrollListener, this));
+ if (this.options.selectionMode != "none") {
+ this.tbodies.bind("click", jQuery.proxy(this.selectionClickListener, this));
+ bodyJQuery.bind(window.opera ? "keypress" : "keydown", jQuery.proxy(this.selectionKeyDownListener, this));
+ this.initializeSelection();
}
} else {
- spacerElement = null;
- dataTableElement = null;
+ this.spacerElement = null;
+ this.dataTableElement = null;
}
- parts = jQuery(element).find(".rf-edt-cnt, .rf-edt-ftr-cnt");
- updateLayout();
- updateScrollPosition(); //TODO Restore horizontal scroll position
- };
+ this.parts = jQuery(this.element).find(".rf-edt-cnt, .rf-edt-ftr-cnt");
+ this.updateLayout();
+ this.updateScrollPosition(); //TODO Restore horizontal scroll position
+ },
- var drag = function(event) {
- jQuery(dragElement).setPosition({left:Math.max(resizeData.left + MIN_WIDTH, event.pageX)});
+ drag: function(event) {
+ jQuery(this.dragElement).setPosition({left:Math.max(this.resizeData.left + MIN_WIDTH, event.pageX)});
return false;
- };
+ },
- var beginResize = function(event) {
- var id = this.parentNode.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
- resizeData = {
+ beginResize: function(event) {
+ var id = event.currentTarget.parentNode.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
+ this.resizeData = {
id : id,
- left : jQuery(this).parent().offset().left
+ left : jQuery(event.currentTarget).parent().offset().left
};
- dragElement.style.height = element.offsetHeight + "px";
- jQuery(dragElement).setPosition({top:jQuery(element).offset().top, left:event.pageX});
- dragElement.style.display = "block";
- jQuery(document).bind("mousemove", drag);
- jQuery(document).one("mouseup", endResize);
+ this.dragElement.style.height = this.element.offsetHeight + "px";
+ jQuery(this.dragElement).setPosition({top:jQuery(this.element).offset().top, left:event.pageX});
+ this.dragElement.style.display = "block";
+ jQuery(document).bind("mousemove", jQuery.proxy(this.drag, this));
+ jQuery(document).one("mouseup", jQuery.proxy(this.endResize, this));
return false;
- };
+ },
- var setColumnWidth = function(id, width) {
- width = width + "px";
- richfaces.utils.getCSSRule("." + WIDTH_CLASS_NAME_BASE + id).style.width = width;
- newWidths[id] = width;
- var widthsArray = new Array();
- for (var id in newWidths) {
- widthsArray.push(id + ":" + newWidths[id]);
- }
- widthInput.value = widthsArray.toString();
- updateLayout();
- adjustResizers();
- sendAjax(); // TODO Maybe, event model should be used here.
- };
-
- var endResize = function(event) {
- jQuery(document).unbind("mousemove", drag);
- dragElement.style.display = "none";
- var width = Math.max(MIN_WIDTH, event.pageX - resizeData.left);
- setColumnWidth(resizeData.id, width);
- };
-
- var reorder = function(event) {
- jQuery(reorderElement).setPosition(event, {offset:[5,5]});
- reorderElement.style.display = "block";
+ endResize: function(event) {
+ jQuery(document).unbind("mousemove", this.drag);
+ this.dragElement.style.display = "none";
+ var width = Math.max(MIN_WIDTH, event.pageX - this.resizeData.left);
+ this.setColumnWidth(this.resizeData.id, width);
+ },
+
+ reorder: function(event) {
+ jQuery(this.reorderElement).setPosition(event, {offset:[5,5]});
+ this.reorderElement.style.display = "block";
return false;
- };
-
- var beginReorder = function(event) {
- if (!jQuery(event.target).is("a, img, :input")) {
- idOfReorderingColumn = this.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
- jQuery(document).bind("mousemove", reorder);
- header.find(".rf-edt-hdr-c").bind("mouseover", overReorder);
- jQuery(document).one("mouseup", cancelReorder);
+ },
+
+ beginReorder: function(event) {
+ if (!jQuery(event.currentTarget).is("a, img, :input")) {
+ this.idOfReorderingColumn = event.currentTarget.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
+ jQuery(document).bind("mousemove", jQuery.proxy(this.reorder, this));
+ this.header.find(".rf-edt-hdr-c").bind("mouseover", jQuery.proxy(this.overReorder, this));
+ jQuery(document).one("mouseup", jQuery.proxy(this.cancelReorder, this));
return false;
}
- };
+ },
- var overReorder = function(event) {
- if (idOfReorderingColumn != this.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1]) {
- var thisElement = jQuery(this);
- var offset = thisElement.offset();
- jQuery(reorderMarkerElement).setPosition({top:offset.top + thisElement.height(), left:offset.left - 5});
- reorderMarkerElement.style.display = "block";
- thisElement.one("mouseout", outReorder);
- thisElement.one("mouseup", endReorder);
+ overReorder: function(event) {
+ if (this.idOfReorderingColumn != event.currentTarget.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1]) {
+ var eventElement = jQuery(event.currentTarget);
+ var offset = eventElement.offset();
+ jQuery(this.reorderMarkerElement).setPosition({top:offset.top + eventElement.height(), left:offset.left - 5});
+ this.reorderMarkerElement.style.display = "block";
+ eventElement.one("mouseout", jQuery.proxy(this.outReorder, this));
+ eventElement.one("mouseup", jQuery.proxy(this.endReorder, this));
}
- };
+ },
- var outReorder = function(event) {
- reorderMarkerElement.style.display = "";
- jQuery(this).unbind("mouseup", endReorder);
- };
+ outReorder: function(event) {
+ this.reorderMarkerElement.style.display = "";
+ jQuery(event.currentTarget).unbind("mouseup", this.endReorder);
+ },
- var endReorder = function(event) {
- reorderMarkerElement.style.display = "";
- jQuery(this).unbind("mouseout", outReorder);
- var id = this.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
+ endReorder: function(event) {
+ this.reorderMarkerElement.style.display = "";
+ jQuery(event.currentTarget).unbind("mouseout", this.outReorder);
+ var id = event.currentTarget.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
var colunmsOrder = "";
- header.find(".rf-edt-hdr-c").each(function() {
+ var _this = this;
+ this.header.find(".rf-edt-hdr-c").each(function() {
var i = this.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
if (i == id) {
- colunmsOrder += idOfReorderingColumn + "," + id + ",";
- } else if (i != idOfReorderingColumn) {
+ colunmsOrder += _this.idOfReorderingColumn + "," + id + ",";
+ } else if (i != _this.idOfReorderingColumn) {
colunmsOrder += i + ",";
}
});
- sendAjax(event, {"rich:columnsOrder" : colunmsOrder}); // TODO Maybe, event model should be used here.
- };
+ this.ajaxFunction(event, {"rich:columnsOrder" : colunmsOrder}); // TODO Maybe, event model should be used here.
+ },
- var cancelReorder = function(event) {
- jQuery(document).unbind("mousemove", reorder);
- header.find(".rf-edt-hdr-c").unbind("mouseover", overReorder);
- reorderElement.style.display = "none";
- };
+ cancelReorder: function(event) {
+ jQuery(document).unbind("mousemove", this.reorder);
+ this.header.find(".rf-edt-hdr-c").unbind("mouseover", this.overReorder);
+ this.reorderElement.style.display = "none";
+ },
- var loadData = function(event) {
- var clientFirst = Math.round((bodyElement.scrollTop + bodyElement.clientHeight / 2) / (rowHeight) - rows / 2);
+ loadData: function(event) {
+ var clientFirst = Math.round((this.bodyElement.scrollTop + this.bodyElement.clientHeight / 2) / this.rowHeight - this.rows / 2);
if (clientFirst <= 0) {
clientFirst = 0;
} else {
- clientFirst = Math.min(rowCount - rows, clientFirst);
+ clientFirst = Math.min(this.rowCount - this.rows, clientFirst);
}
- sendAjax(event, {"rich:clientFirst" : clientFirst});// TODO Maybe, event model should be used here.
- }
-
- var bodyScrollListener = function(event) {
- if(timeoutId) {
- window.clearTimeout(timeoutId);
- timeoutId = null;
+ this.ajaxFunction(event, {"rich:clientFirst" : clientFirst});// TODO Maybe, event model should be used here.
+ },
+
+ bodyScrollListener: function(event) {
+ if(this.timeoutId) {
+ window.clearTimeout(this.timeoutId);
+ this.timeoutId = null;
}
- if (Math.max(this.scrollTop - rowHeight, 0) < spacerElement.offsetHeight
- || Math.min(this.scrollTop + rowHeight + this.clientHeight, this.scrollHeight) > spacerElement.offsetHeight + dataTableElement.offsetHeight) {
- timeoutId = window.setTimeout(function (event) {loadData(event)}, 1000);
+ if (Math.max(event.currentTarget.scrollTop - this.rowHeight, 0) < this.spacerElement.offsetHeight
+ || Math.min(event.currentTarget.scrollTop + this.rowHeight + event.currentTarget.clientHeight, event.currentTarget.scrollHeight) > this.spacerElement.offsetHeight + this.dataTableElement.offsetHeight) {
+ var _this = this;
+ this.timeoutId = window.setTimeout(function (event) {_this.loadData(event)}, 1000);
}
- };
-
- var showActiveRow = function() {
- if (bodyElement.scrollTop > activeIndex * rowHeight + spacerElement.offsetHeight) { //UP
- bodyElement.scrollTop = Math.max(bodyElement.scrollTop - rowHeight, 0);
- } else if (bodyElement.scrollTop + bodyElement.clientHeight
- < (activeIndex + 1) * rowHeight + spacerElement.offsetHeight) { //DOWN
- bodyElement.scrollTop = Math.min(bodyElement.scrollTop + rowHeight, bodyElement.scrollHeight - bodyElement.clientHeight);
+ },
+
+ showActiveRow: function() {
+ if (this.bodyElement.scrollTop > this.activeIndex * this.rowHeight + this.spacerElement.offsetHeight) { //UP
+ this.bodyElement.scrollTop = Math.max(this.bodyElement.scrollTop - this.rowHeight, 0);
+ } else if (this.bodyElement.scrollTop + this.bodyElement.clientHeight
+ < (this.activeIndex + 1) * this.rowHeight + this.spacerElement.offsetHeight) { //DOWN
+ this.bodyElement.scrollTop = Math.min(this.bodyElement.scrollTop + this.rowHeight, this.bodyElement.scrollHeight - this.bodyElement.clientHeight);
}
- }
-
- var selectRow = function(index) {
- ranges.add(index);
- for ( var i = 0; i < tbodies.length; i++) {
- jQuery(tbodies[i].rows[index]).addClass("rf-edt-r-sel");
+ },
+
+ selectRow: function(index) {
+ this.ranges.add(index);
+ for (var i = 0; i < this.tbodies.length; i++) {
+ jQuery(this.tbodies[i].rows[index]).addClass("rf-edt-r-sel");
}
- }
+ },
- var deselectRow = function (index) {
- ranges.remove(index);
- for ( var i = 0; i < tbodies.length; i++) {
- jQuery(tbodies[i].rows[index]).removeClass("rf-edt-r-sel");
+ deselectRow: function (index) {
+ this.ranges.remove(index);
+ for (var i = 0; i < this.tbodies.length; i++) {
+ jQuery(this.tbodies[i].rows[index]).removeClass("rf-edt-r-sel");
}
- }
-
- var setActiveRow = function (index) {
- if(typeof activeIndex == "number") {
- for ( var i = 0; i < tbodies.length; i++) {
- jQuery(tbodies[i].rows[activeIndex]).removeClass("rf-edt-r-act");
+ },
+
+ setActiveRow: function (index) {
+ if (typeof this.activeIndex == "number") {
+ for (var i = 0; i < this.tbodies.length; i++) {
+ jQuery(this.tbodies[i].rows[this.activeIndex]).removeClass("rf-edt-r-act");
}
}
- activeIndex = index;
- for ( var i = 0; i < tbodies.length; i++) {
- jQuery(tbodies[i].rows[activeIndex]).addClass("rf-edt-r-act");
+ this.activeIndex = index;
+ for (var i = 0; i < this.tbodies.length; i++) {
+ jQuery(this.tbodies[i].rows[this.activeIndex]).addClass("rf-edt-r-act");
}
- }
+ },
- var resetShiftRow = function () {
- if(typeof shiftIndex == "number") {
- for ( var i = 0; i < tbodies.length; i++) {
- jQuery(tbodies[i].rows[shiftIndex]).removeClass("rf-edt-r-sht");
+ resetShiftRow: function () {
+ if (typeof this.shiftIndex == "number") {
+ for (var i = 0; i < this.tbodies.length; i++) {
+ jQuery(this.tbodies[i].rows[this.shiftIndex]).removeClass("rf-edt-r-sht");
}
}
- shiftIndex = null;
- }
+ this.shiftIndex = null;
+ },
- var setShiftRow = function (index) {
- resetShiftRow();
- shiftIndex = index;
+ setShiftRow: function (index) {
+ this.resetShiftRow();
+ this.shiftIndex = index;
if(typeof index == "number") {
- for ( var i = 0; i < tbodies.length; i++) {
- jQuery(tbodies[i].rows[shiftIndex]).addClass("rf-edt-r-sht");
+ for (var i = 0; i < this.tbodies.length; i++) {
+ jQuery(this.tbodies[i].rows[this.shiftIndex]).addClass("rf-edt-r-sht");
}
}
- }
+ },
- var initializeSelection = function() {
- ranges.clear();
- var strings = selectionInput.value.split("|");
- activeIndex = strings[1] || null;
- shiftIndex = strings[2] || null;
- selectionFlag = null;
- var rows = tbodies[0].rows;
+ initializeSelection: function() {
+ this.ranges.clear();
+ var strings = this.selectionInput.value.split("|");
+ this.activeIndex = strings[1] || null;
+ this.shiftIndex = strings[2] || null;
+ this.selectionFlag = null;
+ var rows = this.tbodies[0].rows;
for (var i = 0; i < rows.length; i++) {
var row = jQuery(rows[i]);
if (row.hasClass("rf-edt-r-sel")) {
- ranges.add(row[0].rowIndex)
+ this.ranges.add(row[0].rowIndex)
}
if (row.hasClass("rf-edt-r-act")) {
- activeIndex = row[0].rowIndex;
+ this.activeIndex = row[0].rowIndex;
}
if (row.hasClass("rf-edt-r-sht")) {
- shiftIndex = row[0].rowIndex;
+ this.shiftIndex = row[0].rowIndex;
}
}
- writeSelection();
- }
-
- var writeSelection = function() {
- selectionInput.value = [ranges, activeIndex, shiftIndex, selectionFlag].join("|");
- }
+ this.writeSelection();
+ },
- var selectRows = function(range) {
+ writeSelection: function() {
+ this.selectionInput.value = [this.ranges, this.activeIndex, this.shiftIndex, this.selectionFlag].join("|");
+ },
+
+ selectRows: function(range) {
if (typeof range == "number") {
range = [range, range];
}
var changed;
var i = 0;
for (; i < range[0]; i++) {
- if (ranges.contains(i)) {
- deselectRow(i);
+ if (this.ranges.contains(i)) {
+ this.deselectRow(i);
changed = true;
}
}
for (; i <= range[1]; i++) {
- if (!ranges.contains(i)) {
- selectRow(i);
+ if (!this.ranges.contains(i)) {
+ this.selectRow(i);
changed = true;
}
}
- for (; i < rows; i++) {
- if (ranges.contains(i)) {
- deselectRow(i);
+ for (; i < this.rows; i++) {
+ if (this.ranges.contains(i)) {
+ this.deselectRow(i);
changed = true;
}
}
- selectionFlag = typeof shiftIndex == "string" ? shiftIndex : "x";
+ this.selectionFlag = typeof this.shiftIndex == "string" ? this.shiftIndex : "x";
return changed;
- }
+ },
- var processSlectionWithShiftKey = function(index) {
- if(shiftIndex == null) {
- setShiftRow(activeIndex != null ? activeIndex : index);
+ processSlectionWithShiftKey: function(index) {
+ if(this.shiftIndex == null) {
+ this.setShiftRow(this.activeIndex != null ? this.activeIndex : index);
}
var range;
- if ("u" == shiftIndex) {
+ if ("u" == this.shiftIndex) {
range = [0, index];
- } else if ("d" == shiftIndex) {
+ } else if ("d" == this.shiftIndex) {
range = [index, rows - 1];
- } else if (index >= shiftIndex) {
- range = [shiftIndex, index];
+ } else if (index >= this.shiftIndex) {
+ range = [this.shiftIndex, index];
} else {
- range = [index, shiftIndex];
+ range = [index, this.shiftIndex];
}
- return selectRows(range);
- }
+ return this.selectRows(range);
+ },
- var onbeforeselectionchange = function (event) {
- return !options.onbeforeselectionchange || options.onbeforeselectionchange.call(element, event) !== false;
- }
+ onbeforeselectionchange: function (event) {
+ return !this.options.onbeforeselectionchange || this.options.onbeforeselectionchange.call(this.element, event) !== false;
+ },
- var onselectionchange = function (event, index, changed) {
+ onselectionchange: function (event, index, changed) {
if(!event.shiftKey) {
- resetShiftRow();
+ this.resetShiftRow();
}
- if (activeIndex != index) {
- setActiveRow(index);
- showActiveRow();
+ if (this.activeIndex != index) {
+ this.setActiveRow(index);
+ this.showActiveRow();
}
if (changed) {
- writeSelection();
- if (options.onselectionchange) {
- options.onselectionchange.call(element, event);
+ this.writeSelection();
+ if (this.options.onselectionchange) {
+ this.options.onselectionchange.call(this.element, event);
}
}
- }
+ },
- var selectionClickListener = function (event) {
- if (!onbeforeselectionchange(event)) {
+ selectionClickListener: function (event) {
+ if (!this.onbeforeselectionchange(event)) {
return;
}
var changed;
@@ -549,32 +633,32 @@
}
}
var tr = event.target;
- while (tbodies.index(tr.parentNode) == -1) {
+ while (this.tbodies.index(tr.parentNode) == -1) {
tr = tr.parentNode;
}
var index = tr.rowIndex;
- if (options.selectionMode == "single" || (options.selectionMode != "multipleKeyboardFree"
+ if (this.options.selectionMode == "single" || (this.options.selectionMode != "multipleKeyboardFree"
&& !event.shiftKey && !event.ctrlKey)) {
- changed = selectRows(index);
- } else if (options.selectionMode == "multipleKeyboardFree" || (!event.shiftKey && event.ctrlKey)) {
- if (ranges.contains(index)) {
- deselectRow(index);
+ changed = this.selectRows(index);
+ } else if (this.options.selectionMode == "multipleKeyboardFree" || (!event.shiftKey && event.ctrlKey)) {
+ if (this.ranges.contains(index)) {
+ this.deselectRow(index);
} else {
- selectRow(index);
+ this.selectRow(index);
}
changed = true;
} else {
- changed = processSlectionWithShiftKey(index);
+ changed = this.processSlectionWithShiftKey(index);
}
- onselectionchange(event, index, changed);
- }
-
- var selectionKeyDownListener = function(event) {
- if (event.ctrlKey && options.selectionMode != "single" && (event.keyCode == 65 || event.keyCode == 97) //Ctrl-A
- && onbeforeselectionchange(event)) {
- selectRows([0, rows]);
- selectionFlag = "a";
- onselectionchange(event, activeIndex, true); //TODO Is there a way to know that selection haven't changed?
+ this.onselectionchange(event, index, changed);
+ },
+
+ selectionKeyDownListener: function(event) {
+ if (event.ctrlKey && this.options.selectionMode != "single" && (event.keyCode == 65 || event.keyCode == 97) //Ctrl-A
+ && this.onbeforeselectionchange(event)) {
+ this.selectRows([0, rows]);
+ this.selectionFlag = "a";
+ this.onselectionchange(event, this.activeIndex, true); //TODO Is there a way to know that selection haven't changed?
event.preventDefault();
} else {
var index;
@@ -583,127 +667,41 @@
} else if (event.keyCode == 40) { //DOWN
index = 1;
}
- if (index != null && onbeforeselectionchange(event)) {
- if (typeof activeIndex == "number") {
- index += activeIndex;
- if (index >= 0 && index < rows ) {
+ if (index != null && this.onbeforeselectionchange(event)) {
+ if (typeof this.activeIndex == "number") {
+ index += this.activeIndex;
+ if (index >= 0 && index < this.rows) {
var changed;
- if (options.selectionMode == "single" || (!event.shiftKey && !event.ctrlKey)) {
- changed = selectRows(index);
+ if (this.options.selectionMode == "single" || (!event.shiftKey && !event.ctrlKey)) {
+ changed = this.selectRows(index);
} else if (event.shiftKey) {
- changed = processSlectionWithShiftKey(index);
+ changed = this.processSlectionWithShiftKey(index);
}
- onselectionchange(event, index, changed);
+ this.onselectionchange(event, index, changed);
}
}
event.preventDefault();
}
}
- }
-
- var ajaxComplete = function (event, data) {
+ },
+
+ ajaxComplete: function (event, data) {
if (data.reinitializeHeader) {
- bindHeaderHandlers();
+ this.bindHeaderHandlers();
} else {
- selectionInput = document.getElementById(id + ":si");
+ this.selectionInput = document.getElementById(this.id + ":si");
if (data.reinitializeBody) {
- rowCount = data.rowCount;
- initialize();
- } else if (options.selectionMode != "none") {
- initializeSelection();
+ this.rowCount = data.rowCount;
+ this.initialize();
+ } else if (this.options.selectionMode != "none") {
+ this.initializeSelection();
}
- if (spacerElement) {
- spacerElement.style.height = (data.first * rowHeight) + "px";
+ if (this.spacerElement) {
+ this.spacerElement.style.height = (data.first * this.rowHeight) + "px";
}
}
- };
-
- jQuery(document).ready(initialize);
- jQuery(window).bind("resize", updateLayout);
- jQuery(scrollElement).bind("scroll", updateScrollPosition);
- var bindHeaderHandlers = function () {
- header.find(".rf-edt-rsz").bind("mousedown", beginResize);
- header.find(".rf-edt-hdr-c").bind("mousedown", beginReorder);
}
- bindHeaderHandlers();
- jQuery(element).bind("rich:onajaxcomplete", ajaxComplete);
-
- //JS API
- element[richfaces.RICH_CONTAINER] = element[richfaces.RICH_CONTAINER] || {}; // TODO ExtendedDataTable should extend richfaces.BaseComponent instead of using it.
- element[richfaces.RICH_CONTAINER].component = this;
- this.destroy = function() {
- element[richfaces.RICH_CONTAINER] = null;
- jQuery(window).unbind("resize", updateLayout);
- jQuery(richfaces.getDomElement(id + ':st')).remove();
- }
-
- this.detach = function () {
- // TODO see implementation in richfaces-base-component.js
- };
-
- this.getColumnPosition = function(id) {
- var position;
- var headers = header.find(".rf-edt-hdr-c");
- for (var i = 0; i < headers.length; i++) {
- if (id == headers[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1]) {
- position = i;
- }
- }
- return position;
- }
-
- this.setColumnPosition = function(id, position) {
- var colunmsOrder = "";
- var before;
- var headers = header.find(".rf-edt-hdr-c");
- for (var i = 0; i < headers.length; i++) {
- var current = headers[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
- if (i == position) {
- if (before) {
- colunmsOrder += current + "," + id + ",";
- } else {
- colunmsOrder += id + "," + current + ",";
- }
- } else {
- if (id != current) {
- colunmsOrder += current + ",";
- } else {
- before = true;
- }
- }
- }
- sendAjax(null, {"rich:columnsOrder" : colunmsOrder}); // TODO Maybe, event model should be used here.
- }
-
- this.setColumnWidth = function(id, width) {
- setColumnWidth(id, width);
- }
-
- this.filter = function(colunmId, filterValue, isClear) {
- if (typeof(filterValue) == "undefined" || filterValue == null) {
- filterValue = "";
- }
- var map = {}
- map[id + "rich:filtering"] = colunmId + ":" + filterValue + ":" + isClear;
- sendAjax(null, map); // TODO Maybe, event model should be used here.
- }
-
- this.clearFiltering = function() {
- this.filter("", "", true);
- }
-
- this.sort = function(colunmId, sortOrder, isClear) {
- if (typeof(sortOrder) == "string") {
- sortOrder = sortOrder.toUpperCase();
- }
- var map = {}
- map[id + "rich:sorting"] = colunmId + ":" + sortOrder + ":" + isClear;
- sendAjax(null, map); // TODO Maybe, event model should be used here.
- }
-
- this.clearSorting = function() {
- this.filter("", "", true);
- }
- };
-}(window.RichFaces, jQuery));
-
+ });
+
+ var $super = richfaces.ui.ExtendedDataTable.$super;
+}(window.RichFaces, jQuery));
\ No newline at end of file
Modified: branches/RF-9323/ui/iteration/ui/src/test/java/org/richfaces/renderkit/ExtendedDataTableRendererTest.java
===================================================================
--- branches/RF-9323/ui/iteration/ui/src/test/java/org/richfaces/renderkit/ExtendedDataTableRendererTest.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/iteration/ui/src/test/java/org/richfaces/renderkit/ExtendedDataTableRendererTest.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -172,7 +172,7 @@
assertEquals("rf-edt-rord-mkr", table.getElementById("table:rm").getAttribute("class"));
assertEquals("table:wi", table.getElementById("table:wi").getAttribute("name"));
assertTrue(table.getElementsByTagName("script").get(0).getTextContent()
- .contains("RichFaces.ExtendedDataTable"));
+ .contains("RichFaces.ui.ExtendedDataTable"));
}
/**
Modified: branches/RF-9323/ui/misc/ui/src/test/java/org/richfaces/function/RichFunctionTest.java
===================================================================
--- branches/RF-9323/ui/misc/ui/src/test/java/org/richfaces/function/RichFunctionTest.java 2010-12-23 17:16:54 UTC (rev 20786)
+++ branches/RF-9323/ui/misc/ui/src/test/java/org/richfaces/function/RichFunctionTest.java 2010-12-23 17:32:10 UTC (rev 20787)
@@ -112,7 +112,7 @@
@Before
public void setUp() throws Exception {
- environment = MockFacesEnvironment.createEnvironment();
+ environment = MockFacesEnvironment.createNiceEnvironment();
facesContext = environment.getFacesContext();
expect(facesContext.getAttributes()).andStubReturn(new HashMap<Object, Object>());
13 years, 5 months
JBoss Rich Faces SVN: r20786 - in trunk: core/api/src/main/java/org/ajax4jsf/component and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-23 12:16:54 -0500 (Thu, 23 Dec 2010)
New Revision: 20786
Removed:
trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxChildrenEncoder.java
trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxComponent.java
trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxContainerBase.java
trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxDataEncoder.java
trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxSupport.java
trunk/core/api/src/main/java/org/ajax4jsf/context/ViewIdHolder.java
trunk/core/api/src/main/java/org/ajax4jsf/event/
trunk/core/api/src/main/java/org/ajax4jsf/model/KeepAlive.java
trunk/core/api/src/main/java/org/ajax4jsf/renderkit/
trunk/core/impl/src/main/java/org/ajax4jsf/el/
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxChildrenRenderer.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java
Modified:
trunk/core/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
trunk/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
trunk/core/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InputRendererBase.java
Log:
Legacy 3.x code removal
Deleted: trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxChildrenEncoder.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxChildrenEncoder.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxChildrenEncoder.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -1,56 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.component;
-
-import java.io.IOException;
-
-import java.util.Set;
-
-import javax.faces.context.FacesContext;
-
-/**
- * Marker interface for components, have ability to manipulate rendering in case of Ajax responses.
- * Such as ajax-enabled iterator, menus etc
- * @author shura
- *
- */
-public interface AjaxChildrenEncoder {
-
- /**
- * Iterate over all childs of components. If component id contains in list ,
- * or, if list is empty, compotents is submitted form - render it.
- * TODO - Instead of calculate full path for every component, build current Path
- * for componet and send as parameter.
- *
- * @param context -
- * current context
- * @param component -
- * curent faces component.
- * @param ids -
- * list of Id to render.
- * @throws IOException
- */
- public void encodeAjaxChild(FacesContext context, String path, Set<String> ids, Set<String> renderedAreas)
- throws IOException;
-}
Deleted: trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxComponent.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxComponent.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxComponent.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -1,228 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.component;
-
-/**
- * Base Interface for Ajax-enabled acting components.
- * TODO - extend <code>ActionSource</code>???
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/23 20:01:01 $
- *
- */
-public interface AjaxComponent {
- public static final String AJAX_COMPONETT_PARAMETER = AjaxComponent.class.getName() + ".parameter";
-
- /**
- * setter method for property
- * @param new value of String, <code>Collection</code> or array of component's Id , updated in case of Ajax request by parent component. to set
- */
- public abstract void setReRender(Object targetId);
-
- /**
- * @return value or result of valueBinding of String, <code>Collection</code> or array of component's Id , updated in case of Ajax request by parent component.
- */
- public abstract Object getReRender();
-
- /**
- * setter method for property
- * @param new value of String, <code>Collection</code> or array of component's Id , processed at the phases 2-5
- * in the case of Ajax request by parent component. to set
- */
- public abstract void setProcess(Object targetId);
-
- /**
- * @return value or result of valueBinding of String, <code>Collection</code> or array of component's Id , processed at the phases 2-5 in case of Ajax request by parent component.
- */
- public abstract Object getProcess();
-
- /**
- * setter method for property
- * @param new value of ajaxType of control component - link or input to set
- */
-
-// public abstract void setAjaxType(String ajaxType);
-
- /**
- * @return value or result of valueBinding of ajaxType of control component - link or input
- */
-// public abstract String getAjaxType();
-
- /**
- * setter method for property
- * @param new value of Id ( in format of UIComponent.findComponent() call ) of request status indicator to set
- */
- public abstract void setStatus(String status);
-
- /**
- * @return value or result of valueBinding of Id ( in format of UIComponent.findComponent() call ) of request status indicator
- */
- public abstract String getStatus();
-
- /**
- * setter method for property
- * @param new value of Name of JavaScript function, called on complete Ajax request to set
- */
- public abstract void setOncomplete(String oncomplete);
-
- /**
- * @return value or result of valueBinding of Name of JavaScript function, called on complete Ajax request
- */
- public abstract String getOncomplete();
-
- /**
- * @return value or result of valueBinding of Name of JavaScript function, called before updating DOM
- */
- public abstract String getOnbeforedomupdate();
-
- /**
- * setter method for property
- * @param new value of Name of JavaScript function, called before updating DOM to set
- */
- public abstract void setOnbeforedomupdate(String beforeUpdate);
-
- public abstract String getOnbegin();
-
- public abstract void setOnbegin(String onbegin);
-
- /**
- * setter method for property
- * @param new value of custom data translated to oncomplete function by AJAX
- */
- public abstract void setData(Object data);
-
- /**
- * @return value of custom data for translate to oncomplete function by AJAX
- */
- public abstract Object getData();
-
- /**
- * setter method for property
- * @param new value of Submit ( or not ) full form on Ajax action. to set
- */
- public abstract void setLimitRender(boolean submitForm);
-
- /**
- * @return value or result of valueBinding of Submit ( or not ) full form on Ajax action.
- */
- public abstract boolean isLimitRender();
-
- /**
- * setter method for property
- * @param new value of Submit ( or not ) full form on Ajax action. to set
- */
- public abstract void setAjaxSingle(boolean single);
-
- /**
- * @return value or result of valueBinding of Submit ( or not ) full form on Ajax action.
- */
- public abstract boolean isAjaxSingle();
-
- /**
- * Getter for bypassUpdates bean property. Indicate that component must invoke listeners after Process Validators phase
- * and force render response after it - since no values of components will be updated. Can be used to perform validation of client input
- * using server-side validators.
- * @return true if component must force render after validation phase.
- */
- public abstract boolean isBypassUpdates();
-
- /**
- * Setter for bypassUpdates bean property.
- * @param bypass true if component must force render after validation phase.
- */
- public abstract void setBypassUpdates(boolean bypass);
-
- /**
- * Getter for property name of events queue on client side - for avoid to send requests too frequnly ( on key events, for example ), implementation will be generated by
- * componnents-generator
- * @return property value
- */
- public abstract String getEventsQueue();
-
- /**
- * Setter for flag indicated aborting unfinished ajax requests in queue.
- * @param newvalue - new property value. If true, unfinished request in queue will be aborted on new events.
- */
- public abstract void setIgnoreDupResponses(boolean newvalue);
-
- /**
- * Getter for property flag indicated aborting unfinished ajax requests in queue.
- * componnents-generator
- * @return property value
- */
- public abstract boolean isIgnoreDupResponses();
-
- /**
- * Setter for property name of events queue on client side - for avoid to send requests too frequnly ( on key events, for example ), implementation will be generated by
- * componnents-generator
- * @param newvalue - new property value
- */
- public abstract void setEventsQueue(String newvalue);
-
- /**
- * Getter for property Delay ( in ms. ) for send ajax request on JavaScript event. In conjunction with events queue can reduce number of requests on keyboard or mouse move events., implementation will be generated by
- * componnents-generator
- * @return property value
- */
- public abstract int getRequestDelay();
-
- /**
- * Setter for property Delay ( in ms. ) for send ajax request on JavaScript event. In conjunction with events queue can reduce number of requests on keyboard or mouse move events., implementation will be generated by
- * componnents-generator
- * @param newvalue - new property value
- */
- public abstract void setRequestDelay(int newvalue);
-
- /**
- * Getter for request timeout
- * @return timeout in ms.
- */
- public abstract int getTimeout();
-
- /**
- * Setter for request timeout
- * @param timeout new value in ms.
- */
- public abstract void setTimeout(int timeout);
-
- /**
- * Setter for a 'focus' bean property - id of component( or of DOM element ), to set focus after AJAX request.
- * @param focus
- */
- public abstract void setFocus(String focus);
-
- /**
- * @return
- */
- public abstract String getFocus();
-
- /**
- *
- */
- public abstract void setSimilarityGroupingId(String similarityGroupingId);
-
- /**
- *
- */
- public abstract String getSimilarityGroupingId();
-}
Deleted: trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxContainerBase.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxContainerBase.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxContainerBase.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -1,87 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.component;
-
-import javax.el.MethodExpression;
-
-/**
- * Base interface for controller component, managed AJAX Requests.
- * Component, implemented this interface, must always return <code>true</code> for
- * <code>javax.faces.component.UIComponent#getRendersChildren()</code> method.
- * in common, set of components, rendered of current request, maintain by it.
- * TODO - add capabilites for components, rendered in <code>PhaseListener</code>
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/06 16:23:20 $
- *
- */
-public interface AjaxContainerBase {
-
- /**
- * getter for AjaxListener method. Same as for <code>ActionSource</code>
- *
- * @see javax.faces.component.ActionSource#getActionListener()
- */
- public MethodExpression getAjaxListener();
-
- /**
- * setter for AjaxListener <code>MethodBinding</code>
- * in case on AjaxRequest, component must call this method in
- * <code>PhaseId.APPLY_REQUEST_VALUES</code> or
- * <code>PhaseId.INVOKE_APPLICATION</code> phases, depend on immediate flag.
- *
- * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
- */
- public void setAjaxListener(MethodExpression ajaxListener);
-
- /**
- * getter for flag immediate call Listener's on PhaseId.APPLY_REQUEST_VALUES phase.
- *
- * @see javax.faces.component.ActionSource#isImmediate()
- */
- public boolean isImmediate();
-
- /**
- * getter for render method flag of subview. If true, on AJAX-request component render it children
- * after {@link com.sun.faces.lifecycle.Phase.INVOKE_APPLICATION }
- * @return value of selfRendered flag
- */
- public boolean isSelfRendered();
-
- /**
- * setter for self-render flag.
- * @param selfRendered
- */
- public void setSelfRendered(boolean selfRendered);
-
- /**
- * setter for immediate flag.
- *
- * @see javax.faces.component.ActionSource#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate);
-
- public boolean isSubmitted();
-
- public void setSubmitted(boolean submitted);
-}
Deleted: trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxDataEncoder.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxDataEncoder.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxDataEncoder.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -1,42 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.component;
-
-import java.util.Set;
-
-/**
- * Interface for iterable component, allowed for render given set of rows in ajax response.
- * @author shura
- *
- */
-public interface AjaxDataEncoder extends AjaxChildrenEncoder {
-
- /**
- * @return Set for values of {@link org.ajax4jsf.model.ExtendedDataModel} keys, encoded in ajax response by
- * this component.
- */
- public Set<Object> getAjaxKeys();
-
- public void setAjaxKeys(Set<Object> ajaxKeys);
-}
Deleted: trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxSupport.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxSupport.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxSupport.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -1,88 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.component;
-
-import javax.faces.component.UIComponent;
-
-/**
- * Version of {@link org.ajax4jsf.component.AjaxComponent} for append
- * Ajax functions for non-ajax components
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:34 $
- *
- */
-public interface AjaxSupport {
-
- /**
- * @return JavaScript eventString. Rebuild on every call, since
- * can be in loop ( as in dataTable ) with different parameters.
- */
- public String getEventString();
-
- /**
- * setter method for property
- * @param new value of Name of event property of parent component for build JavaScript AJAX.Submit call to set
- */
- public abstract void setEvent(String event);
-
- /**
- * @return value or result of valueBinding of Name of event property of parent component for build JavaScript AJAX.Submit call
- */
- public abstract String getEvent();
-
- /**
- * Name of JavaScript function, called before submit Ajax request
- * description
- *
- * @parameter
- * @return the acceptClass
- */
- public abstract String getOnsubmit();
-
- /**
- * @param newOnsubmit
- * the value to set
- */
- public abstract void setOnsubmit(String newOnsubmit);
-
- /**
- * Getter for property If true, disable default action for target event ( encode 'return false' to JavaScript ), implementation will be generated by
- * componnents-generator
- * @return property value
- */
- public abstract boolean isDisableDefault();
-
- /**
- * Setter for property If true, disable default action for target event ( encode 'return false' to JavaScript ), implementation will be generated by
- * componnents-generator
- * @param newvalue - new property value
- */
- public abstract void setDisableDefault(boolean newvalue);
-
- /**
- * Set property for JavaScrept event generated by this component.
- * @param parent
- */
- public void setParentProperties(UIComponent parent);
-}
Modified: trunk/core/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -69,10 +69,6 @@
public abstract Object getOnbeforedomupdate();
- public abstract void setViewIdHolder(ViewIdHolder viewIdHolder);
-
- public abstract ViewIdHolder getViewIdHolder();
-
public abstract boolean removeRenderedArea(String id);
public abstract void addRenderedArea(String id);
Deleted: trunk/core/api/src/main/java/org/ajax4jsf/context/ViewIdHolder.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/context/ViewIdHolder.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/api/src/main/java/org/ajax4jsf/context/ViewIdHolder.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.context;
-
-/**
- * Interface to skip navigation cases in ViewHandler and , instead, store new ViewId.
- * @author shura
- *
- */
-public interface ViewIdHolder {
- public boolean skipNavigation(String viewId);
-
- public String getViewId();
-
- public void setViewId(String newViewId);
-}
Deleted: trunk/core/api/src/main/java/org/ajax4jsf/model/KeepAlive.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/model/KeepAlive.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/api/src/main/java/org/ajax4jsf/model/KeepAlive.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -1,49 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.model;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marker annotation, to keep request-scope beans between requests in the view state.
- * @author asmirnov
- *
- */
-(a)Target(ElementType.TYPE)
-(a)Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface KeepAlive {
-
- /**
- * Boolean attribute indicating whether kept beans are accessible for all requests or AJAX-only.
- *
- * @return
- * @since 3.2.2
- */
- boolean ajaxOnly() default false;
-}
Modified: trunk/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -34,7 +34,6 @@
import javax.faces.context.FacesContext;
import javax.faces.context.PartialResponseWriter;
-import org.ajax4jsf.component.AjaxComponent;
import org.ajax4jsf.context.AjaxContext;
import org.richfaces.application.ServiceTracker;
import org.richfaces.renderkit.AjaxDataSerializer;
@@ -181,14 +180,7 @@
* @return List of areas Id's , updated by this component.
*/
public static Set<String> getAjaxAreas(UIComponent uiComponent) {
- Object areas;
-
- if (uiComponent instanceof AjaxComponent) {
- areas = ((AjaxComponent) uiComponent).getReRender();
- } else {
- areas = uiComponent.getAttributes().get(AJAX_REGIONS_ATTRIBUTE);
- }
-
+ Object areas = uiComponent.getAttributes().get(AJAX_REGIONS_ATTRIBUTE);
return asIdsSet(areas);
}
@@ -200,14 +192,8 @@
* @since 3.3.0
*/
public static Set<String> getAjaxAreasToProcess(UIComponent component) {
- Object areas;
+ Object areas = component.getAttributes().get(AJAX_PROCESS_ATTRIBUTE);
- if (component instanceof AjaxComponent) {
- areas = ((AjaxComponent) component).getProcess();
- } else {
- areas = component.getAttributes().get(AJAX_PROCESS_ATTRIBUTE);
- }
-
return asIdsSet(areas);
}
@@ -277,15 +263,11 @@
public static boolean isAjaxLimitRender(UIComponent component) {
boolean result = false;
- if (component instanceof AjaxComponent) {
- result = ((AjaxComponent) component).isLimitRender();
+ Object limitRenderObject = component.getAttributes().get(LIMITRENDER_ATTR_NAME);
+ if (limitRenderObject instanceof Boolean) {
+ result = ((Boolean) limitRenderObject).booleanValue();
} else {
- Object limitRenderObject = component.getAttributes().get(LIMITRENDER_ATTR_NAME);
- if (limitRenderObject instanceof Boolean) {
- result = ((Boolean) limitRenderObject).booleanValue();
- } else {
- result = Boolean.valueOf(String.valueOf(limitRenderObject));
- }
+ result = Boolean.valueOf(String.valueOf(limitRenderObject));
}
return result;
@@ -300,10 +282,6 @@
*/
//TODO nick - refactor - remove this method?
public static String getAjaxOncomplete(UIComponent component) {
- if (component instanceof AjaxComponent) {
- return ((AjaxComponent) component).getOncomplete();
- }
-
return (String) component.getAttributes().get(ONCOMPLETE_ATTR_NAME);
}
@@ -315,10 +293,6 @@
*/
//TODO nick - refactor - remove this method?
public static String getAjaxOnBeforeDomUpdate(UIComponent component) {
- if (component instanceof AjaxComponent) {
- return ((AjaxComponent) component).getOnbeforedomupdate();
- }
-
return (String) component.getAttributes().get(ONBEFOREDOMUPDATE_ATTR_NAME);
}
@@ -328,10 +302,6 @@
* @since 4.0
*/
public static Object getAjaxData(UIComponent component) {
- if (component instanceof AjaxComponent) {
- return ((AjaxComponent) component).getData();
- }
-
return component.getAttributes().get(DATA_ATTR_NAME);
}
Modified: trunk/core/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- trunk/core/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/core/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -76,7 +76,6 @@
Object onbeforedomupdate = null;
boolean selfRender = false;
String submittedRegionClientId = null;
- ViewIdHolder viewIdHolder = null;
Integer viewSequence = new Integer(1);
Map<String, Object> responseComponentDataMap = new HashMap<String, Object>();
Map<String, Object> commonAjaxParameters = new HashMap<String, Object>();
@@ -90,7 +89,6 @@
selfRender = false;
viewSequence = new Integer(1);
submittedRegionClientId = null;
- viewIdHolder = null;
responseComponentDataMap = new HashMap<String, Object>();
commonAjaxParameters = new HashMap<String, Object>();
responseData = null;
@@ -388,20 +386,6 @@
}
/**
- * @return the vievIdHolder
- */
- public ViewIdHolder getViewIdHolder() {
- return viewIdHolder;
- }
-
- /**
- * @param viewIdHolder the vievIdHolder to set
- */
- public void setViewIdHolder(ViewIdHolder viewIdHolder) {
- this.viewIdHolder = viewIdHolder;
- }
-
- /**
* @return the responseData
*/
public Object getResponseData() {
Deleted: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxChildrenRenderer.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxChildrenRenderer.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxChildrenRenderer.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -1,222 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.AjaxChildrenEncoder;
-import org.ajax4jsf.component.AjaxOutput;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.AjaxRenderer;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-
-/**
- * @author shura
- */
-public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase implements AjaxRenderer {
- public static final String[] SPECIAL_COMPONENTS_TYPES = {"org.ajax4jsf.Bundle" /* UILoadBundle.COMPONENT_TYPE */,
- "org.apache.myfaces.AliasBean", "org.apache.myfaces.AliasBeansScope"};
-
- private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
- private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
-
- private Set<String> specialComponentTypes = null;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxChildren(javax.faces.context
- * .FacesContext, javax.faces.component.UIComponent, java.lang.String,
- * java.util.Set, java.util.Set)
- */
- public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set<String> ids,
- Set<String> renderedAreas) throws IOException {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO, path, component.getId()));
- }
-
- String currentPath = path;
-
- if (component instanceof NamingContainer) {
- currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
-
- // Do not check children if we have no id to render under naming
- // container.
- if (AjaxContext.getCurrentInstance(context).isLimitRender() && noIdUnderPath(path, ids)) {
- return;
- }
- }
-
- for (Iterator<UIComponent> it = component.getFacetsAndChildren(); it.hasNext();) {
- UIComponent element = (UIComponent) it.next();
-
- encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
- }
- }
-
- private boolean noIdUnderPath(String path, Set<String> ids) {
-
- // Do we have an any component for the rendering under that container ?
- boolean noSuchId = true;
-
- for (String id : ids) {
- if ((null != id) && id.startsWith(path)) {
- noSuchId = false;
-
- break;
- }
- }
-
- return noSuchId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxComponent(javax.faces.context
- * .FacesContext, javax.faces.component.UIComponent, java.lang.String,
- * java.util.Set, java.util.Set)
- */
- public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set<String> ids,
- Set<String> renderedAreas) throws IOException {
-
- if (component.isRendered()) { // skip not-rendered components.
- boolean found = false;
- boolean limitRender = AjaxContext.getCurrentInstance(context).isLimitRender();
- String elementId = component.getId();
- String absoluteId = currentPath + elementId;
-
- if (!ids.isEmpty()) {
-
- // list for rendering may contains absolute id ( best ),
- // component Id or client ID
- // String clientId = element.getClientId(context);
- if (ids.contains(absoluteId) || ids.contains(elementId)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.RENDER_AJAX_AREA_INFO, absoluteId));
- }
-
- // renderChild(context, element);
- found = true;
- }
- }
-
- //
- if (!found && limitRender && (component instanceof NamingContainer)
- && noIdUnderPath(absoluteId + NamingContainer.SEPARATOR_CHAR, ids)) {
- return;
- }
-
- if (!found && !limitRender && (component instanceof AjaxOutput)) {
- if (((AjaxOutput) component).isAjaxRendered()) {
-
- // renderChild(context, element);
- found = true;
- }
- }
-
- if (!found) {
- if (component instanceof AjaxChildrenEncoder) {
- ((AjaxChildrenEncoder) component).encodeAjaxChild(context, currentPath, ids, renderedAreas);
- } else {
-
- // Special case - for control components, not produced
- // html code - such as message bundles loaders,
- // MyFaces aliases etc. we call encodeBegin/end methods
- // even if components not in rendered areas.
- boolean special = isSpecialElement(context, component);
-
- if (special) {
- component.encodeBegin(context);
- }
-
- encodeAjaxChildren(context, component, currentPath, ids, renderedAreas);
-
- if (special) {
- component.encodeEnd(context);
- }
- }
- } else {
- renderedAreas.add(component.getClientId(context));
- component.encodeAll(context);
- }
- }
- }
-
- /**
- * Detect component as special control case - such as messages bundle
- * loader, alias bean components etc. Type of component get by reflection
- * from static field COMPONENT_TYPE
- *
- * @param context
- * @param component
- * @return true if encode methods must be called for this component even in
- * not-rendered parts.
- */
- private boolean isSpecialElement(FacesContext context, UIComponent component) {
- if (specialComponentTypes == null) {
- specialComponentTypes = new HashSet<String>(10);
-
- for (int i = 0; i < SPECIAL_COMPONENTS_TYPES.length; i++) {
- specialComponentTypes.add(SPECIAL_COMPONENTS_TYPES[i]);
- }
-
- String special = context.getExternalContext().getInitParameter(SPECIAL_TYPES_PARAMETER);
-
- if (null != special) {
- String[] split = special.split(",");
-
- for (int i = 0; i < split.length; i++) {
- specialComponentTypes.add(split[i]);
- }
- }
- }
-
- boolean result;
-
- try {
- String componentType = (String) component.getClass().getField("COMPONENT_TYPE").get(null);
-
- result = specialComponentTypes.contains(componentType);
- } catch (Exception e) {
-
- // exception occurs if component not have accesible COMPONENT_TYPE
- // constant
- // we assume that component not in special types.
- result = false;
- }
-
- return result;
- }
-}
Deleted: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-
-/**
- * Base class for all Ajax enabled components. Perform common task -
- * output javasript for component.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:49 $
- */
-public abstract class AjaxComponentRendererBase extends RendererBase {
-}
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -28,7 +28,6 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.component.AjaxComponent;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
@@ -564,30 +563,7 @@
* @return clientId of status area, or <code>null</code>
*/
public static String getAjaxStatus(UIComponent component) {
- String statusId;
-
- if (component instanceof AjaxComponent) {
- statusId = ((AjaxComponent) component).getStatus();
- } else {
- statusId = (String) component.getAttributes().get(STATUS_ATTR_NAME);
- }
-
- return statusId;
-
-// if (null != statusId) {
-// UIComponent status = RendererUtils.getInstance().
-// findComponentFor(component, statusId);
-//
-// if (null != status) {
-// statusId = status
-// .getClientId(FacesContext.getCurrentInstance());
-// } else {
-// LOG.warn(Messages.getMessage(
-// Messages.AJAX_STATUS_COMPONENT_NOT_FOWND_WARNING,
-// component.getId()));
-// }
-// }
-// return statusId;
+ return (String) component.getAttributes().get(STATUS_ATTR_NAME);
}
public static String getQueueId(UIComponent component) {
@@ -612,10 +588,6 @@
//TODO nick - refactor - remove this method?
public static String getAjaxOnBegin(UIComponent component) {
- if (component instanceof AjaxComponent) {
- return ((AjaxComponent) component).getOnbegin();
- }
-
return (String) component.getAttributes().get(ONBEGIN_ATTR_NAME);
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InputRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InputRendererBase.java 2010-12-23 17:08:07 UTC (rev 20785)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InputRendererBase.java 2010-12-23 17:16:54 UTC (rev 20786)
@@ -22,20 +22,21 @@
package org.richfaces.renderkit;
-import org.richfaces.component.util.SelectUtils;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
-import java.util.Map;
+import org.richfaces.component.util.SelectUtils;
+
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 23.01.2007
*/
-public class InputRendererBase extends AjaxComponentRendererBase {
+public class InputRendererBase extends RendererBase {
protected void doDecode(FacesContext context, UIComponent component) {
String clientId = component.getClientId(context);
13 years, 5 months
JBoss Rich Faces SVN: r20785 - in trunk/ui/input/ui/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-12-23 12:08:07 -0500 (Thu, 23 Dec 2010)
New Revision: 20785
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java
trunk/ui/input/ui/src/main/templates/calendar.template.xml
Log:
RF-9482 rich:calendar backed by String not using custom converter
- unused comment was removed in calendar.template.xml
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java 2010-12-23 17:02:11 UTC (rev 20784)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java 2010-12-23 17:08:07 UTC (rev 20785)
@@ -53,25 +53,22 @@
if (date == null) {
return null;
}
-
Date value = null;
-
+ Converter converter = calendar.getConverter();
+ if (converter == null) {
+ Application application = facesContext.getApplication();
+ converter = application.createConverter(date.getClass());
+ }
if (date instanceof Date) {
value = (Date) date;
- } else if (date instanceof String) {
- value = convertStringToDate(facesContext, calendar, (String) date);
} else if (date instanceof Calendar) {
value = ((Calendar) date).getTime();
- } else {
- Converter converter = calendar.getConverter();
- if (converter == null) {
- Application application = facesContext.getApplication();
- converter = application.createConverter(date.getClass());
- if (converter == null) {
- throw new FacesException("Wrong attibute type or there is no converter for custom attibute type");
- }
- }
+ } else if (converter != null){
value = convertStringToDate(facesContext, calendar, converter.getAsString(facesContext, calendar, date));
+ } else if (date instanceof String) {
+ value = convertStringToDate(facesContext, calendar, (String) date);
+ } else {
+ throw new FacesException("Wrong attibute type or there is no converter for custom attibute type");
}
return value;
Modified: trunk/ui/input/ui/src/main/templates/calendar.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/calendar.template.xml 2010-12-23 17:02:11 UTC (rev 20784)
+++ trunk/ui/input/ui/src/main/templates/calendar.template.xml 2010-12-23 17:08:07 UTC (rev 20785)
@@ -86,7 +86,7 @@
new RichFaces.ui.Calendar("#{clientId}", "#{getAsLocale(facesContext, component).toString()}",
#{toScriptArgs(options)}).load(#{writePreloadBody(facesContext, component)});
- --></script>
+ </script>
</span>
</span>
</cc:implementation>
13 years, 5 months
JBoss Rich Faces SVN: r20784 - trunk/core/impl/src/main/java/org/ajax4jsf/resource/image.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-23 12:02:11 -0500 (Thu, 23 Dec 2010)
New Revision: 20784
Removed:
trunk/core/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java
Log:
Legacy 3.x code removal
Deleted: trunk/core/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java
===================================================================
--- trunk/core/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java 2010-12-23 16:50:19 UTC (rev 20783)
+++ trunk/core/impl/src/main/java/org/ajax4jsf/resource/image/ImageInfo.java 2010-12-23 17:02:11 UTC (rev 20784)
@@ -1,1443 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-/*
-* ImageInfo.java
-*
-* Version 1.5
-*
-* A Java class to determine image width, height and color depth for
-* a number of image file formats.
-*
-* Written by Marco Schmidt
-* <http://www.geocities.com/marcoschmidt.geo/contact.html>.
-*
-* Contributed to the Public Domain.
-*
-* Last modification 2004-02-29
-*/
-package org.ajax4jsf.resource.image;
-
-import org.ajax4jsf.Messages;
-
-import java.io.DataInput;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Vector;
-
-/**
- * Get file format, image resolution, number of bits per pixel and optionally
- * number of images, comments and physical resolution from
- * JPEG, GIF, BMP, PCX, PNG, IFF, RAS, PBM, PGM, PPM, PSD and SWF files
- * (or input streams).
- * <p/>
- * Use the class like this:
- * <pre>
- * ImageInfo ii = new ImageInfo();
- * ii.setInput(in); // in can be InputStream or RandomAccessFile
- * ii.setDetermineImageNumber(true); // default is false
- * ii.setCollectComments(true); // default is false
- * if (!ii.check()) {
- * System.err.println("Not a supported image file format.");
- * return;
- * }
- * System.out.println(ii.getFormatName() + ", " + ii.getMimeType() +
- * ", " + ii.getWidth() + " x " + ii.getHeight() + " pixels, " +
- * ii.getBitsPerPixel() + " bits per pixel, " + ii.getNumberOfImages() +
- * " image(s), " + ii.getNumberOfComments() + " comment(s).");
- * // there are other properties, check out the API documentation
- * </pre>
- * You can also use this class as a command line program.
- * Call it with a number of image file names and URLs as parameters:
- * <pre>
- * java ImageInfo *.jpg *.png *.gif http://somesite.tld/image.jpg
- * </pre>
- * or call it without parameters and pipe data to it:
- * <pre>
- * java ImageInfo < image.jpg
- * </pre>
- * <p/>
- * Known limitations:
- * <ul>
- * <li>When the determination of the number of images is turned off, GIF bits
- * per pixel are only read from the global header.
- * For some GIFs, local palettes change this to a typically larger
- * value. To be certain to get the correct color depth, call
- * setDetermineImageNumber(true) before calling check().
- * The complete scan over the GIF file will take additional time.</li>
- * <li>Transparency information is not included in the bits per pixel count.
- * Actually, it was my decision not to include those bits, so it's a feature! ;-)</li>
- * </ul>
- * <p/>
- * Requirements:
- * <ul>
- * <li>Java 1.1 or higher</li>
- * </ul>
- * <p/>
- * The latest version can be found at <a href="http://www.geocities.com/marcoschmidt.geo/image-info.html">
- * http://www.geocities.com/marcoschmidt.geo/image-info.html</a>.
- * <p/>
- * Written by <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">Marco Schmidt</a>.
- * <p/>
- * This class is contributed to the Public Domain.
- * Use it at your own risk.
- * <p/>
- * Last modification 2004-02-29.
- * <p/>
- * History:
- * <ul>
- * <li><strong>2001-08-24</strong> Initial version.</li>
- * <li><strong>2001-10-13</strong> Added support for the file formats BMP and PCX.</li>
- * <li><strong>2001-10-16</strong> Fixed bug in read(int[], int, int) that returned
- * <li><strong>2002-01-22</strong> Added support for file formats Amiga IFF and Sun Raster (RAS).</li>
- * <li><strong>2002-01-24</strong> Added support for file formats Portable Bitmap / Graymap / Pixmap (PBM, PGM, PPM)
- * and Adobe Photoshop (PSD).
- * Added new method getMimeType() to return the MIME type associated with a particular file format.</li>
- * <li><strong>2002-03-15</strong> Added support to recognize number of images in file. Only works with GIF.
- * Use {@link #setDetermineImageNumber} with <code>true</code> as argument to identify animated GIFs
- * ({@link #getNumberOfImages()} will return a value larger than <code>1</code>).</li>
- * <li><strong>2002-04-10</strong> Fixed a bug in the feature 'determine number of images in animated GIF' introduced
- * with version 1.1.
- * Thanks to Marcelo P. Lima for sending in the bug report.
- * Released as 1.1.1.</li>
- * <li><strong>2002-04-18</strong> Added {@link #setCollectComments(boolean)}.
- * That new method lets the user specify whether textual comments are to be
- * stored in an internal list when encountered in an input image file / stream.
- * Added two methods to return the physical width and height of the image in dpi:
- * {@link #getPhysicalWidthDpi()} and {@link #getPhysicalHeightDpi()}.
- * If the physical resolution could not be retrieved, these methods return <code>-1</code>.
- * </li>
- * <li><strong>2002-04-23</strong> Added support for the new properties physical resolution and
- * comments for some formats. Released as 1.2.</li>
- * <li><strong>2002-06-17</strong> Added support for SWF, sent in by Michael Aird.
- * Changed checkJpeg() so that other APP markers than APP0 will not lead to a failure anymore.
- * Released as 1.3.</li>
- * <li><strong>2003-07-28</strong> Bug fix - skip method now takes return values into consideration.
- * Less bytes than necessary may have been skipped, leading to flaws in the retrieved information in some cases.
- * Thanks to Bernard Bernstein for pointing that out.
- * Released as 1.4.</li>
- * <li><strong>2004-02-29</strong> Added support for recognizing progressive JPEG and
- * interlaced PNG and GIF. A new method {@link #isProgressive()} returns whether ImageInfo
- * has found that the storage type is progressive (or interlaced).
- * Thanks to Joe Germuska for suggesting the feature.
- * Bug fix: BMP physical resolution is now correctly determined.
- * Released as 1.5.</li>
- * </ul>
- */
-public class ImageInfo {
- public static final int COLOR_TYPE_BLACK_AND_WHITE = 3;
- public static final int COLOR_TYPE_GRAYSCALE = 2;
- public static final int COLOR_TYPE_PALETTED = 1;
- public static final int COLOR_TYPE_TRUECOLOR_RGB = 0;
- public static final int COLOR_TYPE_UNKNOWN = -1;
-
- /**
- * Return value of {@link #getFormat()} for BMP streams.
- * BMP only supports one image per file.
- * BMP does not allow for comments.
- * The physical resolution can be stored.
- */
- public static final int FORMAT_BMP = 3;
-
- /**
- * Return value of {@link #getFormat()} for GIF streams.
- * ImageInfo can extract comments from GIFs and count the number
- * of images (GIFs with more than one image are animations).
- * If you know of a place where GIFs store the physical resolution
- * of an image, please
- * <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">send me a mail</a>!
- * It is determined whether the GIF stream is interlaced (see {@link #isProgressive()}).
- */
- public static final int FORMAT_GIF = 1;
-
- /**
- * Return value of {@link #getFormat()} for IFF streams.
- */
- public static final int FORMAT_IFF = 5;
-
- /**
- * Return value of {@link #getFormat()} for JPEG streams.
- * ImageInfo can extract physical resolution and comments
- * from JPEGs (only from APP0 headers).
- * Only one image can be stored in a file.
- * It is determined whether the JPEG stream is progressive
- * (see {@link #isProgressive()}).
- */
- public static final int FORMAT_JPEG = 0;
-
- /**
- * Return value of {@link #getFormat()} for PBM streams.
- */
- public static final int FORMAT_PBM = 7;
-
- /**
- * Return value of {@link #getFormat()} for PCX streams.
- * PCX does not allow for comments or more than one image per file.
- * However, the physical resolution can be stored.
- */
- public static final int FORMAT_PCX = 4;
-
- /**
- * Return value of {@link #getFormat()} for PGM streams.
- */
- public static final int FORMAT_PGM = 8;
-
- /**
- * Return value of {@link #getFormat()} for PNG streams.
- * PNG only supports one image per file.
- * Both physical resolution and comments can be stored with PNG,
- * but ImageInfo is currently not able to extract those.
- * It is determined whether the PNG stream is interlaced (see {@link #isProgressive()}).
- */
- public static final int FORMAT_PNG = 2;
-
- /**
- * Return value of {@link #getFormat()} for PPM streams.
- */
- public static final int FORMAT_PPM = 9;
-
- /**
- * Return value of {@link #getFormat()} for PSD streams.
- */
- public static final int FORMAT_PSD = 10;
-
- /**
- * Return value of {@link #getFormat()} for RAS streams.
- * Sun Raster allows for one image per file only and is not able to
- * store physical resolution or comments.
- */
- public static final int FORMAT_RAS = 6;
-
- /**
- * Return value of {@link #getFormat()} for SWF (Shockwave) streams.
- */
- public static final int FORMAT_SWF = 11;
-
- /**
- * The names of all supported file formats.
- * The FORMAT_xyz int constants can be used as index values for
- * this array.
- */
- private static final String[] FORMAT_NAMES = {
- "JPEG", "GIF", "PNG", "BMP", "PCX", "IFF", "RAS", "PBM", "PGM", "PPM", "PSD", "SWF"
- };
-
- /**
- * The names of the MIME types for all supported file formats.
- * The FORMAT_xyz int constants can be used as index values for
- * this array.
- */
- private static final String[] MIME_TYPE_STRINGS = {
- "image/jpeg", "image/gif", "image/png", "image/bmp", "image/pcx", "image/iff", "image/ras",
- "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", "image/psd",
- "application/x-shockwave-flash"
- };
- private int colorType = COLOR_TYPE_UNKNOWN;
- private boolean collectComments = true;
- private int bitBuf;
- private int bitPos;
- private int bitsPerPixel;
- private Vector comments;
- private boolean determineNumberOfImages;
- private DataInput din;
- private int format;
- private int height;
- private InputStream in;
- private int numberOfImages;
- private int physicalHeightDpi;
- private int physicalWidthDpi;
- private boolean progressive;
- private int width;
-
- private void addComment(String s) {
- if (comments == null) {
- comments = new Vector();
- }
-
- comments.addElement(s);
- }
-
- /**
- * Call this method after you have provided an input stream or file
- * using {@link #setInput(InputStream)} or {@link #setInput(DataInput)}.
- * If true is returned, the file format was known and information
- * on the file's content can be retrieved using the various getXyz methods.
- *
- * @return if information could be retrieved from input
- */
- public boolean check() {
- format = -1;
- width = -1;
- height = -1;
- bitsPerPixel = -1;
- numberOfImages = 1;
- physicalHeightDpi = -1;
- physicalWidthDpi = -1;
- comments = null;
-
- try {
- int b1 = read() & 0xff;
- int b2 = read() & 0xff;
-
- if ((b1 == 0x47) && (b2 == 0x49)) {
- return checkGif();
- } else if ((b1 == 0x89) && (b2 == 0x50)) {
- return checkPng();
- } else if ((b1 == 0xff) && (b2 == 0xd8)) {
- return checkJpeg();
- } else if ((b1 == 0x42) && (b2 == 0x4d)) {
- return checkBmp();
- } else if ((b1 == 0x0a) && (b2 < 0x06)) {
- return checkPcx();
- } else if ((b1 == 0x46) && (b2 == 0x4f)) {
- return checkIff();
- } else if ((b1 == 0x59) && (b2 == 0xa6)) {
- return checkRas();
- } else if ((b1 == 0x50) && (b2 >= 0x31) && (b2 <= 0x36)) {
- return checkPnm(b2 - '0');
- } else if ((b1 == 0x38) && (b2 == 0x42)) {
- return checkPsd();
- } else if ((b1 == 0x46) && (b2 == 0x57)) {
- return checkSwf();
- } else {
- return false;
- }
- } catch (IOException ioe) {
- return false;
- }
- }
-
- private boolean checkBmp() throws IOException {
- byte[] a = new byte[44];
-
- if (read(a) != a.length) {
- return false;
- }
-
- width = getIntLittleEndian(a, 16);
- height = getIntLittleEndian(a, 20);
-
- if ((width < 1) || (height < 1)) {
- return false;
- }
-
- bitsPerPixel = getShortLittleEndian(a, 26);
-
- if ((bitsPerPixel != 1) && (bitsPerPixel != 4) && (bitsPerPixel != 8) && (bitsPerPixel != 16)
- && (bitsPerPixel != 24) && (bitsPerPixel != 32)) {
- return false;
- }
-
- int x = (int) (getIntLittleEndian(a, 36) * 0.0254);
-
- if (x > 0) {
- setPhysicalWidthDpi(x);
- }
-
- int y = (int) (getIntLittleEndian(a, 40) * 0.0254);
-
- if (y > 0) {
- setPhysicalHeightDpi(y);
- }
-
- format = FORMAT_BMP;
-
- return true;
- }
-
- private boolean checkGif() throws IOException {
- final byte[] gifMagic87a = {0x46, 0x38, 0x37, 0x61};
- final byte[] gifMagic89a = {0x46, 0x38, 0x39, 0x61};
- byte[] a = new byte[11]; // 4 from the GIF signature + 7 from the global header
-
- if (read(a) != 11) {
- return false;
- }
-
- if ((!equals(a, 0, gifMagic89a, 0, 4)) && (!equals(a, 0, gifMagic87a, 0, 4))) {
- return false;
- }
-
- format = FORMAT_GIF;
- width = getShortLittleEndian(a, 4);
- height = getShortLittleEndian(a, 6);
-
- int flags = a[8] & 0xff;
-
- bitsPerPixel = ((flags >> 4) & 0x07) + 1;
- progressive = (flags & 0x02) != 0;
-
- if (!determineNumberOfImages) {
- return true;
- }
-
- // skip global color palette
- if ((flags & 0x80) != 0) {
- int tableSize = (1 << ((flags & 7) + 1)) * 3;
-
- skip(tableSize);
- }
-
- numberOfImages = 0;
-
- int blockType;
-
- do {
- blockType = read();
-
- switch (blockType) {
- case 0x2c: // image separator
- {
- if (read(a, 0, 9) != 9) {
- return false;
- }
-
- flags = a[8] & 0xff;
-
- int localBitsPerPixel = (flags & 0x07) + 1;
-
- if (localBitsPerPixel > bitsPerPixel) {
- bitsPerPixel = localBitsPerPixel;
- }
-
- if ((flags & 0x80) != 0) {
- skip((1 << localBitsPerPixel) * 3);
- }
-
- skip(1); // initial code length
-
- int n;
-
- do {
- n = read();
-
- if (n > 0) {
- skip(n);
- } else if (n == -1) {
- return false;
- }
- } while (n > 0);
-
- numberOfImages++;
-
- break;
- }
-
- case 0x21: // extension
- {
- int extensionType = read();
-
- if (collectComments && (extensionType == 0xfe)) {
- StringBuffer sb = new StringBuffer();
- int n;
-
- do {
- n = read();
-
- if (n == -1) {
- return false;
- }
-
- if (n > 0) {
- for (int i = 0; i < n; i++) {
- int ch = read();
-
- if (ch == -1) {
- return false;
- }
-
- sb.append((char) ch);
- }
- }
- } while (n > 0);
- } else {
- int n;
-
- do {
- n = read();
-
- if (n > 0) {
- skip(n);
- } else if (n == -1) {
- return false;
- }
- } while (n > 0);
- }
-
- break;
- }
-
- case 0x3b: // end of file
- break;
-
- default: {
- return false;
- }
- }
- } while (blockType != 0x3b);
-
- return true;
- }
-
- private boolean checkIff() throws IOException {
- byte[] a = new byte[10];
-
- // read remaining 2 bytes of file id, 4 bytes file size
- // and 4 bytes IFF subformat
- if (read(a, 0, 10) != 10) {
- return false;
- }
-
- final byte[] iffRm = {0x52, 0x4d};
-
- if (!equals(a, 0, iffRm, 0, 2)) {
- return false;
- }
-
- int type = getIntBigEndian(a, 6);
-
- if ((type != 0x494c424d) && // type must be ILBM...
- (type != 0x50424d20)) { // ...or PBM
- return false;
- }
-
- // loop chunks to find BMHD chunk
- do {
- if (read(a, 0, 8) != 8) {
- return false;
- }
-
- int chunkId = getIntBigEndian(a, 0);
- int size = getIntBigEndian(a, 4);
-
- if ((size & 1) == 1) {
- size++;
- }
-
- if (chunkId == 0x424d4844) { // BMHD chunk
- if (read(a, 0, 9) != 9) {
- return false;
- }
-
- format = FORMAT_IFF;
- width = getShortBigEndian(a, 0);
- height = getShortBigEndian(a, 2);
- bitsPerPixel = a[8] & 0xff;
-
- return (width > 0) && (height > 0) && (bitsPerPixel > 0) && (bitsPerPixel < 33);
- } else {
- skip(size);
- }
- } while (true);
- }
-
- private boolean checkJpeg() throws IOException {
- byte[] data = new byte[12];
-
- while (true) {
- if (read(data, 0, 4) != 4) {
- return false;
- }
-
- int marker = getShortBigEndian(data, 0);
- int size = getShortBigEndian(data, 2);
-
- if ((marker & 0xff00) != 0xff00) {
- return false; // not a valid marker
- }
-
- if (marker == 0xffe0) { // APPx
- if (size < 14) {
- return false; // APPx header must be >= 14 bytes
- }
-
- if (read(data, 0, 12) != 12) {
- return false;
- }
-
- final byte[] app0Id = {0x4a, 0x46, 0x49, 0x46, 0x00};
-
- if (equals(app0Id, 0, data, 0, 5)) {
-
- // System.out.println("data 7=" + data[7]);
- if (data[7] == 1) {
- setPhysicalWidthDpi(getShortBigEndian(data, 8));
- setPhysicalHeightDpi(getShortBigEndian(data, 10));
- } else if (data[7] == 2) {
- int x = getShortBigEndian(data, 8);
- int y = getShortBigEndian(data, 10);
-
- setPhysicalWidthDpi((int) (x * 2.54f));
- setPhysicalHeightDpi((int) (y * 2.54f));
- }
- }
-
- skip(size - 14);
- } else if (collectComments && (size > 2) && (marker == 0xfffe)) { // comment
- size -= 2;
-
- byte[] chars = new byte[size];
-
- if (read(chars, 0, size) != size) {
- return false;
- }
-
- String comment = new String(chars, "iso-8859-1");
-
- comment = comment.trim();
- addComment(comment);
- } else if ((marker >= 0xffc0) && (marker <= 0xffcf) && (marker != 0xffc4) && (marker != 0xffc8)) {
- if (read(data, 0, 6) != 6) {
- return false;
- }
-
- format = FORMAT_JPEG;
- bitsPerPixel = (data[0] & 0xff) * (data[5] & 0xff);
- progressive = (marker == 0xffc2) || (marker == 0xffc6) || (marker == 0xffca) || (marker == 0xffce);
- width = getShortBigEndian(data, 3);
- height = getShortBigEndian(data, 1);
-
- return true;
- } else {
- skip(size - 2);
- }
- }
- }
-
- private boolean checkPcx() throws IOException {
- byte[] a = new byte[64];
-
- if (read(a) != a.length) {
- return false;
- }
-
- if (a[0] != 1) { // encoding, 1=RLE is only valid value
- return false;
- }
-
- // width / height
- int x1 = getShortLittleEndian(a, 2);
- int y1 = getShortLittleEndian(a, 4);
- int x2 = getShortLittleEndian(a, 6);
- int y2 = getShortLittleEndian(a, 8);
-
- if ((x1 < 0) || (x2 < x1) || (y1 < 0) || (y2 < y1)) {
- return false;
- }
-
- width = x2 - x1 + 1;
- height = y2 - y1 + 1;
-
- // color depth
- int bits = a[1];
- int planes = a[63];
-
- if ((planes == 1) && ((bits == 1) || (bits == 2) || (bits == 4) || (bits == 8))) {
-
- // paletted
- bitsPerPixel = bits;
- } else if ((planes == 3) && (bits == 8)) {
-
- // RGB truecolor
- bitsPerPixel = 24;
- } else {
- return false;
- }
-
- setPhysicalWidthDpi(getShortLittleEndian(a, 10));
- setPhysicalHeightDpi(getShortLittleEndian(a, 10));
- format = FORMAT_PCX;
-
- return true;
- }
-
- private boolean checkPng() throws IOException {
- final byte[] pngMagic = {
- 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a
- };
- byte[] a = new byte[27];
-
- if (read(a) != 27) {
- return false;
- }
-
- if (!equals(a, 0, pngMagic, 0, 6)) {
- return false;
- }
-
- format = FORMAT_PNG;
- width = getIntBigEndian(a, 14);
- height = getIntBigEndian(a, 18);
- bitsPerPixel = a[22] & 0xff;
-
- int colorType = a[23] & 0xff;
-
- if ((colorType == 2) || (colorType == 6)) {
- bitsPerPixel *= 3;
- }
-
- progressive = (a[26] & 0xff) != 0;
-
- return true;
- }
-
- private boolean checkPnm(int id) throws IOException {
- if ((id < 1) || (id > 6)) {
- return false;
- }
-
- final int[] pnmFormats = {FORMAT_PBM, FORMAT_PGM, FORMAT_PPM};
-
- format = pnmFormats[(id - 1) % 3];
-
- boolean hasPixelResolution = false;
- String s;
-
- while (true) {
- s = readLine();
-
- if (s != null) {
- s = s.trim();
- }
-
- if ((s == null) || (s.length() < 1)) {
- continue;
- }
-
- if (s.charAt(0) == '#') { // comment
- if (collectComments && (s.length() > 1)) {
- addComment(s.substring(1));
- }
-
- continue;
- }
-
- if (!hasPixelResolution) { // split "343 966" into width=343, height=966
- int spaceIndex = s.indexOf(' ');
-
- if (spaceIndex == -1) {
- return false;
- }
-
- String widthString = s.substring(0, spaceIndex);
-
- spaceIndex = s.lastIndexOf(' ');
-
- if (spaceIndex == -1) {
- return false;
- }
-
- String heightString = s.substring(spaceIndex + 1);
-
- try {
- width = Integer.parseInt(widthString);
- height = Integer.parseInt(heightString);
- } catch (NumberFormatException nfe) {
- return false;
- }
-
- if ((width < 1) || (height < 1)) {
- return false;
- }
-
- if (format == FORMAT_PBM) {
- bitsPerPixel = 1;
-
- return true;
- }
-
- hasPixelResolution = true;
- } else {
- int maxSample;
-
- try {
- maxSample = Integer.parseInt(s);
- } catch (NumberFormatException nfe) {
- return false;
- }
-
- if (maxSample < 0) {
- return false;
- }
-
- for (int i = 0; i < 25; i++) {
- if (maxSample < (1 << (i + 1))) {
- bitsPerPixel = i + 1;
-
- if (format == FORMAT_PPM) {
- bitsPerPixel *= 3;
- }
-
- return true;
- }
- }
-
- return false;
- }
- }
- }
-
- private boolean checkPsd() throws IOException {
- byte[] a = new byte[24];
-
- if (read(a) != a.length) {
- return false;
- }
-
- final byte[] psdMagic = {0x50, 0x53};
-
- if (!equals(a, 0, psdMagic, 0, 2)) {
- return false;
- }
-
- format = FORMAT_PSD;
- width = getIntBigEndian(a, 16);
- height = getIntBigEndian(a, 12);
-
- int channels = getShortBigEndian(a, 10);
- int depth = getShortBigEndian(a, 20);
-
- bitsPerPixel = channels * depth;
-
- return (width > 0) && (height > 0) && (bitsPerPixel > 0) && (bitsPerPixel <= 64);
- }
-
- private boolean checkRas() throws IOException {
- byte[] a = new byte[14];
-
- if (read(a) != a.length) {
- return false;
- }
-
- final byte[] rasMagic = {0x6a, (byte) 0x95};
-
- if (!equals(a, 0, rasMagic, 0, 2)) {
- return false;
- }
-
- format = FORMAT_RAS;
- width = getIntBigEndian(a, 2);
- height = getIntBigEndian(a, 6);
- bitsPerPixel = getIntBigEndian(a, 10);
-
- return (width > 0) && (height > 0) && (bitsPerPixel > 0) && (bitsPerPixel <= 24);
- }
-
- // Written by Michael Aird.
- private boolean checkSwf() throws IOException {
-
- // get rid of the last byte of the signature, the byte of the version and 4 bytes of the size
- byte[] a = new byte[6];
-
- if (read(a) != a.length) {
- return false;
- }
-
- format = FORMAT_SWF;
-
- int bitSize = (int) readUBits(5);
- int minX = (int) readSBits(bitSize);
- int maxX = (int) readSBits(bitSize);
- int minY = (int) readSBits(bitSize);
- int maxY = (int) readSBits(bitSize);
-
- width = maxX / 20; // cause we're in twips
- height = maxY / 20; // cause we're in twips
- setPhysicalWidthDpi(72);
- setPhysicalHeightDpi(72);
-
- return (width > 0) && (height > 0);
- }
-
- /**
- * Run over String list, return false iff at least one of the arguments
- * equals <code>-c</code>.
- */
- private static boolean determineVerbosity(String[] args) {
- if ((args != null) && (args.length > 0)) {
- for (int i = 0; i < args.length; i++) {
- if ("-c".equals(args[i])) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- private boolean equals(byte[] a1, int offs1, byte[] a2, int offs2, int num) {
- while (num-- > 0) {
- if (a1[offs1++] != a2[offs2++]) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * If {@link #check()} was successful, returns the image's number of bits per pixel.
- * Does not include transparency information like the alpha channel.
- *
- * @return number of bits per image pixel
- */
- public int getBitsPerPixel() {
- return bitsPerPixel;
- }
-
- /**
- * Returns the index'th comment retrieved from the image.
- *
- * @throws IllegalArgumentException if index is smaller than 0 or larger than or equal
- * to the number of comments retrieved
- * @see #getNumberOfComments
- */
- public String getComment(int index) {
- if ((comments == null) || (index < 0) || (index >= comments.size())) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_COMMENT_INDEX, "" + index));
- }
-
- return (String) comments.elementAt(index);
- }
-
- /**
- * If {@link #check()} was successful, returns the image format as one
- * of the FORMAT_xyz constants from this class.
- * Use {@link #getFormatName()} to get a textual description of the file format.
- *
- * @return file format as a FORMAT_xyz constant
- */
- public int getFormat() {
- return format;
- }
-
- /**
- * If {@link #check()} was successful, returns the image format's name.
- * Use {@link #getFormat()} to get a unique number.
- *
- * @return file format name
- */
- public String getFormatName() {
- if ((format >= 0) && (format < FORMAT_NAMES.length)) {
- return FORMAT_NAMES[format];
- } else {
- return "?";
- }
- }
-
- /**
- * If {@link #check()} was successful, returns one the image's vertical
- * resolution in pixels.
- *
- * @return image height in pixels
- */
- public int getHeight() {
- return height;
- }
-
- private int getIntBigEndian(byte[] a, int offs) {
- return (a[offs] & 0xff) << 24 | (a[offs + 1] & 0xff) << 16 | (a[offs + 2] & 0xff) << 8 | a[offs + 3] & 0xff;
- }
-
- private int getIntLittleEndian(byte[] a, int offs) {
- return (a[offs + 3] & 0xff) << 24 | (a[offs + 2] & 0xff) << 16 | (a[offs + 1] & 0xff) << 8 | a[offs] & 0xff;
- }
-
- /**
- * If {@link #check()} was successful, returns a String with the
- * MIME type of the format.
- *
- * @return MIME type, e.g. <code>image/jpeg</code>
- */
- public String getMimeType() {
- if ((format >= 0) && (format < MIME_TYPE_STRINGS.length)) {
- if ((format == FORMAT_JPEG) && progressive) {
- return "image/pjpeg";
- }
-
- return MIME_TYPE_STRINGS[format];
- } else {
- return null;
- }
- }
-
- /**
- * If {@link #check()} was successful and {@link #setCollectComments(boolean)} was called with
- * <code>true</code> as argument, returns the number of comments retrieved
- * from the input image stream / file.
- * Any number >= 0 and smaller than this number of comments is then a
- * valid argument for the {@link #getComment(int)} method.
- *
- * @return number of comments retrieved from input image
- */
- public int getNumberOfComments() {
- if (comments == null) {
- return 0;
- } else {
- return comments.size();
- }
- }
-
- /**
- * Returns the number of images in the examined file.
- * Assumes that <code>setDetermineImageNumber(true);</code> was called before
- * a successful call to {@link #check()}.
- * This value can currently be only different from <code>1</code> for GIF images.
- *
- * @return number of images in file
- */
- public int getNumberOfImages() {
- return numberOfImages;
- }
-
- /**
- * Returns the physical height of this image in dots per inch (dpi).
- * Assumes that {@link #check()} was successful.
- * Returns <code>-1</code> on failure.
- *
- * @return physical height (in dpi)
- * @see #getPhysicalWidthDpi()
- * @see #getPhysicalHeightInch()
- */
- public int getPhysicalHeightDpi() {
- return physicalHeightDpi;
- }
-
- /**
- * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
- * or -1 if no value could be found.
- *
- * @return physical height (in dpi)
- * @see #getPhysicalHeightDpi()
- * @see #getPhysicalWidthDpi()
- * @see #getPhysicalWidthInch()
- */
- public float getPhysicalHeightInch() {
- int h = getHeight();
- int ph = getPhysicalHeightDpi();
-
- if ((h > 0) && (ph > 0)) {
- return ((float) h) / ((float) ph);
- } else {
- return -1.0f;
- }
- }
-
- /**
- * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
- * or -1 if no value could be found.
- *
- * @return physical width (in dpi)
- * @see #getPhysicalHeightDpi()
- * @see #getPhysicalWidthInch()
- * @see #getPhysicalHeightInch()
- */
- public int getPhysicalWidthDpi() {
- return physicalWidthDpi;
- }
-
- /**
- * Returns the physical width of an image in inches, or
- * <code>-1.0f</code> if width information is not available.
- * Assumes that {@link #check} has been called successfully.
- *
- * @return physical width in inches or <code>-1.0f</code> on failure
- * @see #getPhysicalWidthDpi
- * @see #getPhysicalHeightInch
- */
- public float getPhysicalWidthInch() {
- int w = getWidth();
- int pw = getPhysicalWidthDpi();
-
- if ((w > 0) && (pw > 0)) {
- return ((float) w) / ((float) pw);
- } else {
- return -1.0f;
- }
- }
-
- private int getShortBigEndian(byte[] a, int offs) {
- return (a[offs] & 0xff) << 8 | (a[offs + 1] & 0xff);
- }
-
- private int getShortLittleEndian(byte[] a, int offs) {
- return (a[offs] & 0xff) | (a[offs + 1] & 0xff) << 8;
- }
-
- /**
- * If {@link #check()} was successful, returns one the image's horizontal
- * resolution in pixels.
- *
- * @return image width in pixels
- */
- public int getWidth() {
- return width;
- }
-
- /**
- * Returns whether the image is stored in a progressive (also called: interlaced) way.
- *
- * @return true for progressive/interlaced, false otherwise
- */
- public boolean isProgressive() {
- return progressive;
- }
-
- /**
- * To use this class as a command line application, give it either
- * some file names as parameters (information on them will be
- * printed to standard output, one line per file) or call
- * it with no parameters. It will then check data given to it
- * via standard input.
- *
- * @param args the program arguments which must be file names
- */
- public static void main(String[] args) {
- ImageInfo imageInfo = new ImageInfo();
-
- imageInfo.setDetermineImageNumber(true);
-
- boolean verbose = determineVerbosity(args);
-
- if (args.length == 0) {
- run(null, System.in, imageInfo, verbose);
- } else {
- int index = 0;
-
- while (index < args.length) {
- InputStream in = null;
-
- try {
- String name = args[index++];
-
- System.out.print(name + ";");
-
- if (name.startsWith("http://")) {
- in = new URL(name).openConnection().getInputStream();
- } else {
- in = new FileInputStream(name);
- }
-
- run(name, in, imageInfo, verbose);
- in.close();
- } catch (Exception e) {
- System.out.println(e);
-
- try {
- in.close();
- } catch (Exception ee) {
-
- // TODO Refactoring
- }
- }
- }
- }
- }
-
- private static void print(String sourceName, ImageInfo ii, boolean verbose) {
- if (verbose) {
- printVerbose(sourceName, ii);
- } else {
- printCompact(sourceName, ii);
- }
- }
-
- private static void printCompact(String sourceName, ImageInfo imageInfo) {
- System.out.println(imageInfo.getFormatName() + ";" + imageInfo.getMimeType() + ";" + imageInfo.getWidth() + ";"
- + imageInfo.getHeight() + ";" + imageInfo.getBitsPerPixel() + ";"
- + imageInfo.getNumberOfImages() + ";" + imageInfo.getPhysicalWidthDpi() + ";"
- + imageInfo.getPhysicalHeightDpi() + ";" + imageInfo.getPhysicalWidthInch() + ";"
- + imageInfo.getPhysicalHeightInch() + ";" + imageInfo.isProgressive());
- }
-
- private static void printLine(int indentLevels, String text, float value, float minValidValue) {
- if (value < minValidValue) {
- return;
- }
-
- printLine(indentLevels, text, Float.toString(value));
- }
-
- private static void printLine(int indentLevels, String text, int value, int minValidValue) {
- if (value >= minValidValue) {
- printLine(indentLevels, text, Integer.toString(value));
- }
- }
-
- private static void printLine(int indentLevels, String text, String value) {
- if ((value == null) || (value.length() == 0)) {
- return;
- }
-
- while (indentLevels-- > 0) {
- System.out.print("\t");
- }
-
- if ((text != null) && (text.length() > 0)) {
- System.out.print(text);
- System.out.print(" ");
- }
-
- System.out.println(value);
- }
-
- private static void printVerbose(String sourceName, ImageInfo ii) {
- printLine(0, null, sourceName);
- printLine(1, "File format: ", ii.getFormatName());
- printLine(1, "MIME type: ", ii.getMimeType());
- printLine(1, "Width (pixels): ", ii.getWidth(), 1);
- printLine(1, "Height (pixels): ", ii.getHeight(), 1);
- printLine(1, "Bits per pixel: ", ii.getBitsPerPixel(), 1);
- printLine(1, "Progressive: ", Boolean.toString(ii.isProgressive()));
- printLine(1, "Number of images: ", ii.getNumberOfImages(), 1);
- printLine(1, "Physical width (dpi): ", ii.getPhysicalWidthDpi(), 1);
- printLine(1, "Physical height (dpi): ", ii.getPhysicalHeightDpi(), 1);
- printLine(1, "Physical width (inches): ", ii.getPhysicalWidthInch(), 1.0f);
- printLine(1, "Physical height (inches): ", ii.getPhysicalHeightInch(), 1.0f);
-
- int numComments = ii.getNumberOfComments();
-
- printLine(1, "Number of textual comments: ", numComments, 1);
-
- if (numComments > 0) {
- for (int i = 0; i < numComments; i++) {
- printLine(2, null, ii.getComment(i));
- }
- }
- }
-
- private int read() throws IOException {
- if (in != null) {
- return in.read();
- } else {
- return din.readByte();
- }
- }
-
- private int read(byte[] a) throws IOException {
- if (in != null) {
- return in.read(a);
- } else {
- din.readFully(a);
-
- return a.length;
- }
- }
-
- private int read(byte[] a, int offset, int num) throws IOException {
- if (in != null) {
- return in.read(a, offset, num);
- } else {
- din.readFully(a, offset, num);
-
- return num;
- }
- }
-
- private String readLine() throws IOException {
- return readLine(new StringBuffer());
- }
-
- private String readLine(StringBuffer sb) throws IOException {
- boolean finished;
-
- do {
- int value = read();
-
- finished = (value == -1) || (value == 10);
-
- if (!finished) {
- sb.append((char) value);
- }
- } while (!finished);
-
- return sb.toString();
- }
-
- private long readUBits(int numBits) throws IOException {
- if (numBits == 0) {
- return 0;
- }
-
- int bitsLeft = numBits;
- long result = 0;
-
- if (bitPos == 0) { // no value in the buffer - read a byte
- if (in != null) {
- bitBuf = in.read();
- } else {
- bitBuf = din.readByte();
- }
-
- bitPos = 8;
- }
-
- while (true) {
- int shift = bitsLeft - bitPos;
-
- if (shift > 0) {
-
- // Consume the entire buffer
- result |= bitBuf << shift;
- bitsLeft -= bitPos;
-
- // Get the next byte from the input stream
- if (in != null) {
- bitBuf = in.read();
- } else {
- bitBuf = din.readByte();
- }
-
- bitPos = 8;
- } else {
-
- // Consume a portion of the buffer
- result |= bitBuf >> -shift;
- bitPos -= bitsLeft;
- bitBuf &= 0xff >> (8 - bitPos); // mask off the consumed bits
-
- return result;
- }
- }
- }
-
- /**
- * Read a signed value from the given number of bits
- */
- private int readSBits(int numBits) throws IOException {
-
- // Get the number as an unsigned value.
- long uBits = readUBits(numBits);
-
- // Is the number negative?
- if ((uBits & (1L << (numBits - 1))) != 0) {
-
- // Yes. Extend the sign.
- uBits |= -1L << numBits;
- }
-
- return (int) uBits;
- }
-
- private void synchBits() {
- bitBuf = 0;
- bitPos = 0;
- }
-
- private String readLine(int firstChar) throws IOException {
- StringBuffer result = new StringBuffer();
-
- result.append((char) firstChar);
-
- return readLine(result);
- }
-
- private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
- imageInfo.setInput(in);
- imageInfo.setDetermineImageNumber(false);
- imageInfo.setCollectComments(verbose);
-
- if (imageInfo.check()) {
- print(sourceName, imageInfo, verbose);
- }
- }
-
- /**
- * Specify whether textual comments are supposed to be extracted from input.
- * Default is <code>false</code>.
- * If enabled, comments will be added to an internal list.
- *
- * @param newValue if <code>true</code>, this class will read comments
- * @see #getNumberOfComments
- * @see #getComment
- */
- public void setCollectComments(boolean newValue) {
- collectComments = newValue;
- }
-
- /**
- * Specify whether the number of images in a file is to be
- * determined - default is <code>false</code>.
- * This is a special option because some file formats require running over
- * the entire file to find out the number of images, a rather time-consuming
- * task.
- * Not all file formats support more than one image.
- * If this method is called with <code>true</code> as argument,
- * the actual number of images can be queried via
- * {@link #getNumberOfImages()} after a successful call to
- * {@link #check()}.
- *
- * @param newValue will the number of images be determined?
- * @see #getNumberOfImages
- */
- public void setDetermineImageNumber(boolean newValue) {
- determineNumberOfImages = newValue;
- }
-
- /**
- * Set the input stream to the argument stream (or file).
- * Note that {@link java.io.RandomAccessFile} implements
- * {@link java.io.DataInput}.
- *
- * @param dataInput the input stream to read from
- */
- public void setInput(DataInput dataInput) {
- din = dataInput;
- in = null;
- }
-
- /**
- * Set the input stream to the argument stream (or file).
- *
- * @param inputStream the input stream to read from
- */
- public void setInput(InputStream inputStream) {
- in = inputStream;
- din = null;
- }
-
- private void setPhysicalHeightDpi(int newValue) {
- physicalWidthDpi = newValue;
- }
-
- private void setPhysicalWidthDpi(int newValue) {
- physicalHeightDpi = newValue;
- }
-
- private void skip(int num) throws IOException {
- while (num > 0) {
- long result;
-
- if (in != null) {
- result = in.skip(num);
- } else {
- result = din.skipBytes(num);
- }
-
- if (result > 0) {
- num -= result;
- }
- }
- }
-}
13 years, 5 months
JBoss Rich Faces SVN: r20783 - in trunk/core/impl/src: main/resources/META-INF and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-23 11:50:19 -0500 (Thu, 23 Dec 2010)
New Revision: 20783
Removed:
trunk/core/impl/src/main/java/org/ajax4jsf/application/
trunk/core/impl/src/main/java/org/ajax4jsf/cache/
trunk/core/impl/src/main/java/org/ajax4jsf/webapp/
trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/
trunk/core/impl/src/test/java/org/ajax4jsf/renderkit/
trunk/core/impl/src/test/java/org/ajax4jsf/resource/
trunk/core/impl/src/test/java/org/ajax4jsf/util/
Modified:
trunk/core/impl/src/main/resources/META-INF/faces-config.xml
Log:
Legacy 3.x code removal
Modified: trunk/core/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/faces-config.xml 2010-12-23 16:19:44 UTC (rev 20782)
+++ trunk/core/impl/src/main/resources/META-INF/faces-config.xml 2010-12-23 16:50:19 UTC (rev 20783)
@@ -2,11 +2,6 @@
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0">
- <factory>
- <!--
- <lifecycle-factory>org.ajax4jsf.application.DebugLifecycleFactory</lifecycle-factory>
- -->
- </factory>
<application>
<!-- system-event-listener>
<system-event-listener-class>org.ajax4jsf.component.RenderPhaseUIDataAdaptorVisitor</system-event-listener-class>
13 years, 5 months
JBoss Rich Faces SVN: r20782 - in trunk/core/impl/src: main/java/org/ajax4jsf/context and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-23 11:19:44 -0500 (Thu, 23 Dec 2010)
New Revision: 20782
Removed:
trunk/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
trunk/core/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java
trunk/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
trunk/core/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
trunk/core/impl/src/main/java/org/ajax4jsf/renderkit/
trunk/core/impl/src/main/java/org/ajax4jsf/resource/image/package-info.java
trunk/core/impl/src/main/java/org/richfaces/webapp/taglib/
trunk/core/impl/src/main/resources/org/ajax4jsf/javascript/
trunk/core/impl/src/main/resources/org/ajax4jsf/org/
trunk/core/impl/src/main/resources/org/richfaces/renderkit/html/images/
trunk/core/impl/src/main/resources/org/richfaces/renderkit/html/scripts/
trunk/core/impl/src/test/java/org/ajax4jsf/context/
Log:
Legacy 3.x code removal
Deleted: trunk/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
===================================================================
--- trunk/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-12-23 16:14:34 UTC (rev 20781)
+++ trunk/core/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-12-23 16:19:44 UTC (rev 20782)
@@ -1,131 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.context;
-
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-/**
- * This class hold all methods for get application init parameters. Created for
- * single access point to all parameters - simplest for a documentation.
- *
- * @author asmirnov
- */
-public final class ContextInitParameters {
-
- private static final String INIT_PARAM_PREFIX = ContextInitParameters.class.getSimpleName() + ":";
- private static final Object NULL = new Object() {
-
- public String toString() {
- return ContextInitParameters.class.getSimpleName() + ": null Object";
- };
-
- };
-
- /**
- *
- */
- private ContextInitParameters() {
-
- // this is a only static methods for a access to Web app Init
- // parameters. Do not Instantiate !
- }
-
- static int getInteger(FacesContext context, String[] paramNames, int defaultValue) {
- String initParameter = getInitParameter(context, paramNames);
-
- if (null == initParameter) {
- return defaultValue;
- } else {
- try {
- return Integer.parseInt(initParameter);
- } catch (NumberFormatException e) {
- throw new FacesException("Context parameter " + paramNames + " must have integer value");
- }
- }
- }
-
- static String getString(FacesContext context, String[] paramNames, String defaultValue) {
- String initParameter = getInitParameter(context, paramNames);
-
- if (null == initParameter) {
- return defaultValue;
- } else {
- return initParameter;
- }
- }
-
- static boolean getBoolean(FacesContext context, String[] paramNames, boolean defaultValue) {
- String initParameter = getInitParameter(context, paramNames);
-
- if (null == initParameter) {
- return defaultValue;
- } else if ("true".equalsIgnoreCase(initParameter) || "yes".equalsIgnoreCase(initParameter)) {
- return true;
- } else if ("false".equalsIgnoreCase(initParameter) || "no".equalsIgnoreCase(initParameter)) {
- return false;
- } else {
- throw new FacesException("Illegal value [" + initParameter + "] for a init parameter +" + paramNames
- + ", only logical values 'true' or 'false' is allowed");
- }
- }
-
- static String getInitParameter(FacesContext context, String[] paramNames) {
- ExternalContext externalContext = context.getExternalContext();
- String value = null;
-
- for (int i = 0; (i < paramNames.length) && (null == value); i++) {
- value = externalContext.getInitParameter(paramNames[i]);
- }
-
- return value;
- }
-
- private static boolean getBooleanValue(Object value, boolean defaultValue) {
- if (value == null) {
- return defaultValue;
- }
-
- if (value instanceof Boolean) {
- return ((Boolean) value).booleanValue();
- }
-
- String stringValue = (String) value;
-
- return ("true".equalsIgnoreCase(stringValue) || "yes".equalsIgnoreCase(stringValue));
- }
-
- private static Object evaluateInitParameterExpression(FacesContext context, Object parameterValue) {
- if (parameterValue == NULL || parameterValue == null) {
- return null;
- } else if (parameterValue instanceof ValueExpression) {
- ValueExpression expression = (ValueExpression) parameterValue;
-
- return (String) expression.getValue(context.getELContext());
- } else {
- return parameterValue.toString();
- }
- }
-
-}
\ No newline at end of file
Deleted: trunk/core/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java
===================================================================
--- trunk/core/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java 2010-12-23 16:14:34 UTC (rev 20781)
+++ trunk/core/impl/src/main/java/org/ajax4jsf/context/InvokerCallback.java 2010-12-23 16:19:44 UTC (rev 20782)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.context;
-
-import javax.faces.component.ContextCallback;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * Callback Interface
- * for invoke lifecycle methods ( processDecodes, processValidators ... encodeEnd ).
- *
- * @author shura
- */
-public interface InvokerCallback extends ContextCallback {
-
- /**
- * Process method on given component.
- *
- * @param context
- * @param component
- */
- public void invokeContextCallback(FacesContext context, UIComponent component);
-
- /**
- * Default processing on UIVewRoot
- *
- * @param context
- */
- public void invokeRoot(FacesContext context);
-}
Deleted: trunk/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
===================================================================
--- trunk/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2010-12-23 16:14:34 UTC (rev 20781)
+++ trunk/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2010-12-23 16:19:44 UTC (rev 20782)
@@ -1,120 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.context;
-
-import javax.faces.FacesException;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.richfaces.renderkit.HtmlConstants;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-class ResponseWriterContentHandler implements ContentHandler {
- private String linkClass;
- private Node node;
-
- public ResponseWriterContentHandler(String linkClass) {
- super();
-
- try {
- Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
-
- node = document.createElement("head");
- document.appendChild(node);
- } catch (ParserConfigurationException e) {
- throw new FacesException(e.getLocalizedMessage(), e);
- }
-
- this.linkClass = linkClass;
- }
-
- public void characters(char[] ch, int start, int length) throws SAXException {
- node.appendChild(node.getOwnerDocument().createTextNode(new String(ch, start, length)));
- }
-
- public void endDocument() throws SAXException {
- }
-
- public void endElement(String uri, String localName, String name) throws SAXException {
- node = node.getParentNode();
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- throw new UnsupportedOperationException();
- }
-
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- }
-
- public void processingInstruction(String target, String data) throws SAXException {
- throw new UnsupportedOperationException();
- }
-
- public void setDocumentLocator(Locator locator) {
- throw new UnsupportedOperationException();
- }
-
- public void skippedEntity(String name) throws SAXException {
- throw new UnsupportedOperationException();
- }
-
- public void startDocument() throws SAXException {
- }
-
- public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
- Document document = node.getOwnerDocument();
- Element element = document.createElement(localName);
- int length = atts.getLength();
-
- for (int i = 0; i < length; i++) {
- element.setAttribute(atts.getLocalName(i), atts.getValue(i));
- }
-
- if (HtmlConstants.LINK_ELEMENT.equals(localName)) {
- element.setAttribute(HtmlConstants.CLASS_ATTRIBUTE, linkClass);
- }
-
- node = node.appendChild(element);
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- throw new UnsupportedOperationException();
- }
-
- public Node[] getNodes() {
- NodeList childNodes = node.getChildNodes();
- Node[] list = new Node[childNodes.getLength()];
-
- for (int i = 0; i < list.length; i++) {
- list[i] = childNodes.item(i);
- }
-
- return list;
- }
-}
Deleted: trunk/core/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
===================================================================
--- trunk/core/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2010-12-23 16:14:34 UTC (rev 20781)
+++ trunk/core/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2010-12-23 16:19:44 UTC (rev 20782)
@@ -1,593 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.context;
-
-/**
- * @author Nick Belaevski
- */
-
-//TODO remove - https://jira.jboss.org/jira/browse/RFPL-42
-public class ViewResources {
-
-// private static final String INIT_PARAMETER_PREFIX = "_init_parameter_";
-// private static final Object NULL = new Object();
-//
-// private String scriptStrategy;
-//
-// private String styleStrategy;
-//
-// private boolean useStdControlsSkinning;
-//
-// private boolean useStdControlsSkinningClasses;
-//
-// private HeadResponseWriter componentWriter;
-//
-// private HeadResponseWriter userWriter;
-//
-// private RenderKit renderKit;
-//
-// private Node[] headNodes = null;
-//
-// private static final String EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY = ViewResources.class.getName() + "EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY";
-//
-// private static final InternetResource EXTENDED_SKINNING_ON_RESOURCE = new InternetResourceBase() {
-//
-// private final String RESOURCE_KEY = this.getClass().getName();
-//
-// @Override
-// public void encode(FacesContext context, Object data)
-// throws IOException {
-//
-// encode(context, data, Collections.EMPTY_MAP);
-// }
-//
-// @Override
-// public void encode(FacesContext context, Object data,
-// Map<String, Object> attributes) throws IOException {
-//
-// Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-// if (requestMap.get(RESOURCE_KEY) == null) {
-// ResponseWriter writer = context.getResponseWriter();
-// writer.startElement(HTML.SCRIPT_ELEM, null);
-//
-// if (!attributes.containsKey(HTML.TYPE_ATTR)) {
-// writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
-// }
-//
-// for (Map.Entry<String, Object> entry : attributes.entrySet()) {
-// writer.writeAttribute(entry.getKey(), entry.getValue(), null);
-// }
-//
-// writer.writeText("window.RICH_FACES_EXTENDED_SKINNING_ON=true;", null);
-//
-// writer.endElement(HTML.SCRIPT_ELEM);
-//
-// requestMap.put(RESOURCE_KEY, Boolean.TRUE);
-// }
-// }
-// };
-//
-// public void setScriptStrategy(String scriptsStrategy) {
-// this.scriptStrategy = scriptsStrategy;
-// }
-//
-// public void setStyleStrategy(String stylesStrategy) {
-// this.styleStrategy = stylesStrategy;
-// }
-//
-// public void setUseStdControlsSkinning(boolean stdControlsSkinning) {
-// this.useStdControlsSkinning = stdControlsSkinning;
-// }
-//
-// public void setUseStdControlsSkinningClasses(boolean stdControlsSkinningClasses) {
-// this.useStdControlsSkinningClasses = stdControlsSkinningClasses;
-// }
-//
-// public void setExtendedSkinningAllowed(boolean extendedSkinningAllowed) {
-// this.extendedSkinningAllowed = extendedSkinningAllowed;
-// }
-//
-// private static String SCRIPT = HTML.SCRIPT_ELEM;
-// private static String SCRIPT_UC = SCRIPT.toUpperCase(Locale.US);
-//
-// private static String SRC = HTML.SRC_ATTRIBUTE;
-// private static String SRC_UC = SRC.toUpperCase(Locale.US);
-//
-// private void mergeHeadResourceNode(List<Node> nodes, Set<String> renderedScripts, Node node) {
-// boolean shouldAdd = true;
-//
-// String nodeName = node.getNodeName();
-// if (SCRIPT.equals(nodeName) || SCRIPT_UC.equals(nodeName)) {
-// if (node.getFirstChild() == null) {
-// //no text content etc.
-//
-// NamedNodeMap attributes = node.getAttributes();
-// if (attributes != null) {
-// Node item = attributes.getNamedItem(SRC);
-// if (item == null) {
-// attributes.getNamedItem(SRC_UC);
-// }
-//
-// if (item != null) {
-// String src = item.getNodeValue();
-// if (src != null) {
-// if (renderedScripts.contains(src)) {
-// shouldAdd = false;
-// } else {
-// renderedScripts.add(src);
-// }
-// }
-// }
-// }
-// }
-// }
-//
-// if (shouldAdd) {
-// nodes.add(node);
-// }
-// }
-//
-// private Node[] mergeHeadResourceNodes() {
-// List<Node> result = new ArrayList<Node>();
-//
-// Set<String> scripts = new HashSet<String>();
-//
-// for (Node node : componentWriter.getNodes()) {
-// mergeHeadResourceNode(result, scripts, node);
-// }
-//
-// for (Node node : userWriter.getNodes()) {
-// mergeHeadResourceNode(result, scripts, node);
-// }
-//
-// return result.toArray(new Node[result.size()]);
-// }
-//
-// public Node[] getHeadEvents() {
-// if (headNodes == null) {
-// headNodes = mergeHeadResourceNodes();
-// }
-//
-// return headNodes;
-// }
-//
-// private static final Log log = LogFactory.getLog(ViewResources.class);
-//
-// //todo
-//
-// private static final Map<String, Object> EXTENDED_SKINNING = new HashMap<String, Object>(1);
-//
-// static {
-// EXTENDED_SKINNING.put(HTML.MEDIA_ATTRIBUTE, "rich-extended-skinning");
-// }
-//
-// public static final String SKINNING_STYLES_PATH = "/org/richfaces/renderkit/html/css/";
-//
-// public static final String QUEUE_SCRIPT_RESOURCE = "org.ajax4jsf.renderkit.html.scripts.QueueScript";
-//
-// private boolean extendedSkinningAllowed;
-//
-// private boolean processScripts;
-//
-// private boolean processStyles;
-//
-// private boolean useSkinning;
-//
-// private InternetResourceBuilder resourceBuilder;
-//
-// private boolean ajaxRequest;
-//
-// public static final String COMPONENT_RESOURCE_LINK_CLASS = "component";
-//
-// public static final String USER_RESOURCE_LINK_CLASS = "user";
-//
-// class HeadResponseWriter extends SAXResponseWriter {
-//
-// public Node[] getNodes() {
-// return ((ResponseWriterContentHandler) getXmlConsumer()).getNodes();
-// }
-//
-// public HeadResponseWriter(String linkClass) {
-// super(new ResponseWriterContentHandler(linkClass));
-//
-// }
-// }
-//
-// private void encodeResources(FacesContext context, ResourceRenderer renderer, Set<String> set) throws IOException {
-//
-// if (set != null) {
-// URIInternetResource resourceImpl = new URIInternetResource();
-//
-// for (String uri : set) {
-// resourceImpl.setUri(uri);
-// renderer.encode(resourceImpl, context, null);
-// }
-// }
-// }
-//
-// private boolean encodeSkinningResources(FacesContext context, InternetResourceBuilder resourceBuilder) throws IOException, FacesException {
-// String resourceSuffix = null;
-//
-// if (useStdControlsSkinning) {
-// if (useStdControlsSkinningClasses) {
-// resourceSuffix = "_both.xcss";
-// } else {
-// resourceSuffix = ".xcss";
-// }
-// } else {
-// if (useStdControlsSkinningClasses) {
-// resourceSuffix = "_classes.xcss";
-// } else {
-// //no resources
-// }
-// }
-//
-// if (resourceSuffix != null) {
-// resourceBuilder.createResource(
-// this, SKINNING_STYLES_PATH.concat("basic").concat(resourceSuffix)).encode(context, null);
-//
-// if (extendedSkinningAllowed) {
-// resourceBuilder.createResource(
-// this, SKINNING_STYLES_PATH.concat("extended").concat(resourceSuffix)).encode(context, null, EXTENDED_SKINNING);
-// }
-//
-// return true;
-// }
-//
-// return false;
-// }
-//
-// /**
-// * Find renderer for given component.
-// *
-// * @param context
-// * @param comp
-// * @param renderKit
-// * @return
-// */
-// private Renderer getRenderer(FacesContext context, UIComponent comp) {
-//
-// String rendererType = comp.getRendererType();
-// if (rendererType != null) {
-// return (renderKit.getRenderer(comp.getFamily(), rendererType));
-// } else {
-// return (null);
-// }
-// }
-//
-// public void processHeadResources(FacesContext context) throws FacesException {
-//
-// RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
-// .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-// renderKit = rkFactory.getRenderKit(context, context
-// .getViewRoot().getRenderKitId());
-//
-// boolean scriptsOff = false;
-//
-// processStyles = true;
-// processScripts = true;
-// useSkinning = false;
-//
-// ajaxRequest = AjaxContext.getCurrentInstance(context).isAjaxRequest(context);
-//
-// if (log.isDebugEnabled()) {
-// log
-// .debug("Process component tree for collect used scripts and styles");
-// }
-//
-// String skinStyleSheetUri = null;
-// String skinExtendedStyleSheetUri = null;
-//
-// Skin skin = null;
-// try {
-// skin = SkinFactory.getInstance().getSkin(context);
-// // For a "NULL" skin, do not collect components stylesheets
-// if ("false".equals(skin.getParameter(context,
-// Skin.LOAD_STYLE_SHEETS))) {
-// processStyles = false;
-// }
-// // Set default style sheet for current skin.
-// skinStyleSheetUri = (String) skin.getParameter(context,
-// Skin.GENERAL_STYLE_SHEET);
-// // Set default style sheet for current skin.
-// skinExtendedStyleSheetUri = (String) skin.getParameter(context,
-// Skin.EXTENDED_STYLE_SHEET);
-// } catch (SkinNotFoundException e) {
-// if (log.isWarnEnabled()) {
-// log.warn("Current Skin is not found", e);
-// }
-// }
-//
-// resourceBuilder = InternetResourceBuilder.getInstance();
-//
-// ResponseWriter oldResponseWriter = context.getResponseWriter();
-//
-// componentWriter = new HeadResponseWriter("component");
-// userWriter = new HeadResponseWriter("user");
-//
-// try {
-// componentWriter.startDocument();
-// userWriter.startDocument();
-//
-// context.setResponseWriter(componentWriter);
-//
-// // Check init parameters for a resources processing.
-// if (null != scriptStrategy) {
-// if (InternetResourceBuilder.LOAD_NONE
-// .equals(scriptStrategy)) {
-// scriptsOff = true;
-// processScripts = false;
-// } else if (InternetResourceBuilder.LOAD_ALL
-// .equals(scriptStrategy)) {
-// processScripts = false;
-// // For an "ALL" strategy, it is not necessary to load scripts in the ajax request
-// if (!ajaxRequest) {
-// try {
-// resourceBuilder
-// .createResource(
-// this,
-// InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT).encode(context, null);
-// resourceBuilder
-// .createResource(
-// this,
-// InternetResourceBuilder.COMMON_UI_SCRIPT).encode(context, null);
-//
-// } catch (ResourceNotFoundException e) {
-// if (log.isWarnEnabled()) {
-// log
-// .warn("No aggregated javaScript library found "
-// + e.getMessage());
-// }
-// }
-//
-// }
-// }
-// }
-//
-// if (InternetResourceBuilder.LOAD_NONE.equals(styleStrategy)) {
-// processStyles = false;
-// } else if (InternetResourceBuilder.LOAD_ALL
-// .equals(styleStrategy)) {
-// processStyles = false;
-// // For an "ALL" strategy, it is not necessary to load styles
-// // in the ajax request
-// if (!ajaxRequest) {
-//
-// try {
-// useSkinning = encodeSkinningResources(context, resourceBuilder);
-//
-// resourceBuilder
-// .createResource(this, InternetResourceBuilder.COMMON_STYLE).encode(context, null);
-//
-// } catch (ResourceNotFoundException e) {
-// if (log.isWarnEnabled()) {
-// log.warn("No stylesheet found "
-// + e.getMessage());
-// }
-// }
-//
-// }
-// } else {
-// useSkinning = encodeSkinningResources(context, resourceBuilder);
-// }
-//
-// //traverse components
-// //traverse(context, context.getViewRoot());
-//
-// context.setResponseWriter(componentWriter);
-//
-// QueueRegistry queueRegistry = QueueRegistry.getInstance(context);
-// if (Boolean.valueOf(getInitParameterValue(context, "org.richfaces.queue.global.enabled"))) {
-// queueRegistry.setShouldCreateDefaultGlobalQueue();
-// }
-//
-// if (queueRegistry.hasQueuesToEncode()) {
-// InternetResource queueScriptResource = resourceBuilder.getResource(QUEUE_SCRIPT_RESOURCE);
-// queueScriptResource.encode(context, null);
-// }
-//
-// // Append Skin StyleSheet after a
-// if (null != skinStyleSheetUri) {
-// String resourceURL = context.getApplication()
-// .getViewHandler().getResourceURL(context,
-// skinStyleSheetUri);
-//
-// URIInternetResource resourceImpl = new URIInternetResource();
-// resourceImpl.setUri(resourceURL);
-// resourceImpl.setRenderer(resourceBuilder.getStyleRenderer());
-// resourceImpl.encode(context, null);
-//
-// useSkinning = true;
-// }
-//
-// if (null != skinExtendedStyleSheetUri && extendedSkinningAllowed) {
-// String resourceURL = context.getApplication().getViewHandler().getResourceURL(context,
-// skinExtendedStyleSheetUri);
-//
-// URIInternetResource resourceImpl = new URIInternetResource();
-// resourceImpl.setUri(resourceURL);
-// resourceImpl.setRenderer(resourceBuilder.getStyleRenderer());
-// resourceImpl.encode(context, null, EXTENDED_SKINNING);
-//
-// useSkinning = true;
-// }
-//
-// if (useSkinning && extendedSkinningAllowed) {
-// if (!ajaxRequest) {
-// if (!scriptsOff) {
-// //skinning levels aren't dynamic, page-level setting cannot be changed
-// //by AJAX request
-// EXTENDED_SKINNING_ON_RESOURCE.encode(context, null);
-// } else {
-//
-// Map<String, Object> applicationMap = context.getExternalContext().getApplicationMap();
-// if (applicationMap.get(EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY) == null) {
-// //do it once per application life - strategies can be changed dynamically
-// ResponseWriter writer = context.getResponseWriter();
-// try {
-// StringWriter stringWriter = new StringWriter();
-//
-// if (oldResponseWriter != null) {
-// context.setResponseWriter(oldResponseWriter.cloneWithWriter(stringWriter));
-// } else {
-// context.setResponseWriter(this.renderKit.createResponseWriter(
-// stringWriter, "text/html",
-// "US-ASCII"));
-// }
-//
-//
-// EXTENDED_SKINNING_ON_RESOURCE.encode(context, null);
-//
-// stringWriter.flush();
-//
-// if (log.isInfoEnabled()) {
-// log.info("Extended skinning is on and NONE scripts loading strategy was detected. " +
-// "Do not forget that one of " + InternetResourceBuilder.SKINNING_SCRIPT + " or " +
-// InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT + " resources should be presented " +
-// "on the page together with the following code: \n" + stringWriter.getBuffer().toString() +
-// "\nfor extended level of skinning to work.");
-// }
-// } finally {
-// if (writer != null) {
-// context.setResponseWriter(writer);
-// }
-// }
-//
-// applicationMap.put(EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY, Boolean.TRUE);
-// }
-// }
-// }
-//
-// if (processScripts) {
-// InternetResource resource = resourceBuilder.createResource(null,
-// InternetResourceBuilder.SKINNING_SCRIPT);
-//
-// resource.encode(context, null);
-// }
-// }
-//
-// componentWriter.endDocument();
-// userWriter.endDocument();
-// } catch (IOException e) {
-// throw new FacesException(e.getLocalizedMessage(), e);
-// } finally {
-// if (oldResponseWriter != null) {
-// context.setResponseWriter(oldResponseWriter);
-// }
-// }
-// }
-//
-// private static String getInitParameterValue(FacesContext context, String parameterName) {
-//
-// String key = INIT_PARAMETER_PREFIX + parameterName;
-//
-// ExternalContext externalContext = context.getExternalContext();
-// Map<String, Object> applicationMap = externalContext.getApplicationMap();
-// Object mutex = externalContext.getRequest();
-// Object parameterValue = null;
-//
-// synchronized (mutex) {
-// parameterValue = applicationMap.get(key);
-//
-// if (parameterValue == null) {
-//
-// String initParameter = externalContext.getInitParameter(parameterName);
-// if (initParameter != null) {
-//
-// if (ELUtils.isValueReference(initParameter)) {
-// Application application = context.getApplication();
-// ExpressionFactory expressionFactory = application.getExpressionFactory();
-//
-// parameterValue = expressionFactory.createValueExpression(context.getELContext(),
-// initParameter,
-// String.class);
-// } else {
-// parameterValue = initParameter;
-// }
-//
-// } else {
-// parameterValue = NULL;
-// }
-//
-// applicationMap.put(key, parameterValue);
-// }
-// }
-//
-// return evaluate(context, parameterValue);
-// }
-//
-// private static String evaluate(FacesContext context, Object parameterValue) {
-// if (parameterValue == NULL || parameterValue == null) {
-// return null;
-// } else if (parameterValue instanceof ValueExpression) {
-// ValueExpression expression = (ValueExpression) parameterValue;
-//
-// return (String) expression.getValue(context.getELContext());
-// } else {
-// return parameterValue.toString();
-// }
-// }
-//
-// public void initialize(FacesContext context) {
-// boolean extendedSkinningAllowed = true;
-// String skinningLevel = getInitParameterValue(context, InternetResourceBuilder.CONTROL_SKINNING_LEVEL);
-// if (skinningLevel != null && skinningLevel.length() > 0) {
-// if (InternetResourceBuilder.BASIC.equals(skinningLevel)) {
-// extendedSkinningAllowed = false;
-// } else if (!InternetResourceBuilder.EXTENDED.equals(skinningLevel)) {
-// throw new IllegalArgumentException("Value: " + skinningLevel +
-// " of " + InternetResourceBuilder.CONTROL_SKINNING_LEVEL
-// + " init parameter is invalid! Only " + InternetResourceBuilder.EXTENDED
-// + ", " + InternetResourceBuilder.BASIC + " can be used");
-// }
-// }
-//
-// this.setExtendedSkinningAllowed(extendedSkinningAllowed);
-//
-// this.setScriptStrategy(getInitParameterValue(context,
-// InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM));
-//
-// boolean useStdControlsSkinning = false;
-//
-// String stdControlsSkinning = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_PARAM);
-// if (stdControlsSkinning != null) {
-// useStdControlsSkinning = InternetResourceBuilder.ENABLE.equals(stdControlsSkinning);
-// }
-//
-// this.setUseStdControlsSkinning(useStdControlsSkinning);
-//
-// boolean useStdControlsSkinningClasses = true;
-//
-// String stdControlsSkinningClasses = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_CLASSES_PARAM);
-// if (stdControlsSkinningClasses != null) {
-// useStdControlsSkinningClasses = InternetResourceBuilder.ENABLE.equals(stdControlsSkinningClasses);
-// }
-//
-// this.setUseStdControlsSkinningClasses(useStdControlsSkinningClasses);
-//
-// this.setStyleStrategy(getInitParameterValue(context,
-// InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM));
-//
-//
-// }
-//
-}
Deleted: trunk/core/impl/src/main/java/org/ajax4jsf/resource/image/package-info.java
===================================================================
--- trunk/core/impl/src/main/java/org/ajax4jsf/resource/image/package-info.java 2010-12-23 16:14:34 UTC (rev 20781)
+++ trunk/core/impl/src/main/java/org/ajax4jsf/resource/image/package-info.java 2010-12-23 16:19:44 UTC (rev 20782)
@@ -1,4 +0,0 @@
-/**
- * Image resources support classes
- */
-package org.ajax4jsf.resource.image;
13 years, 5 months
JBoss Rich Faces SVN: r20781 - in trunk/core/impl/src: main/java/org/ajax4jsf/resource/image and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-23 11:14:34 -0500 (Thu, 23 Dec 2010)
New Revision: 20781
Added:
trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferOutputStreamTest.java
trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferWriterTest.java
Removed:
trunk/core/impl/src/main/java/org/ajax4jsf/config/
trunk/core/impl/src/main/java/org/ajax4jsf/css/
trunk/core/impl/src/main/java/org/ajax4jsf/event/
trunk/core/impl/src/main/java/org/ajax4jsf/javascript/
trunk/core/impl/src/main/java/org/ajax4jsf/request/
trunk/core/impl/src/main/java/org/ajax4jsf/resource/image/animatedgif/
trunk/core/impl/src/main/java/org/ajax4jsf/webapp/XMLResponseWriterState.java
trunk/core/impl/src/main/java/org/ajax4jsf/webapp/package-info.java
trunk/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/
trunk/core/impl/src/main/resources/org/ajax4jsf/webapp/
trunk/core/impl/src/main/resources/org/ajax4jsf/xml/
trunk/core/impl/src/test/java/org/ajax4jsf/config/
trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferOutputStreamTest.java
trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferWriterTest.java
trunk/core/impl/src/test/java/org/ajax4jsf/javascript/
Modified:
trunk/core/impl/src/main/resources/META-INF/faces-config.xml
Log:
Legacy 3.x code removal
Deleted: trunk/core/impl/src/main/java/org/ajax4jsf/webapp/XMLResponseWriterState.java
===================================================================
--- trunk/core/impl/src/main/java/org/ajax4jsf/webapp/XMLResponseWriterState.java 2010-12-23 16:09:52 UTC (rev 20780)
+++ trunk/core/impl/src/main/java/org/ajax4jsf/webapp/XMLResponseWriterState.java 2010-12-23 16:14:34 UTC (rev 20781)
@@ -1,132 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.webapp;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author shura Class to implement state pattern for
- * <code>ResponceWriter</code> Real states must extend this. By
- * default, block any events, ignore output.
- */
-class XMLResponseWriterState {
-
- // private ResponseWriter writer;
-
- /**
- * @throws java.io.IOException
- */
- private static final String ILLEGAL_METOD_STATE = Messages.getMessage(Messages.ILLEGAL_METHOD_STATE);
-
- void endDocument() throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param name
- * @throws java.io.IOException
- */
- void endElement(String name) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @throws java.io.IOException
- */
- void startDocument() throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param name
- * @param component
- * @throws java.io.IOException
- */
- void startElement(String name, UIComponent component) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param name
- * @param value
- * @param property
- * @throws java.io.IOException
- */
- void writeAttribute(String name, Object value, String property) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param comment
- * @throws java.io.IOException
- */
- void writeComment(Object comment) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param text
- * @param off
- * @param len
- * @throws java.io.IOException
- */
- void writeText(char[] text, int off, int len) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param text
- * @param property
- * @throws java.io.IOException
- */
- void writeText(Object text, String property) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param name
- * @param value
- * @param property
- * @throws java.io.IOException
- */
- void writeURIAttribute(String name, Object value, String property) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * Main hook for realise <code>Writer</code>. In document writed as
- * comment, outside of document do nothing ....
- *
- * @param cbuf
- * @param off
- * @param len
- * @throws IOException
- */
- void write(char[] cbuf, int off, int len) throws IOException {
-
- // DO NOTHING
- }
-}
Deleted: trunk/core/impl/src/main/java/org/ajax4jsf/webapp/package-info.java
===================================================================
--- trunk/core/impl/src/main/java/org/ajax4jsf/webapp/package-info.java 2010-12-23 16:09:52 UTC (rev 20780)
+++ trunk/core/impl/src/main/java/org/ajax4jsf/webapp/package-info.java 2010-12-23 16:14:34 UTC (rev 20781)
@@ -1,4 +0,0 @@
-/**
- * Web application-related stuff: filters, parsers, etc.
- */
-package org.ajax4jsf.webapp;
Modified: trunk/core/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/faces-config.xml 2010-12-23 16:09:52 UTC (rev 20780)
+++ trunk/core/impl/src/main/resources/META-INF/faces-config.xml 2010-12-23 16:14:34 UTC (rev 20781)
@@ -23,9 +23,6 @@
<system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
</system-event-listener>
</application>
- <!-- lifecycle>
- <phase-listener>org.ajax4jsf.event.AjaxPhaseListener</phase-listener>
- </lifecycle -->
<managed-bean>
<managed-bean-name>a4j</managed-bean-name>
<managed-bean-class>org.richfaces.VersionBean</managed-bean-class>
Copied: trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferOutputStreamTest.java (from rev 20771, trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferOutputStreamTest.java)
===================================================================
--- trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferOutputStreamTest.java (rev 0)
+++ trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferOutputStreamTest.java 2010-12-23 16:14:34 UTC (rev 20781)
@@ -0,0 +1,84 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.ajax4jsf.io;
+
+import junit.framework.TestCase;
+
+import org.ajax4jsf.io.ByteBuffer;
+import org.ajax4jsf.io.FastBufferOutputStream;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class FastBufferOutputStreamTest extends TestCase {
+
+ /**
+ * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
+ */
+ public void testResetOneBuffer() throws Exception {
+ FastBufferOutputStream stream = new FastBufferOutputStream(256);
+
+ for (int i = 0; i < 255; i++) {
+ stream.write(i);
+ }
+
+ assertEquals(255, stream.getLength());
+
+ ByteBuffer firstBuffer = stream.getFirstBuffer();
+
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ stream.reset();
+ assertEquals(0, stream.getLength());
+ firstBuffer = stream.getFirstBuffer();
+ assertEquals(0, firstBuffer.getUsedSize());
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
+ */
+ public void testResetTwoBuffers() throws Exception {
+ FastBufferOutputStream stream = new FastBufferOutputStream(256);
+
+ for (int i = 0; i < 257; i++) {
+ stream.write(i);
+ }
+
+ assertEquals(257, stream.getLength());
+
+ ByteBuffer firstBuffer = stream.getFirstBuffer();
+
+ assertNotNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ stream.reset();
+ assertEquals(0, stream.getLength());
+ firstBuffer = stream.getFirstBuffer();
+ assertEquals(0, firstBuffer.getUsedSize());
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ }
+}
Copied: trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferWriterTest.java (from rev 20771, trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferWriterTest.java)
===================================================================
--- trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferWriterTest.java (rev 0)
+++ trunk/core/impl/src/test/java/org/ajax4jsf/io/FastBufferWriterTest.java 2010-12-23 16:14:34 UTC (rev 20781)
@@ -0,0 +1,118 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.ajax4jsf.io;
+
+import junit.framework.TestCase;
+
+import org.ajax4jsf.io.CharBuffer;
+import org.ajax4jsf.io.FastBufferReader;
+import org.ajax4jsf.io.FastBufferWriter;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class FastBufferWriterTest extends TestCase {
+
+ /**
+ * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
+ */
+ public void testResetOneBuffer() throws Exception {
+ FastBufferWriter stream = new FastBufferWriter(256);
+
+ for (int i = 0; i < 255; i++) {
+ stream.write(i);
+ }
+
+ assertEquals(255, stream.getLength());
+
+ CharBuffer firstBuffer = stream.getFirstBuffer();
+
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ stream.reset();
+ assertEquals(0, stream.getLength());
+ firstBuffer = stream.getFirstBuffer();
+ assertEquals(0, firstBuffer.getUsedSize());
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
+ */
+ public void testResetTwoBuffers() throws Exception {
+ FastBufferWriter stream = new FastBufferWriter(256);
+
+ for (int i = 0; i < 257; i++) {
+ stream.write(i);
+ }
+
+ assertEquals(257, stream.getLength());
+
+ CharBuffer firstBuffer = stream.getFirstBuffer();
+
+ assertNotNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ stream.reset();
+ assertEquals(0, stream.getLength());
+ firstBuffer = stream.getFirstBuffer();
+ assertEquals(0, firstBuffer.getUsedSize());
+ assertNull(firstBuffer.getNext());
+ assertNull(firstBuffer.getPrevious());
+ }
+
+ public void testCompact() throws Exception {
+ int itemsTowWrite = 16384 + 16000;
+ FastBufferWriter writer = new FastBufferWriter(16384);
+
+ for (int i = 0; i < itemsTowWrite; i++) {
+ writer.write(i);
+ }
+
+ writer.close();
+
+ CharBuffer firstBuffer = writer.getFirstBuffer();
+
+ assertNotNull(firstBuffer);
+
+ CharBuffer nextBuffer = firstBuffer.getNext();
+
+ assertNotNull(nextBuffer);
+ assertNull(nextBuffer.getNext());
+ assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
+ assertTrue(nextBuffer.getUsedSize() < nextBuffer.getCacheSize());
+ firstBuffer.compact();
+ assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
+ assertTrue(nextBuffer.getUsedSize() == nextBuffer.getCacheSize());
+
+ FastBufferReader reader = new FastBufferReader(firstBuffer);
+
+ for (int i = 0; i < itemsTowWrite; i++) {
+ assertEquals(i, reader.read());
+ }
+
+ reader.close();
+ }
+}
Deleted: trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferOutputStreamTest.java
===================================================================
--- trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferOutputStreamTest.java 2010-12-23 16:09:52 UTC (rev 20780)
+++ trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferOutputStreamTest.java 2010-12-23 16:14:34 UTC (rev 20781)
@@ -1,84 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.io.parser;
-
-import junit.framework.TestCase;
-
-import org.ajax4jsf.io.ByteBuffer;
-import org.ajax4jsf.io.FastBufferOutputStream;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-public class FastBufferOutputStreamTest extends TestCase {
-
- /**
- * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
- */
- public void testResetOneBuffer() throws Exception {
- FastBufferOutputStream stream = new FastBufferOutputStream(256);
-
- for (int i = 0; i < 255; i++) {
- stream.write(i);
- }
-
- assertEquals(255, stream.getLength());
-
- ByteBuffer firstBuffer = stream.getFirstBuffer();
-
- assertNull(firstBuffer.getNext());
- assertNull(firstBuffer.getPrevious());
- stream.reset();
- assertEquals(0, stream.getLength());
- firstBuffer = stream.getFirstBuffer();
- assertEquals(0, firstBuffer.getUsedSize());
- assertNull(firstBuffer.getNext());
- assertNull(firstBuffer.getPrevious());
- }
-
- /**
- * Test method for {@link org.ajax4jsf.io.FastBufferOutputStream#reset()}.
- */
- public void testResetTwoBuffers() throws Exception {
- FastBufferOutputStream stream = new FastBufferOutputStream(256);
-
- for (int i = 0; i < 257; i++) {
- stream.write(i);
- }
-
- assertEquals(257, stream.getLength());
-
- ByteBuffer firstBuffer = stream.getFirstBuffer();
-
- assertNotNull(firstBuffer.getNext());
- assertNull(firstBuffer.getPrevious());
- stream.reset();
- assertEquals(0, stream.getLength());
- firstBuffer = stream.getFirstBuffer();
- assertEquals(0, firstBuffer.getUsedSize());
- assertNull(firstBuffer.getNext());
- assertNull(firstBuffer.getPrevious());
- }
-}
Deleted: trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferWriterTest.java
===================================================================
--- trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferWriterTest.java 2010-12-23 16:09:52 UTC (rev 20780)
+++ trunk/core/impl/src/test/java/org/ajax4jsf/io/parser/FastBufferWriterTest.java 2010-12-23 16:14:34 UTC (rev 20781)
@@ -1,118 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.io.parser;
-
-import junit.framework.TestCase;
-
-import org.ajax4jsf.io.CharBuffer;
-import org.ajax4jsf.io.FastBufferReader;
-import org.ajax4jsf.io.FastBufferWriter;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-public class FastBufferWriterTest extends TestCase {
-
- /**
- * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
- */
- public void testResetOneBuffer() throws Exception {
- FastBufferWriter stream = new FastBufferWriter(256);
-
- for (int i = 0; i < 255; i++) {
- stream.write(i);
- }
-
- assertEquals(255, stream.getLength());
-
- CharBuffer firstBuffer = stream.getFirstBuffer();
-
- assertNull(firstBuffer.getNext());
- assertNull(firstBuffer.getPrevious());
- stream.reset();
- assertEquals(0, stream.getLength());
- firstBuffer = stream.getFirstBuffer();
- assertEquals(0, firstBuffer.getUsedSize());
- assertNull(firstBuffer.getNext());
- assertNull(firstBuffer.getPrevious());
- }
-
- /**
- * Test method for {@link org.ajax4jsf.io.FastBufferWriter#reset()}.
- */
- public void testResetTwoBuffers() throws Exception {
- FastBufferWriter stream = new FastBufferWriter(256);
-
- for (int i = 0; i < 257; i++) {
- stream.write(i);
- }
-
- assertEquals(257, stream.getLength());
-
- CharBuffer firstBuffer = stream.getFirstBuffer();
-
- assertNotNull(firstBuffer.getNext());
- assertNull(firstBuffer.getPrevious());
- stream.reset();
- assertEquals(0, stream.getLength());
- firstBuffer = stream.getFirstBuffer();
- assertEquals(0, firstBuffer.getUsedSize());
- assertNull(firstBuffer.getNext());
- assertNull(firstBuffer.getPrevious());
- }
-
- public void testCompact() throws Exception {
- int itemsTowWrite = 16384 + 16000;
- FastBufferWriter writer = new FastBufferWriter(16384);
-
- for (int i = 0; i < itemsTowWrite; i++) {
- writer.write(i);
- }
-
- writer.close();
-
- CharBuffer firstBuffer = writer.getFirstBuffer();
-
- assertNotNull(firstBuffer);
-
- CharBuffer nextBuffer = firstBuffer.getNext();
-
- assertNotNull(nextBuffer);
- assertNull(nextBuffer.getNext());
- assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
- assertTrue(nextBuffer.getUsedSize() < nextBuffer.getCacheSize());
- firstBuffer.compact();
- assertTrue(firstBuffer.getUsedSize() == firstBuffer.getCacheSize());
- assertTrue(nextBuffer.getUsedSize() == nextBuffer.getCacheSize());
-
- FastBufferReader reader = new FastBufferReader(firstBuffer);
-
- for (int i = 0; i < itemsTowWrite; i++) {
- assertEquals(i, reader.read());
- }
-
- reader.close();
- }
-}
13 years, 5 months
JBoss Rich Faces SVN: r20780 - trunk/core/impl/src/main/resources/META-INF/resources.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-12-23 11:09:52 -0500 (Thu, 23 Dec 2010)
New Revision: 20780
Modified:
trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js
Log:
http://jira.jboss.com/jira/browse/RF-10046
Modified: trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-12-23 16:08:06 UTC (rev 20779)
+++ trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-12-23 16:09:52 UTC (rev 20780)
@@ -78,13 +78,13 @@
if (e) {
var elements = e.getElementsByTagName("*");
if (elements.length) {
- jQuery.cleanData(elements);
jQuery.each(elements, function(index) {
richfaces.cleanComponent(this);
});
+ jQuery.cleanData(elements);
}
+ richfaces.cleanComponent(e);
jQuery.cleanData([e]);
- richfaces.cleanComponent(e);
}
};
13 years, 5 months
JBoss Rich Faces SVN: r20779 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: richCalendar and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-12-23 11:08:06 -0500 (Thu, 23 Dec 2010)
New Revision: 20779
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestRichCalendarAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSpinner/TestRichSpinner.java
Log:
* fixed bugs in tests
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java 2010-12-23 16:06:35 UTC (rev 20778)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richAccordion/TestRichAccordion.java 2010-12-23 16:08:06 UTC (rev 20779)
@@ -169,6 +169,7 @@
}
@Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10054")
public void testBypassUpdates() {
selenium.click(pjq("input[type=radio][name$=bypassUpdatesInput][value=true]"));
selenium.waitForPageToLoad();
@@ -261,6 +262,7 @@
}
@Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10054")
public void testImmediate() {
selenium.click(pjq("input[type=radio][name$=immediateInput][value=true]"));
selenium.waitForPageToLoad();
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestRichCalendarAttributes.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestRichCalendarAttributes.java 2010-12-23 16:06:35 UTC (rev 20778)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestRichCalendarAttributes.java 2010-12-23 16:08:06 UTC (rev 20779)
@@ -333,18 +333,18 @@
assertEquals(label, labels[i], "Week day label " + i);
}
- // wrong input
- selenium.type(pjq("input[type=text][id$=firstWeekDayInput]"), "9");
- selenium.waitForPageToLoad();
-
- selenium.click(input);
-
- labels = new String[]{"", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
-
- for (int i = 0; i < 8; i++) {
- String label = selenium.getText(weekDayLabel.format(i));
- assertEquals(label, labels[i], "Week day label " + i);
- }
+ // wrong input - throws a server-side exception
+ // selenium.type(pjq("input[type=text][id$=firstWeekDayInput]"), "9");
+ // selenium.waitForPageToLoad();
+ //
+ // selenium.click(input);
+ //
+ // labels = new String[]{"", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+ //
+ // for (int i = 0; i < 8; i++) {
+ // String label = selenium.getText(weekDayLabel.format(i));
+ // assertEquals(label, labels[i], "Week day label " + i);
+ // }
}
@Test
@@ -413,7 +413,7 @@
selenium.waitForPageToLoad(TIMEOUT);
selenium.type(input, "Dec 23, 2010 19:27");
-
+
waitGui.failWith("Attribute oninputchange does not work correctly").until(
new EventFiredCondition(new Event("inputchange")));
}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java 2010-12-23 16:06:35 UTC (rev 20778)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java 2010-12-23 16:08:06 UTC (rev 20779)
@@ -410,9 +410,6 @@
@Test
public void testSaveOnBlurSelectTrueTrue() {
- selenium.click(pjq("input[type=radio][name$=saveOnBlurInput][value=true]"));
- selenium.waitForPageToLoad();
-
selenium.click(select);
assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
@@ -423,8 +420,6 @@
@Test
public void testSaveOnBlurSelectTrueFalse() {
- selenium.click(pjq("input[type=radio][name$=saveOnBlurInput][value=true]"));
- selenium.waitForPageToLoad();
selenium.click(pjq("input[type=radio][name$=saveOnSelectInput][value=false]"));
selenium.waitForPageToLoad();
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSpinner/TestRichSpinner.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSpinner/TestRichSpinner.java 2010-12-23 16:06:35 UTC (rev 20778)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInputNumberSpinner/TestRichSpinner.java 2010-12-23 16:08:06 UTC (rev 20779)
@@ -118,10 +118,10 @@
guardXhr(selenium).type(input, number);
waitGui.failWith("Page was not updated").waitForChange(reqTime, retrieveText.locator(time));
- int roundedNumber = (int) Math.round(Double.parseDouble(number));
+ Double newNumber = new Double(number);
- assertEquals(selenium.getText(output), Integer.toString(roundedNumber), "Output was not updated.");
- assertEquals(getInputValue(), Integer.toString(roundedNumber), "Input was not updated.");
+ assertEquals(selenium.getText(output), newNumber == 0 ? "0" : newNumber.toString(), "Output was not updated.");
+ assertEquals(selenium.getValue(input), newNumber == 0 ? "0" : newNumber.toString(), "Input was not updated.");
}
@Test
@@ -211,6 +211,7 @@
}
@Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10048")
public void testImmediate() {
JQueryLocator immediateInput = pjq("input[type=radio][name$=immediateInput][value=true]");
selenium.click(immediateInput);
13 years, 5 months