JBoss Rich Faces SVN: r22099 - in branches/4.0.X/core: impl/src/main/java/org/richfaces/application/push/impl/jms and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2011-03-09 07:17:53 -0500 (Wed, 09 Mar 2011)
New Revision: 22099
Modified:
branches/4.0.X/core/api/src/main/java/org/richfaces/application/push/TopicsContext.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/application/push/impl/jms/SessionImpl.java
Log:
Small push refactorings
Modified: branches/4.0.X/core/api/src/main/java/org/richfaces/application/push/TopicsContext.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/richfaces/application/push/TopicsContext.java 2011-03-09 12:03:27 UTC (rev 22098)
+++ branches/4.0.X/core/api/src/main/java/org/richfaces/application/push/TopicsContext.java 2011-03-09 12:17:53 UTC (rev 22099)
@@ -53,13 +53,7 @@
}
public Topic getTopic(TopicKey key) {
- Topic topic = topics.get(key.getTopicName());
-
- if (topic == null) {
- //TODO
- }
-
- return topic;
+ return topics.get(key.getTopicName());
}
public void removeTopic(TopicKey key) {
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/application/push/impl/jms/SessionImpl.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/application/push/impl/jms/SessionImpl.java 2011-03-09 12:03:27 UTC (rev 22098)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/application/push/impl/jms/SessionImpl.java 2011-03-09 12:17:53 UTC (rev 22099)
@@ -21,6 +21,7 @@
*/
package org.richfaces.application.push.impl.jms;
+import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
@@ -156,12 +157,26 @@
TopicKey rootTopicKey = topicKey.getRootTopicKey();
Topic pushTopic = topicsContext.getTopic(rootTopicKey);
- try {
- //TODO - publish another events
- pushTopic.publishEvent(new SessionPreSubscriptionEvent(pushTopic, topicKey, this));
- } catch (EventAbortedException e) {
+ String errorMessage = null;
+
+ if (pushTopic == null) {
+ errorMessage = MessageFormat.format("Topic ''{0}'' is not configured", topicKey.getTopicAddress());
+ } else {
+ try {
+ //TODO - publish another events
+ pushTopic.publishEvent(new SessionPreSubscriptionEvent(pushTopic, topicKey, this));
+ } catch (EventAbortedException e) {
+ if (e.getMessage() != null) {
+ errorMessage = e.getMessage();
+ } else {
+ errorMessage = MessageFormat.format("Unknown error connecting to ''{0}'' topic", topicKey.getTopicAddress());
+ }
+ }
+ }
+
+ if (errorMessage != null) {
itr.remove();
- failedSubscriptions.put(topicKey, e.getMessage());
+ failedSubscriptions.put(topicKey, errorMessage);
}
}
}
13 years, 8 months
JBoss Rich Faces SVN: r22098 - in branches/4.0.X/core: api/src/main/java/org/ajax4jsf/model and 15 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2011-03-09 07:03:27 -0500 (Wed, 09 Mar 2011)
New Revision: 22098
Removed:
branches/4.0.X/core/impl/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java
Modified:
branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java
branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/PropertyUtils.java
branches/4.0.X/core/api/src/main/java/org/ajax4jsf/model/SequenceDataModel.java
branches/4.0.X/core/api/src/main/java/org/richfaces/cache/CacheFactory.java
branches/4.0.X/core/api/src/main/java/org/richfaces/renderkit/AjaxConstants.java
branches/4.0.X/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
branches/4.0.X/core/api/src/main/java/org/richfaces/resource/ImageType.java
branches/4.0.X/core/api/src/main/java/org/richfaces/skin/SkinFactory.java
branches/4.0.X/core/api/src/main/java/org/richfaces/skin/SkinNotFoundException.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/JBossCacheCache.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/JBossCacheCacheFactory.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/OSCacheCacheFactory.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/renderkit/util/CoreRendererUtils.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/ExternalStaticResource.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/skin/SkinBean.java
branches/4.0.X/core/impl/src/main/java/org/richfaces/util/Util.java
branches/4.0.X/core/impl/src/test/java/org/richfaces/cache/BaseCacheTest.java
branches/4.0.X/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java
Log:
TODOs and small refactorings
Modified: branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -38,8 +38,6 @@
*/
public JSObject(String name, Object... parameters) {
super(name, parameters);
-
- // TODO Auto-generated constructor stub
}
public void appendScript(Appendable target) throws IOException {
Modified: branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -54,8 +54,6 @@
* @param index
*/
public JSReference(String name, Object index) {
-
- // TODO Auto-generated constructor stub
this.name = name;
this.index = index;
}
Modified: branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/PropertyUtils.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/PropertyUtils.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/ajax4jsf/javascript/PropertyUtils.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -56,8 +56,6 @@
PropertyDescriptor[] descriptors = null;
try {
-
- // TODO - cache introspection info?
BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass());
descriptors = beanInfo.getPropertyDescriptors();
Modified: branches/4.0.X/core/api/src/main/java/org/ajax4jsf/model/SequenceDataModel.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/ajax4jsf/model/SequenceDataModel.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/ajax4jsf/model/SequenceDataModel.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -42,46 +42,6 @@
this.wrappedModel = wrapped;
}
- /*
- * (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#dataIterator(org.ajax4jsf.ajax.repeat.Range)
- */
-
-/* public Iterator dataIterator(Range range) {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = wrapped.getRowCount();
- final int firstRow = seqRange.getFirstRow();
- if(rows > 0){
- rows += firstRow;
- if(rowCount >=0){
- rows = Math.min(rows, rowCount);
- }
- } else if(rowCount >=0 ){
- rows = rowCount;
- }
- final int maxRow = rows;
- return new Iterator(){
-
- int rowIndex = firstRow;
-
- public boolean hasNext() {
- // TODO Auto-generated method stub
- return maxRow < 0 || rowIndex < maxRow;
- }
-
- public Object next() {
- // TODO Auto-generated method stub
- return new Integer(rowIndex++);
- }
-
- public void remove() {
- throw new IllegalStateException();
- }
-
- };
- }
-*/
public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
final SequenceRange seqRange = (SequenceRange) range;
int rows = seqRange.getRows();
@@ -152,8 +112,6 @@
* @see javax.faces.model.DataModel#getRowCount()
*/
public int getRowCount() {
-
- // TODO Auto-generated method stub
return wrappedModel.getRowCount();
}
@@ -162,8 +120,6 @@
* @see javax.faces.model.DataModel#getRowData()
*/
public E getRowData() {
-
- // TODO Auto-generated method stub
return wrappedModel.getRowData();
}
@@ -172,8 +128,6 @@
* @see javax.faces.model.DataModel#getRowIndex()
*/
public int getRowIndex() {
-
- // TODO Auto-generated method stub
return wrappedModel.getRowIndex();
}
@@ -182,8 +136,6 @@
* @see javax.faces.model.DataModel#getWrappedData()
*/
public Object getWrappedData() {
-
- // TODO Auto-generated method stub
return wrappedModel.getWrappedData();
}
@@ -192,8 +144,6 @@
* @see javax.faces.model.DataModel#isRowAvailable()
*/
public boolean isRowAvailable() {
-
- // TODO Auto-generated method stub
return wrappedModel.isRowAvailable();
}
Modified: branches/4.0.X/core/api/src/main/java/org/richfaces/cache/CacheFactory.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/richfaces/cache/CacheFactory.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/richfaces/cache/CacheFactory.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -35,13 +35,11 @@
public interface CacheFactory {
/**
- * creates a new implementation specific Cache object using the env parameters.
- * @param env implementation specific environment parameters passed to the
- * CacheFactory.
- * @param cacheLoader implementation of the {@link CacheLoader} to use
- * @param cacheConfigurationloader TODO
+ * Creates a new implementation specific Cache object using the env parameters.
+ * @param facesContext
+ * @param cacheName
+ * @param env
* @return an implementation specific Cache object.
- * @throws CacheException if any error occurs.
*/
public Cache createCache(FacesContext facesContext, String cacheName, Map<?, ?> env);
Modified: branches/4.0.X/core/api/src/main/java/org/richfaces/renderkit/AjaxConstants.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/richfaces/renderkit/AjaxConstants.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/richfaces/renderkit/AjaxConstants.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -35,7 +35,6 @@
public static final String BEHAVIOR_EVENT_PARAMETER = "javax.faces.behavior.event";
- //TODO - review
public static final String AJAX_COMPONENT_ID_PARAMETER = "org.richfaces.ajax.component";
}
Modified: branches/4.0.X/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -50,25 +50,6 @@
public final class CoreAjaxRendererUtils {
/**
- * Attribute for keep JavaScript function name for call before updating
- * DOM tree.
- */
- public static final String ONBEFOREDOMUPDATE_ATTR_NAME = "onbeforedomupdate";
-
- /**
- * Attribute for keep JavaScript function name for call after complete
- * request.
- */
- public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
-
- public static final String DATA_ATTR_NAME = "data";
-
- /**
- * Attribute to keep
- */
- public static final String LIMITRENDER_ATTR_NAME = "limitRender";
-
- /**
* @since 3.3.0
*/
public static final String AJAX_PROCESS_ATTRIBUTE = "process";
@@ -238,57 +219,4 @@
return null;
}
-
- /**
- * Calculate, must be component render only given areas, or all sended from
- * server.
- *
- * @param component
- * @return <code>true</code> if client must render ONLY given areas.
- */
- public static boolean isAjaxLimitRender(UIComponent component) {
- boolean result = false;
-
- Object limitRenderObject = component.getAttributes().get(LIMITRENDER_ATTR_NAME);
- if (limitRenderObject instanceof Boolean) {
- result = ((Boolean) limitRenderObject).booleanValue();
- } else {
- result = Boolean.valueOf(String.valueOf(limitRenderObject));
- }
-
- return result;
- }
-
-
- /**
- * Get function name for call on completed ajax request.
- *
- * @param component for wich calculate function name
- * @return name of JavaScript function or <code>null</code>
- */
- //TODO nick - refactor - remove this method?
- public static String getAjaxOncomplete(UIComponent component) {
- return (String) component.getAttributes().get(ONCOMPLETE_ATTR_NAME);
- }
-
- /**
- * Get function name for call before update DOM.
- *
- * @param component for wich calculate function name
- * @return name of JavaScript function or <code>null</code>
- */
- //TODO nick - refactor - remove this method?
- public static String getAjaxOnBeforeDomUpdate(UIComponent component) {
- return (String) component.getAttributes().get(ONBEFOREDOMUPDATE_ATTR_NAME);
- }
-
- /**
- * @param component
- * @return
- * @since 4.0
- */
- public static Object getAjaxData(UIComponent component) {
- return component.getAttributes().get(DATA_ATTR_NAME);
- }
-
}
Modified: branches/4.0.X/core/api/src/main/java/org/richfaces/resource/ImageType.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/richfaces/resource/ImageType.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/richfaces/resource/ImageType.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -50,8 +50,6 @@
return new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, SAFE_WEB_COLORS_MODEL);
}
},
-
- // TODO - add common png8
JPEG("jpeg") {
@Override
public BufferedImage createImage(int width, int height) {
Modified: branches/4.0.X/core/api/src/main/java/org/richfaces/skin/SkinFactory.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/richfaces/skin/SkinFactory.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/richfaces/skin/SkinFactory.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -28,22 +28,13 @@
/**
* Base factory class ( implement Singleton design pattern ). Produce self
* instance to build current skin configuration. At present, realised as lazy
- * creation factory. TODO - select point to initialize.
+ * creation factory.
*
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:43 $
*/
public abstract class SkinFactory {
- /**
- * Initialize skin factory. TODO - make call from init() method of any
- * servlet or custom faces element method ??? If exist resource
- * META-INF/services/org.richfaces.skin.SkinFactory , create
- * instance of class by name from first line of this file. If such class
- * have constructor with {@link SkinFactory} parameter, instantiate it with
- * instance of default factory ( as usual in JSF ). If any error occurs in
- * instantiate custom factory, return default.
- */
@Deprecated
public static final SkinFactory getInstance() {
return getInstance(FacesContext.getCurrentInstance());
Modified: branches/4.0.X/core/api/src/main/java/org/richfaces/skin/SkinNotFoundException.java
===================================================================
--- branches/4.0.X/core/api/src/main/java/org/richfaces/skin/SkinNotFoundException.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/api/src/main/java/org/richfaces/skin/SkinNotFoundException.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -34,25 +34,17 @@
public SkinNotFoundException() {
super();
-
- // TODO Auto-generated constructor stub
}
public SkinNotFoundException(String arg0) {
super(arg0);
-
- // TODO Auto-generated constructor stub
}
public SkinNotFoundException(Throwable arg0) {
super(arg0);
-
- // TODO Auto-generated constructor stub
}
public SkinNotFoundException(String arg0, Throwable arg1) {
super(arg0, arg1);
-
- // TODO Auto-generated constructor stub
}
}
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -22,6 +22,7 @@
package org.richfaces.application.push.impl;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
@@ -73,8 +74,6 @@
}
public void onRequest(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) throws IOException {
- // TODO Auto-generated method stub
-
HttpServletRequest req = resource.getRequest();
HttpServletResponse resp = resource.getResponse();
@@ -87,7 +86,9 @@
}
if (session == null) {
- //TODO - debug log
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(MessageFormat.format("Session {0} was not found", pushSessionId));
+ }
resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
@@ -98,8 +99,7 @@
Request request = createRequest(resource, session);
request.suspend();
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.error(e.getMessage(), e);
}
}
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/JBossCacheCache.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/JBossCacheCache.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/JBossCacheCache.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -17,12 +17,17 @@
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
/**
* @author Nick Belaevski
* @since 4.0
*/
public class JBossCacheCache implements org.richfaces.cache.Cache {
+
+ private static final Logger LOGGER = RichfacesLogger.CACHE.getLogger();
+
private static final String RESOURCE = "resource";
private Cache<String, Object> cache;
@@ -59,29 +64,17 @@
transaction.commit();
}
} catch (SystemException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.error(e.getMessage(), e);
} catch (SecurityException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.error(e.getMessage(), e);
} catch (IllegalStateException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.error(e.getMessage(), e);
} catch (RollbackException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.error(e.getMessage(), e);
} catch (HeuristicMixedException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.error(e.getMessage(), e);
} catch (HeuristicRollbackException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.error(e.getMessage(), e);
}
}
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/JBossCacheCacheFactory.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/JBossCacheCacheFactory.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/JBossCacheCacheFactory.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -82,9 +82,7 @@
try {
stream.close();
} catch (IOException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOG.debug(e.getMessage(), e);
}
}
}
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/OSCacheCacheFactory.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/OSCacheCacheFactory.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/cache/OSCacheCacheFactory.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -32,6 +32,7 @@
import java.util.Map;
import java.util.Properties;
+import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import org.ajax4jsf.resource.util.URLToStreamHelper;
@@ -75,8 +76,7 @@
try {
stream.close();
} catch (IOException e) {
-
- // TODO: handle exception
+ LOG.debug(e.getMessage(), e);
}
}
}
@@ -91,17 +91,13 @@
try {
cacheProperties.putAll(loadProperties());
} catch (IOException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new FacesException(e.getMessage(), e);
}
try {
cacheProperties.putAll(loadProperties());
} catch (IOException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new FacesException(e.getMessage(), e);
}
cacheProperties.putAll(env);
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -28,7 +28,6 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxClientBehavior;
-import org.richfaces.renderkit.util.CoreAjaxRendererUtils;
import org.richfaces.renderkit.util.CoreRendererUtils;
/**
@@ -82,10 +81,10 @@
data = behavior.getData();
} else {
renderValue = target.getAttributes().get("render");
- limitRender = CoreAjaxRendererUtils.isAjaxLimitRender(target);
- onbeforedomupdate = CoreAjaxRendererUtils.getAjaxOnBeforeDomUpdate(target);
- oncomplete = CoreAjaxRendererUtils.getAjaxOncomplete(target);
- data = CoreAjaxRendererUtils.getAjaxData(target);
+ limitRender = isTrue(target.getAttributes().get("limitRender"));
+ onbeforedomupdate = (String) target.getAttributes().get("onbeforedomupdate");
+ oncomplete = (String) target.getAttributes().get("oncomplete");
+ data = target.getAttributes().get("data");
}
Collection<String> unresolvedRenderIds = toCollection(renderValue);
@@ -93,4 +92,16 @@
renderIds = CoreRendererUtils.INSTANCE.findComponentsFor(facesContext, target, unresolvedRenderIds);
}
+ private boolean isTrue(Object value) {
+ boolean result = false;
+
+ if (value instanceof Boolean) {
+ result = ((Boolean) value).booleanValue();
+ } else {
+ result = Boolean.valueOf(String.valueOf(value));
+ }
+
+ return result;
+ }
+
}
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/renderkit/util/CoreRendererUtils.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/renderkit/util/CoreRendererUtils.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/renderkit/util/CoreRendererUtils.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -118,9 +118,6 @@
*/
public Collection<String> findComponentsFor(FacesContext context, UIComponent component,
Collection<String> shortIds) {
-
- // TODO - implement
- // TODO add support for @*
Set<String> result = new LinkedHashSet<String>(shortIds.size());
if (checkKeyword(shortIds, ALL)) {
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -56,7 +56,6 @@
super();
}
- // TODO remove FacesContext argument?
protected int getContentLength(FacesContext context) {
return -1;
}
@@ -116,9 +115,7 @@
}
}
} catch (IOException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.error(e.getMessage(), e);
}
} else {
if (LOGGER.isDebugEnabled()) {
@@ -140,7 +137,6 @@
return classLoader;
}
- //TODO nick - review
private String getResourceVersion() {
if (this instanceof VersionedResource) {
return ((VersionedResource) this).getVersion();
@@ -151,8 +147,6 @@
@Override
public String getRequestPath() {
-
- // TODO - cache resource request path in request scope
FacesContext context = FacesContext.getCurrentInstance();
ResourceCodec resourceCodec = ServiceTracker.getService(context, ResourceCodec.class);
String libraryName = getLibraryName();
@@ -207,8 +201,6 @@
String contentType = getContentType();
if (contentType != null) {
-
- // TODO add content-encoding?
headers.put("Content-Type", contentType);
}
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/ExternalStaticResource.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/ExternalStaticResource.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/ExternalStaticResource.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -98,7 +98,6 @@
@Override
public URL getURL() {
- //TODO - review
throw new UnsupportedOperationException();
}
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -303,7 +303,6 @@
* @return
*/
protected Resource createHandlerDependentResource(ResourceKey resourceKey, Map<String, String> parameters) {
- // TODO nick - libraryName as package name?
if (!Strings.isNullOrEmpty(resourceKey.getLibraryName())) {
return null;
}
@@ -357,7 +356,6 @@
private boolean checkResourceMarker(String resourceName) {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- // TODO resource marker extension name?
URL resourceMarkerUrl = contextClassLoader.getResource("META-INF/" + resourceName
+ ".resource.properties");
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/skin/SkinBean.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/skin/SkinBean.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/skin/SkinBean.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -39,8 +39,6 @@
* @see org.richfaces.skin.Skin#hashCode(javax.faces.context.FacesContext)
*/
public int hashCode(FacesContext context) {
-
- // TODO Auto-generated method stub
return getSkin().hashCode(context);
}
@@ -50,8 +48,6 @@
*/
@Override
public Set entrySet() {
-
- // TODO Auto-generated method stub
return Collections.EMPTY_SET;
}
@@ -84,7 +80,7 @@
private Skin getSkin() {
FacesContext context = FacesContext.getCurrentInstance();
- return SkinFactory.getInstance().getSkin(context);
+ return SkinFactory.getInstance(context).getSkin(context);
}
/*
@@ -102,8 +98,6 @@
*/
@Override
public boolean isEmpty() {
-
- // TODO Auto-generated method stub
return false;
}
@@ -130,7 +124,7 @@
/* Static methods for manipulate skins */
public static Object skinHashCode() {
FacesContext context = FacesContext.getCurrentInstance();
- int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
+ int hashCode = SkinFactory.getInstance(context).getSkin(context).hashCode(context);
byte[] bs = ByteBuffer.allocate(4).putInt(hashCode).array();
return bs;
Modified: branches/4.0.X/core/impl/src/main/java/org/richfaces/util/Util.java
===================================================================
--- branches/4.0.X/core/impl/src/main/java/org/richfaces/util/Util.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/main/java/org/richfaces/util/Util.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -167,9 +167,7 @@
try {
result = (Date) ((Format) RFC1123_DATE_FORMATTER.clone()).parseObject(s);
} catch (ParseException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
+ RESOURCE_LOGGER.error(e.getMessage(), e);
}
}
Modified: branches/4.0.X/core/impl/src/test/java/org/richfaces/cache/BaseCacheTest.java
===================================================================
--- branches/4.0.X/core/impl/src/test/java/org/richfaces/cache/BaseCacheTest.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/test/java/org/richfaces/cache/BaseCacheTest.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -203,8 +203,6 @@
try {
thread.join();
} catch (InterruptedException e) {
-
- // TODO Auto-generated catch block
failure.set(true);
}
}
Modified: branches/4.0.X/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java
===================================================================
--- branches/4.0.X/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -65,10 +65,6 @@
assert idsToVisit != null;
- if (idsToVisit == VisitContext.ALL_IDS) {
- // TODO
- }
-
// All ids or non-empty collection means we need to visit our children.
return !idsToVisit.isEmpty();
}
@@ -124,8 +120,6 @@
try {
setRowIndex(oldRowIndex);
} catch (Exception e) {
-
- // TODO: handle exception
LOG.error(e.getMessage(), e);
}
}
Deleted: branches/4.0.X/core/impl/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java
===================================================================
--- branches/4.0.X/core/impl/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java 2011-03-09 10:35:12 UTC (rev 22097)
+++ branches/4.0.X/core/impl/src/test/java/org/richfaces/skin/SkinThreadsTestCase.java 2011-03-09 12:03:27 UTC (rev 22098)
@@ -1,115 +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.skin;
-//
-//import javax.faces.context.FacesContext;
-//
-//import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
-//import org.richfaces.skin.Skin;
-//import org.richfaces.skin.SkinFactory;
-//
-///**
-// * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
-// * @version $Revision: 1.1.2.2 $ $Date: 2007/02/20 20:58:11 $
-// *
-// */
-//public class SkinThreadsTestCase extends AbstractThreadedAjax4JsfTestCase {
-//
-// /**
-// * @param s
-// */
-// public SkinThreadsTestCase(String s) {
-// super(s);
-// // TODO Auto-generated constructor stub
-// }
-//
-// /*
-// * (non-Javadoc)
-// *
-// * @see com.exadel.vcp.tests.VcpJsfTestCase#setUp()
-// */
-//public void setUp() throws Exception {
-// // TODO Auto-generated method stub
-// super.setUp();
-// servletContext.setAttribute("skin", new Bean());
-// }
-// /*
-// * (non-Javadoc)
-// *
-// * @see com.exadel.vcp.tests.VcpJsfTestCase#tearDown()
-// */
-// public void tearDown() throws Exception {
-// // TODO Auto-generated method stub
-// super.tearDown();
-// }
-//
-//
-// public class SkinTestRunnable extends TestCaseRunnable {
-//
-//
-// /**
-// *
-// */
-// public SkinTestRunnable() {
-// // TODO Auto-generated constructor stub
-// }
-//
-// /* (non-Javadoc)
-// * @see com.exadel.vcp.tests.ThreadedVcpJsfTestCase.TestCaseRunnable#runTestCase(javax.faces.context.FacesContext)
-// */
-// public void runTestCase(FacesContext context) throws Throwable {
-// context.getExternalContext().getRequestMap().put("test", new Bean());
-// Skin skin = SkinFactory.getInstance().getSkin(context);
-// assertNotNull(skin);
-// assertEquals("TEST", skin.getRenderKitId(context));
-// assertEquals("binded.string", skin.getParameter(context, "bind.property"));
-// assertEquals("bindedstring", skin.getParameter(context, "string.property"));
-// assertEquals("10", skin.getParameter(context, "int.property"));
-// assertNull(skin.getParameter(context, "notexist"));
-// }
-//
-// }
-//
-// /**
-// * Test skin factory for thread-safe.
-// */
-// public void testThreadsafe() {
-// TestCaseRunnable[] runnables = new TestCaseRunnable[20];
-// for (int i = 0; i < runnables.length; i++) {
-// runnables[i] = new SkinTestRunnable();
-//
-// }
-// this.runTestCaseRunnables(runnables);
-// }
-// /*
-// * (non-Javadoc)
-// *
-// * @see com.exadel.vcp.tests.VcpJsfTestCase#getSkinName()
-// */
-// protected String getSkinName() {
-// // TODO Auto-generated method stub
-// return "#{skin.name}";
-// }
-//}
-
-
-
13 years, 8 months
JBoss Rich Faces SVN: r22097 - modules/tests/metamer/trunk/application/src/main/webapp/components/richHashParam.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-03-09 05:35:12 -0500 (Wed, 09 Mar 2011)
New Revision: 22097
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richHashParam/simple.xhtml
Log:
hashParameter - popup panel sample - added fix for shadow (RFPL-1243)
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richHashParam/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richHashParam/simple.xhtml 2011-03-09 10:34:43 UTC (rev 22096)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richHashParam/simple.xhtml 2011-03-09 10:35:12 UTC (rev 22097)
@@ -72,10 +72,10 @@
<rich:componentControl target="popupPanel" operation="show">
<a4j:param noEscape="true" value="event" />
<rich:hashParam>
- <f:param name="width" value="543px" />
- <f:param name="height" value="345px" />
- <f:param name="minWidth" value="300px" />
- <f:param name="minHeight" value="150px" />
+ <f:param name="width" value="543" />
+ <f:param name="height" value="345" />
+ <f:param name="minWidth" value="300" />
+ <f:param name="minHeight" value="150" />
<a4j:param noEscape="true" name="left" value="33+44" />
<a4j:param noEscape="true" name="top" value="55-33" />
</rich:hashParam>
13 years, 8 months
JBoss Rich Faces SVN: r22096 - modules/tests/metamer/trunk/application/src/main/webapp/templates.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-03-09 05:34:43 -0500 (Wed, 09 Mar 2011)
New Revision: 22096
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml
Log:
moved commented code because it is considered as component in grid
Modified: modules/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml 2011-03-09 10:34:14 UTC (rev 22095)
+++ modules/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml 2011-03-09 10:34:43 UTC (rev 22096)
@@ -65,12 +65,6 @@
<h:outputLabel id="localeLabel" value="Locale" for="locale" />
<h:outputText id="locale" value="#{facesContext.viewRoot.locale}" />
-
- <!--
- TODO: disabled because of MyFaces issue: MYFACES-3061 (RF-10668)
- <h:outputLabel id="showUiDebugLabel" value="Show ui:debug" for="showUiDebug" />
- <h:outputText id="showUiDebug" value="Ctrl+Shift+L " />
- -->
<h:outputLabel id="renderCheckerLabel" value="Render Checker" for="renderChecker"/>
<a4j:outputPanel id="renderChecker">
@@ -96,6 +90,9 @@
<!--
TODO: disabled because of MyFaces issue: MYFACES-3061 (RF-10668)
+ h:outputLabel id="showUiDebugLabel" value="Show ui:debug" for="showUiDebug"
+ h:outputText id="showUiDebug" value="Ctrl+Shift+L "
+
ui:debug hotkey="L"
-->
</h:panelGrid>
13 years, 8 months
JBoss Rich Faces SVN: r22095 - modules/tests/metamer/trunk/application.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-03-09 05:34:14 -0500 (Wed, 09 Mar 2011)
New Revision: 22095
Modified:
modules/tests/metamer/trunk/application/pom.xml
Log:
added mojarra_2_1-development profile
Modified: modules/tests/metamer/trunk/application/pom.xml
===================================================================
--- modules/tests/metamer/trunk/application/pom.xml 2011-03-09 10:15:02 UTC (rev 22094)
+++ modules/tests/metamer/trunk/application/pom.xml 2011-03-09 10:34:14 UTC (rev 22095)
@@ -537,6 +537,21 @@
</dependencies>
</profile>
<profile>
+ <id>mojarra_2_1-development</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.1.0-b11</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>2.1.0-b11</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
<id>jee-development</id>
<dependencies>
<dependency>
13 years, 8 months
JBoss Rich Faces SVN: r22094 - in modules/tests/metamer/trunk/application/src/main: java/org/richfaces/tests/metamer/bean and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2011-03-09 05:15:02 -0500 (Wed, 09 Mar 2011)
New Revision: 22094
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichValidatorBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/converter/
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/converter/EmptyStringToNullConverter.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/AssertFalseBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/AssertTrueBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/DecimalMinMaxBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/DigitsBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/FutureBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MaxBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MinBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MinMaxBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/NotEmptyBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/NotNullBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/PastBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/PatternBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/SizeBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/Validable.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/
modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csv.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/jsr303.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/list.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
Log:
added 2 pages for testing validation
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-03-09 09:27:32 UTC (rev 22093)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -161,6 +161,7 @@
components.put("richToolbarGroup", "Rich Toolbar Group");
components.put("richTooltip", "Rich Tooltip");
components.put("richTree", "Rich Tree");
+ components.put("richValidator", "Rich Validator");
}
private void createSkinList() {
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichValidatorBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichValidatorBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichValidatorBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.bean;
+
+import java.io.Serializable;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+
+import org.richfaces.component.behavior.ClientValidatorImpl;
+import org.richfaces.tests.metamer.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for rich:validator.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "richValidatorBean")
+@ViewScoped
+public class RichValidatorBean implements Serializable {
+
+ private static final long serialVersionUID = -1L;
+ private static Logger logger;
+ private Attributes attributes;
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.debug("initializing bean " + getClass().getName());
+
+ attributes = Attributes.getBehaviorAttributesFromFacesConfig(ClientValidatorImpl.class, getClass());
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/converter/EmptyStringToNullConverter.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/converter/EmptyStringToNullConverter.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/converter/EmptyStringToNullConverter.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.converter;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+
+/**
+ * Converter used for converting empty strings to null.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@FacesConverter(value = "emptyStringToNullConverter")
+public class EmptyStringToNullConverter implements Converter {
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAsObject(FacesContext context, UIComponent component, String value) {
+ if (value.isEmpty()) {
+ return null;
+ } else {
+ return value;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getAsString(FacesContext context, UIComponent component, Object value) {
+ if (value == null) {
+ return "";
+ }
+
+ return value.toString();
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/AssertFalseBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/AssertFalseBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/AssertFalseBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.AssertFalse;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author asmirnov, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class AssertFalseBean extends Validable<Boolean> {
+
+ public AssertFalseBean() {
+ value = false;
+ }
+
+ @AssertFalse
+ @Override
+ public Boolean getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(Boolean intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Boolean, false";
+ }
+
+ @Override
+ public String getLabel() {
+ return "assertFalse";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/AssertTrueBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/AssertTrueBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/AssertTrueBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.AssertTrue;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author asmirnov, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class AssertTrueBean extends Validable<Boolean> {
+
+ public AssertTrueBean() {
+ value = true;
+ }
+
+ @AssertTrue
+ @Override
+ public Boolean getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(Boolean intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Boolean, true";
+ }
+
+ @Override
+ public String getLabel() {
+ return "assertTrue";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/DecimalMinMaxBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/DecimalMinMaxBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/DecimalMinMaxBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import java.math.BigDecimal;
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.DecimalMax;
+import javax.validation.constraints.DecimalMin;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class DecimalMinMaxBean extends Validable<BigDecimal> {
+
+ public DecimalMinMaxBean() {
+ value = new BigDecimal(3);
+ }
+
+ @DecimalMin("2.5")
+ @DecimalMax("9.688")
+ @Override
+ public BigDecimal getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(BigDecimal intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Decimal, from 2.5 to 9.688";
+ }
+
+ @Override
+ public String getLabel() {
+ return "decimalMinMax";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/DigitsBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/DigitsBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/DigitsBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import java.math.BigDecimal;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.Digits;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class DigitsBean extends Validable<BigDecimal> {
+
+ public DigitsBean() {
+ value = new BigDecimal("2.567");
+ }
+
+ @Digits(integer = 3, fraction = 4)
+ @Override
+ public BigDecimal getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(BigDecimal intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Decimal, 3 digits integer and 4 fraction";
+ }
+
+ @Override
+ public String getLabel() {
+ return "digits";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/FutureBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/FutureBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/FutureBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import java.util.Date;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.Future;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class FutureBean extends Validable<Date> {
+
+ public FutureBean() {
+ value = new Date(System.currentTimeMillis() + 4 * 24 * 3600 * 1000);
+ }
+
+ @Future
+ @Override
+ public Date getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(Date intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Date, future";
+ }
+
+ @Override
+ public String getLabel() {
+ return "future";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MaxBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MaxBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MaxBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.Max;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author asmirnov, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class MaxBean extends Validable<Integer> {
+
+ public MaxBean() {
+ value = 9;
+ }
+
+ @Max(10)
+ @Override
+ public Integer getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(Integer intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Integer, max 10";
+ }
+
+ @Override
+ public String getLabel() {
+ return "max";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MinBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MinBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MinBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.Min;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author asmirnov, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class MinBean extends Validable<Integer> {
+
+ public MinBean() {
+ value = 4;
+ }
+
+ @Min(2)
+ @Override
+ public Integer getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(Integer intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Integer, min 2";
+ }
+
+ @Override
+ public String getLabel() {
+ return "min";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MinMaxBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MinMaxBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/MinMaxBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author asmirnov, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class MinMaxBean extends Validable<Integer> {
+
+ public MinMaxBean() {
+ value = 4;
+ }
+
+ @Min(2)
+ @Max(10)
+ @Override
+ public Integer getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(Integer intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Integer, from 2 to 10";
+ }
+
+ @Override
+ public String getLabel() {
+ return "minMax";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/NotEmptyBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/NotEmptyBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/NotEmptyBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import javax.faces.bean.ManagedBean;
+import org.hibernate.validator.constraints.NotEmpty;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author asmirnov, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class NotEmptyBean extends Validable<String> {
+
+ public NotEmptyBean() {
+ value = "RichFaces 4";
+ }
+
+ @NotEmpty
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(String text) {
+ this.value = text;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Text, not empty";
+ }
+
+ @Override
+ public String getLabel() {
+ return "notEmpty";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/NotNullBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/NotNullBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/NotNullBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author asmirnov, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class NotNullBean extends Validable<String> {
+
+ public NotNullBean() {
+ value = "RichFaces 4";
+ }
+
+ @NotNull
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(String text) {
+ this.value = text;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Text value, not null";
+ }
+
+ @Override
+ public String getLabel() {
+ return "notNull";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/PastBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/PastBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/PastBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import java.util.Date;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.Past;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class PastBean extends Validable<Date> {
+
+ public PastBean() {
+ value = new Date(System.currentTimeMillis() - 4 * 24 * 3600 * 1000);
+ }
+
+ @Past
+ @Override
+ public Date getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(Date intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Date, past";
+ }
+
+ @Override
+ public String getLabel() {
+ return "past";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/PatternBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/PatternBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/PatternBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.Pattern;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author asmirnov, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class PatternBean extends Validable<String> {
+
+ public PatternBean() {
+ value = "richFaces 4";
+ }
+
+ @Pattern(regexp = "[a-z].*")
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(String text) {
+ this.value = text;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Text, pattern '[a-z].*'";
+ }
+
+ @Override
+ public String getLabel() {
+ return "pattern";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/SizeBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/SizeBean.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/SizeBean.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.faces.bean.ManagedBean;
+import javax.validation.constraints.Size;
+
+/**
+ * Helper bean for testing JSR-303.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean
+public class SizeBean extends Validable<List<String>> {
+
+ public SizeBean() {
+ value = new ArrayList<String>();
+ value.add("A");
+ value.add("B");
+ }
+
+ @Size(min = 2, max = 4)
+ @Override
+ public List<String> getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(List<String> intValue) {
+ this.value = intValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Selection size, from 2 to 4";
+ }
+
+ @Override
+ public String getLabel() {
+ return "size";
+ }
+}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/Validable.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/Validable.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/Validable.java 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.validation;
+
+import java.lang.reflect.ParameterizedType;
+
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+/**
+ * Helper abstract class for testing JSR-303.
+ *
+ * @author asmirnov, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public abstract class Validable<T> {
+
+ T value;
+
+ public T getValue() {
+ return value;
+ }
+
+ public void setValue(T value) {
+ this.value = value;
+ }
+
+ public Converter getConverter() {
+ Class<T> parameterType = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
+ return FacesContext.getCurrentInstance().getApplication().createConverter(parameterType);
+ }
+
+ public abstract String getDescription();
+
+ public abstract String getLabel();
+}
Added: modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csv.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csv.xhtml (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csv.xhtml 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,321 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"
+ xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
+
+ <!--
+JBoss, Home of Professional Open Source
+Copyright 2010-2011, 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.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="view">
+ <f:metadata>
+ <f:viewParam name="templates" value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="head">
+
+ </ui:define>
+
+ <ui:define name="component">
+ <script type="text/javascript">
+ function setCorrectValues() {
+ var today = new Date();
+ var inPast = new Date(today.getTime() - 4 * 24 * 3600 * 1000);
+ var inFuture = new Date(today.getTime() + 4 * 24 * 3600 * 1000);
+
+ $('input[id$=assertTrue]')[0].checked = true;
+ $('input[id$=assertFalse]')[0].checked = false;
+ $('input[id$=decimalMinMax]').val('3');
+ $('input[id$=digits]').val('2.567');
+ $('input[id$=max]').val('9');
+ $('input[id$=min]').val('4');
+ $('input[id$=minMax]').val('4');
+ $('input[id$=notEmpty]').val('RichFaces 4');
+ $('input[id$=notNull]').val('RichFaces 4');
+ $('input[id$=pattern]').val('richFaces 4');
+ $('input[id$=past]').val(inPast.format("d mmm yyyy"));
+ $('input[id$=future]').val(inFuture.format("d mmm yyyy"));
+ $('input[value=A]')[0].checked=true
+ $('input[value=B]')[0].checked=true
+ $('input[value=C]')[0].checked=false
+ $('input[value=D]')[0].checked=false
+ $('input[value=E]')[0].checked=false
+ $('input[value=F]')[0].checked=false
+ }
+
+ function setWrongValues() {
+ var today = new Date();
+ var inPast = new Date(today.getTime() - 4 * 24 * 3600 * 1000);
+ var inFuture = new Date(today.getTime() + 4 * 24 * 3600 * 1000);
+
+ $('input[id$=assertTrue]')[0].checked = false;
+ $('input[id$=assertFalse]')[0].checked = true;
+ $('input[id$=decimalMinMax]').val('10.668');
+ $('input[id$=digits]').val('15.627123');
+ $('input[id$=max]').val('122');
+ $('input[id$=min]').val('-544');
+ $('input[id$=minMax]').val('-5');
+ $('input[id$=notEmpty]').val('');
+ $('input[id$=notNull]').val('');
+ $('input[id$=pattern]').val('@@@');
+ $('input[id$=past]').val(inFuture.format("d mmm yyyy"));
+ $('input[id$=future]').val(inPast.format("d mmm yyyy"));
+ $('input[value=A]')[0].checked=false
+ $('input[value=B]')[0].checked=false
+ $('input[value=C]')[0].checked=false
+ $('input[value=D]')[0].checked=false
+ $('input[value=E]')[0].checked=false
+ $('input[value=F]')[0].checked=true
+ }
+ </script>
+
+ <input id="setCorrectValuesButton" type="button" value="set correct values" onclick="setCorrectValues()"/>
+ <input id="setWrongValuesButton" type="button" value="set wrong values" onclick="setWrongValues()"/>
+
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="assertTrue" value="#{assertTrueBean.description}" />
+ <h:selectBooleanCheckbox id="assertTrue" value="#{assertTrueBean.value}" label="#{assertTrueBean.label}">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:selectBooleanCheckbox>
+ <rich:message id="assertTrueMsg" for="assertTrue" />
+
+ <h:outputLabel for="assertFalse" value="#{assertFalseBean.description}" />
+ <h:selectBooleanCheckbox id="assertFalse" value="#{assertFalseBean.value}" label="#{assertFalseBean.label}">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:selectBooleanCheckbox>
+ <rich:message id="assertFalseMsg" for="assertFalse" />
+
+ <h:outputLabel for="decimalMinMax" value="#{decimalMinMaxBean.description}" />
+ <h:inputText id="decimalMinMax" value="#{decimalMinMaxBean.value}" label="#{decimalMinMaxBean.label}" converter="#{decimalMinMaxBean.converter}">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="decimalMinMaxMsg" for="decimalMinMax" />
+
+ <h:outputLabel for="digits" value="#{digitsBean.description}" />
+ <h:inputText id="digits" value="#{digitsBean.value}" label="#{digitsBean.label}" converter="#{digitsBean.converter}">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="digitsMsg" for="digits" />
+
+ <h:outputLabel for="max" value="#{maxBean.description}" />
+ <h:inputText id="max" value="#{maxBean.value}" label="#{maxBean.label}" converter="#{maxBean.converter}">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="maxMsg" for="max" />
+
+ <h:outputLabel for="min" value="#{minBean.description}" />
+ <h:inputText id="min" value="#{minBean.value}" label="#{minBean.label}" converter="#{minBean.converter}">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="minMsg" for="min" />
+
+ <h:outputLabel for="minMax" value="#{minMaxBean.description}" />
+ <h:inputText id="minMax" value="#{minMaxBean.value}" label="#{minMaxBean.label}" converter="#{minMaxBean.converter}">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="minMaxMsg" for="minMax" />
+
+ <h:outputLabel for="notEmpty" value="#{notEmptyBean.description}" />
+ <h:inputText id="notEmpty" value="#{notEmptyBean.value}" label="#{notEmptyBean.label}" converter="#{notEmptyBean.converter}">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="notEmptyMsg" for="notEmpty" />
+
+ <h:outputLabel for="notNull" value="#{notNullBean.description}" />
+ <h:inputText id="notNull" value="#{notNullBean.value}" label="#{notNullBean.label}" converter="emptyStringToNullConverter">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="notNullMsg" for="notNull" />
+
+ <h:outputLabel for="pattern" value="#{patternBean.description}" />
+ <h:inputText id="pattern" value="#{patternBean.value}" label="#{patternBean.label}" converter="#{patternBean.converter}">
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="patternMsg" for="pattern" />
+
+ <h:outputLabel for="past" value="#{pastBean.description}" />
+ <h:inputText id="past" value="#{pastBean.value}" label="#{pastBean.label}" >
+ <f:convertDateTime pattern="d MMM yyyy"/>
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="pastMsg" for="past" />
+
+ <h:outputLabel for="future" value="#{futureBean.description}" />
+ <h:inputText id="future" value="#{futureBean.value}" label="#{futureBean.label}" >
+ <f:convertDateTime pattern="d MMM yyyy"/>
+ <rich:validator data="#{richValidator.attributes['data'].value}"
+ disabled="#{richValidator.attributes['disabled'].value}"
+ immediate="#{richValidator.attributes['immediate'].value}"
+ onbeforedomupdate="#{richValidator.attributes['onbeforedomupdate'].value}"
+ onbeforesubmit="#{richValidator.attributes['onbeforesubmit'].value}"
+ onbegin="#{richValidator.attributes['onbegin'].value}"
+ oncomplete="#{richValidator.attributes['oncomplete'].value}"
+ onerror="#{richValidator.attributes['onerror'].value}"
+ queueId="#{richValidator.attributes['queueId'].value}"
+ status="#{richValidator.attributes['status'].value}"
+ />
+ </h:inputText>
+ <rich:message id="futureMsg" for="future" />
+
+ <h:outputLabel for="size" value="#{sizeBean.description}" />
+ <h:selectManyCheckbox id="size" value="#{sizeBean.value}" label="#{sizeBean.label}" >
+ <f:selectItem itemValue="A" itemLabel="A"/>
+ <f:selectItem itemValue="B" itemLabel="B"/>
+ <f:selectItem itemValue="C" itemLabel="C"/>
+ <f:selectItem itemValue="D" itemLabel="D"/>
+ <f:selectItem itemValue="E" itemLabel="E"/>
+ <f:selectItem itemValue="F" itemLabel="F"/>
+ </h:selectManyCheckbox>
+ <rich:message id="sizeMsg" for="size" />
+ </h:panelGrid>
+
+ <br/>
+
+ <h:commandButton id="hButton" value="h:commandButton" style="margin-right: 10px;"/>
+ <a4j:commandButton id="a4jButton" value="a4j:commandButton"/>
+
+ <br/>
+ <rich:messages/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <metamer:attributes value="#{richValidatorBean.attributes}" id="attributes"/>
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added: modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/jsr303.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/jsr303.xhtml (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/jsr303.xhtml 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"
+ xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
+
+ <!--
+JBoss, Home of Professional Open Source
+Copyright 2010-2011, 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.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="view">
+ <f:metadata>
+ <f:viewParam name="templates" value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="head">
+
+ </ui:define>
+
+ <ui:define name="component">
+ <script type="text/javascript">
+ function setCorrectValues() {
+ var today = new Date();
+ var inPast = new Date(today.getTime() - 4 * 24 * 3600 * 1000);
+ var inFuture = new Date(today.getTime() + 4 * 24 * 3600 * 1000);
+
+ $('input[id$=assertTrue]')[0].checked = true;
+ $('input[id$=assertFalse]')[0].checked = false;
+ $('input[id$=decimalMinMax]').val('3');
+ $('input[id$=digits]').val('2.567');
+ $('input[id$=max]').val('9');
+ $('input[id$=min]').val('4');
+ $('input[id$=minMax]').val('4');
+ $('input[id$=notEmpty]').val('RichFaces 4');
+ $('input[id$=notNull]').val('RichFaces 4');
+ $('input[id$=pattern]').val('richFaces 4');
+ $('input[id$=past]').val(inPast.format("d mmm yyyy"));
+ $('input[id$=future]').val(inFuture.format("d mmm yyyy"));
+ $('input[value=A]')[0].checked=true
+ $('input[value=B]')[0].checked=true
+ $('input[value=C]')[0].checked=false
+ $('input[value=D]')[0].checked=false
+ $('input[value=E]')[0].checked=false
+ $('input[value=F]')[0].checked=false
+ }
+
+ function setWrongValues() {
+ var today = new Date();
+ var inPast = new Date(today.getTime() - 4 * 24 * 3600 * 1000);
+ var inFuture = new Date(today.getTime() + 4 * 24 * 3600 * 1000);
+
+ $('input[id$=assertTrue]')[0].checked = false;
+ $('input[id$=assertFalse]')[0].checked = true;
+ $('input[id$=decimalMinMax]').val('10.668');
+ $('input[id$=digits]').val('15.627123');
+ $('input[id$=max]').val('122');
+ $('input[id$=min]').val('-544');
+ $('input[id$=minMax]').val('-5');
+ $('input[id$=notEmpty]').val('');
+ $('input[id$=notNull]').val('');
+ $('input[id$=pattern]').val('@@@');
+ $('input[id$=past]').val(inFuture.format("d mmm yyyy"));
+ $('input[id$=future]').val(inPast.format("d mmm yyyy"));
+ $('input[value=A]')[0].checked=false
+ $('input[value=B]')[0].checked=false
+ $('input[value=C]')[0].checked=false
+ $('input[value=D]')[0].checked=false
+ $('input[value=E]')[0].checked=false
+ $('input[value=F]')[0].checked=true
+ }
+ </script>
+
+ <input id="setCorrectValuesButton" type="button" value="set correct values" onclick="setCorrectValues()"/>
+ <input id="setWrongValuesButton" type="button" value="set wrong values" onclick="setWrongValues()"/>
+
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="assertTrue" value="#{assertTrueBean.description}" />
+ <h:selectBooleanCheckbox id="assertTrue" value="#{assertTrueBean.value}" label="#{assertTrueBean.label}" />
+ <rich:message id="assertTrueMsg" for="assertTrue" />
+
+ <h:outputLabel for="assertFalse" value="#{assertFalseBean.description}" />
+ <h:selectBooleanCheckbox id="assertFalse" value="#{assertFalseBean.value}" label="#{assertFalseBean.label}" />
+ <rich:message id="assertFalseMsg" for="assertFalse" />
+
+ <h:outputLabel for="decimalMinMax" value="#{decimalMinMaxBean.description}" />
+ <h:inputText id="decimalMinMax" value="#{decimalMinMaxBean.value}" label="#{decimalMinMaxBean.label}" converter="#{decimalMinMaxBean.converter}"/>
+ <rich:message id="decimalMinMaxMsg" for="decimalMinMax" />
+
+ <h:outputLabel for="digits" value="#{digitsBean.description}" />
+ <h:inputText id="digits" value="#{digitsBean.value}" label="#{digitsBean.label}" converter="#{digitsBean.converter}"/>
+ <rich:message id="digitsMsg" for="digits" />
+
+ <h:outputLabel for="max" value="#{maxBean.description}" />
+ <h:inputText id="max" value="#{maxBean.value}" label="#{maxBean.label}" converter="#{maxBean.converter}"/>
+ <rich:message id="maxMsg" for="max" />
+
+ <h:outputLabel for="min" value="#{minBean.description}" />
+ <h:inputText id="min" value="#{minBean.value}" label="#{minBean.label}" converter="#{minBean.converter}"/>
+ <rich:message id="minMsg" for="min" />
+
+ <h:outputLabel for="minMax" value="#{minMaxBean.description}" />
+ <h:inputText id="minMax" value="#{minMaxBean.value}" label="#{minMaxBean.label}" converter="#{minMaxBean.converter}"/>
+ <rich:message id="minMaxMsg" for="minMax" />
+
+ <h:outputLabel for="notEmpty" value="#{notEmptyBean.description}" />
+ <h:inputText id="notEmpty" value="#{notEmptyBean.value}" label="#{notEmptyBean.label}" converter="#{notEmptyBean.converter}"/>
+ <rich:message id="notEmptyMsg" for="notEmpty" />
+
+ <h:outputLabel for="notNull" value="#{notNullBean.description}" />
+ <h:inputText id="notNull" value="#{notNullBean.value}" label="#{notNullBean.label}" converter="emptyStringToNullConverter"/>
+ <rich:message id="notNullMsg" for="notNull" />
+
+ <h:outputLabel for="pattern" value="#{patternBean.description}" />
+ <h:inputText id="pattern" value="#{patternBean.value}" label="#{patternBean.label}" converter="#{patternBean.converter}"/>
+ <rich:message id="patternMsg" for="pattern" />
+
+ <h:outputLabel for="past" value="#{pastBean.description}" />
+ <h:inputText id="past" value="#{pastBean.value}" label="#{pastBean.label}" >
+ <f:convertDateTime pattern="d MMM yyyy"/>
+ </h:inputText>
+ <rich:message id="pastMsg" for="past" />
+
+ <h:outputLabel for="future" value="#{futureBean.description}" />
+ <h:inputText id="future" value="#{futureBean.value}" label="#{futureBean.label}" >
+ <f:convertDateTime pattern="d MMM yyyy"/>
+ </h:inputText>
+ <rich:message id="futureMsg" for="future" />
+
+ <h:outputLabel for="size" value="#{sizeBean.description}" />
+ <h:selectManyCheckbox id="size" value="#{sizeBean.value}" label="#{sizeBean.label}" >
+ <f:selectItem itemValue="A" itemLabel="A"/>
+ <f:selectItem itemValue="B" itemLabel="B"/>
+ <f:selectItem itemValue="C" itemLabel="C"/>
+ <f:selectItem itemValue="D" itemLabel="D"/>
+ <f:selectItem itemValue="E" itemLabel="E"/>
+ <f:selectItem itemValue="F" itemLabel="F"/>
+ </h:selectManyCheckbox>
+ <rich:message id="sizeMsg" for="size" />
+ </h:panelGrid>
+
+ <br/>
+
+ <h:commandButton id="hButton" value="h:commandButton" style="margin-right: 10px;"/>
+ <a4j:commandButton id="a4jButton" value="a4j:commandButton"/>
+
+ <br/>
+ <rich:messages/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added: modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/list.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/list.xhtml (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/list.xhtml 2011-03-09 10:15:02 UTC (rev 22094)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
+
+ <!--
+JBoss, Home of Professional Open Source
+Copyright 2010-2011, 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.
+ -->
+
+ <ui:composition template="/templates/list.xhtml">
+
+ <ui:define name="pageTitle">Rich Validator</ui:define>
+
+ <ui:define name="links">
+
+ <metamer:testPageLink id="csv" outcome="csv" value="Client Side Validation">
+ Simple page that contains <b>rich:validator</b> testing the support for JSR-303 and input boxes for all validator's attributes.
+ </metamer:testPageLink>
+
+ <metamer:testPageLink id="jsr303" outcome="jsr303" value="JSR-303 Bean Validation">
+ Page containing input with various JSR-303 validators.
+ </metamer:testPageLink>
+
+ </ui:define>
+
+ </ui:composition>
+
+</html>
13 years, 8 months
JBoss Rich Faces SVN: r22093 - in modules/tests/metamer/trunk: application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-03-09 04:27:32 -0500 (Wed, 09 Mar 2011)
New Revision: 22093
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/AbstractNode.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadable.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/ModelNodeImpl.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/RecursiveNodeImpl.java
modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/TestRichTreeModelRecursiveAdaptorBeanSerialization.java
Removed:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadingListener.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/Reference.java
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeModelRecursiveAdaptorBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/KeyConverter.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadingChecker.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/ModelNode.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/Node.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/RecursiveNode.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTreeModelAdaptor/TestTreeModelAdaptorSelection.java
Log:
refactored tree to support serialization (needed for MyFaces) (RF-1224)
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeModelRecursiveAdaptorBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeModelRecursiveAdaptorBean.java 2011-03-09 09:26:00 UTC (rev 22092)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeModelRecursiveAdaptorBean.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -30,15 +30,15 @@
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.PostConstruct;
+import javax.el.ELContext;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
+import javax.faces.context.FacesContext;
import org.richfaces.component.UITreeModelRecursiveAdaptor;
import org.richfaces.tests.metamer.Attributes;
-import org.richfaces.tests.metamer.model.treeAdaptor.LazyLoadingListener;
-import org.richfaces.tests.metamer.model.treeAdaptor.Node;
import org.richfaces.tests.metamer.model.treeAdaptor.RecursiveNode;
-import org.richfaces.tests.metamer.model.treeAdaptor.Reference;
+import org.richfaces.tests.metamer.model.treeAdaptor.RecursiveNodeImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +51,7 @@
public class RichTreeModelRecursiveAdaptorBean implements Serializable {
- private static final long serialVersionUID = 4008175400649809L;
+ private static final long serialVersionUID = 1L;
private static Logger logger;
private static List<RecursiveNode> rootNodes;
@@ -64,17 +64,9 @@
/*
* Nodes which was loaded lazily in the current request
*/
- private Set<Node> lazyInitializedNodes = new LinkedHashSet<Node>();
+ private Set<String> lazyInitializedNodes = new LinkedHashSet<String>();
- private LazyLoadingListener<Node> nodeLazyLoadingListener = new LazyLoadingListener<Node>() {
- private static final long serialVersionUID = 1L;
-
- public void notify(Node node) {
- lazyInitializedNodes.add(node);
- };
- };
-
- public Set<Node> getLazyInitializedNodes() {
+ public Set<String> getLazyInitializedNodes() {
return lazyInitializedNodes;
}
@@ -101,16 +93,7 @@
public List<RecursiveNode> getRootNodes() {
if (!rootNodesInitialized) {
- rootNodes = RecursiveNode.createChildren(null, leafChildrenNullable,
- new Reference<LazyLoadingListener<Node>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public LazyLoadingListener<Node> get() {
- return nodeLazyLoadingListener;
- }
- });
- rootNodesInitialized = true;
+ rootNodes = RecursiveNodeImpl.createChildren(true, "", 1, false);
}
return rootNodes;
}
@@ -138,4 +121,9 @@
public static List<RecursiveNode> getRootNodesStatically() {
return rootNodes;
}
+
+ public static RichTreeModelRecursiveAdaptorBean getFacesContext() {
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+ return (RichTreeModelRecursiveAdaptorBean) elContext.getELResolver().getValue(elContext, null, "richTreeModelRecursiveAdaptorBean");
+ }
}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/AbstractNode.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/AbstractNode.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/AbstractNode.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.model.treeAdaptor;
+
+import java.io.Serializable;
+
+import org.richfaces.tests.metamer.bean.RichTreeModelRecursiveAdaptorBean;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class AbstractNode implements Serializable, LazyLoadable, Node {
+
+ private static final long serialVersionUID = 1L;
+
+ private boolean isRoot;
+ private int number;
+ private String parentLabel;
+
+ protected AbstractNode(boolean isRoot, int number, String parentLabel) {
+ this.number = number;
+ this.parentLabel = parentLabel;
+ this.isRoot = isRoot;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.INode#isRoot()
+ */
+ @Override
+ public boolean isRoot() {
+ return isRoot;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.INode#getNumber()
+ */
+ @Override
+ public int getNumber() {
+ return number;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.INode#getParentLabel()
+ */
+ @Override
+ public String getParentLabel() {
+ return parentLabel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.INode#getLabel()
+ */
+ @Override
+ public abstract String getLabel();
+
+ @Override
+ public void notifyLoaded() {
+ RichTreeModelRecursiveAdaptorBean bean = RichTreeModelRecursiveAdaptorBean.getFacesContext();
+ bean.getLazyInitializedNodes().add(this.getLabel());
+ }
+}
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/KeyConverter.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/KeyConverter.java 2011-03-09 09:26:00 UTC (rev 22092)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/KeyConverter.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -66,7 +66,7 @@
break;
case 'K':
- for (ModelNode.K key : model.getMap().keySet()) {
+ for (ModelNodeImpl.K key : model.getMap().keySet()) {
if (key.number == num) {
return key;
}
@@ -85,8 +85,8 @@
}
public String getAsString(FacesContext context, UIComponent component, Object value) {
- if (value instanceof ModelNode.K) {
- ModelNode.K k = (ModelNode.K) value;
+ if (value instanceof ModelNodeImpl.K) {
+ ModelNodeImpl.K k = (ModelNodeImpl.K) value;
return k.getLabel();
}
Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadable.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadable.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadable.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.model.treeAdaptor;
+
+/**
+ * <p>
+ * Marks that given object can be checked for lazy loading.
+ * </p>
+ *
+ * <p>
+ * Needs to implement {@link #notifyLoaded()} which performs notification about accessing object by external entity.
+ * </p>
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public interface LazyLoadable {
+ void notifyLoaded();
+}
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadingChecker.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadingChecker.java 2011-03-09 09:26:00 UTC (rev 22092)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadingChecker.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -1,3 +1,24 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.model.treeAdaptor;
import static java.lang.reflect.Modifier.isStatic;
@@ -3,52 +24,36 @@
import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
-import javassist.util.proxy.MethodHandler;
-import javassist.util.proxy.ProxyFactory;
-import javassist.util.proxy.ProxyObject;
+/**
+ * <p>
+ * Wraps {@link LazyLoadable} entity with proxy which performs notification by {@link LazyLoadable#notifyLoaded()} to
+ * let know about accessing methods of that wrapped instance.
+ * </p>
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public final class LazyLoadingChecker<T extends Serializable & LazyLoadable> implements InvocationHandler, Serializable {
+ private static final long serialVersionUID = 1L;
-import org.apache.commons.lang.Validate;
-
-public final class LazyLoadingChecker<T> implements MethodHandler, Serializable {
- private static final long serialVersionUID = 1L;
-
T instance;
- Reference<LazyLoadingListener<T>> listenerReference = null;
- private LazyLoadingChecker(T instance, Reference<LazyLoadingListener<T>> listenerReference) {
+ private LazyLoadingChecker(T instance) {
this.instance = instance;
- this.listenerReference = listenerReference;
}
@SuppressWarnings("unchecked")
- public static <T> T wrapInstance(T instance, Reference<LazyLoadingListener<T>> listenerReference) {
- Validate.notNull(listenerReference);
- ProxyFactory f = new ProxyFactory();
- f.setSuperclass(instance.getClass());
- Class<?> c = f.createClass();
-
- T proxy;
- try {
- proxy = (T) c.newInstance();
- } catch (InstantiationException e) {
- throw new IllegalStateException(e);
- } catch (IllegalAccessException e) {
- throw new IllegalStateException(e);
- }
-
- ((ProxyObject) proxy).setHandler(new LazyLoadingChecker<T>(instance, listenerReference));
- return proxy;
+ public static <T extends Serializable & LazyLoadable> T wrapInstance(T instance) {
+ return (T) Proxy.newProxyInstance(instance.getClass().getClassLoader(), instance.getClass().getInterfaces(),
+ new LazyLoadingChecker<T>(instance));
}
@Override
- public Object invoke(Object self, Method m, Method proceed, Object[] args) throws Throwable {
+ public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
if (!isStatic(m.getModifiers())) {
- LazyLoadingListener<T> listener = listenerReference.get();
- if (listener != null) {
- listener.notify(instance);
- } else {
- throw new IllegalStateException();
- }
+ instance.notifyLoaded();
}
Object result = m.invoke(instance, args);
Deleted: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadingListener.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadingListener.java 2011-03-09 09:26:00 UTC (rev 22092)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/LazyLoadingListener.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -1,7 +0,0 @@
-package org.richfaces.tests.metamer.model.treeAdaptor;
-
-import java.io.Serializable;
-
-public interface LazyLoadingListener<T> extends Serializable {
- void notify(T instance);
-}
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/ModelNode.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/ModelNode.java 2011-03-09 09:26:00 UTC (rev 22092)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/ModelNode.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -21,137 +21,24 @@
*******************************************************************************/
package org.richfaces.tests.metamer.model.treeAdaptor;
-import java.io.Serializable;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
+import org.richfaces.tests.metamer.model.treeAdaptor.ModelNodeImpl.A;
+import org.richfaces.tests.metamer.model.treeAdaptor.ModelNodeImpl.B;
+import org.richfaces.tests.metamer.model.treeAdaptor.ModelNodeImpl.K;
+import org.richfaces.tests.metamer.model.treeAdaptor.ModelNodeImpl.V;
+
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class ModelNode extends Node {
- private static final long serialVersionUID = 1L;
+public interface ModelNode extends Node {
+ A getValue();
- private static final int BS = 3;
- private static final int KS = 4;
- List<B> bs;
- Map<K, V> map;
- List<RecursiveNode> rs;
+ List<B> getList();
- public ModelNode() {
- super(null, null, null);
- }
+ Map<K, V> getMap();
- protected ModelNode(Node parent, AtomicReference<Boolean> nullable,
- Reference<LazyLoadingListener<Node>> lazyLoadingListenerReference) {
- super(parent, nullable, lazyLoadingListenerReference);
- }
-
- public static ModelNode getInstance(Node parent, AtomicReference<Boolean> nullable,
- Reference<LazyLoadingListener<Node>> lazyLoadingListenerReference) {
- return lazyLoadingChecker(new ModelNode(parent, nullable, lazyLoadingListenerReference));
- }
-
- public String getLabel() {
- return isRoot() ? "M" : getParent().getLabel() + "-M";
- }
-
- public A getValue() {
- return new A();
- }
-
- public List<B> getList() {
- if (bs == null) {
- bs = new LinkedList<B>();
- for (int i = 0; i < BS; i++) {
- bs.add(new B(i));
- }
- }
- return bs;
- }
-
- public Map<K, V> getMap() {
- if (map == null) {
- map = new LinkedHashMap<K, V>();
- for (int i = 0; i < KS; i++) {
- map.put(new K(i), new V(i));
- }
- }
- return map;
- }
-
- public List<RecursiveNode> getRecursive() {
- if (rs == null) {
- rs = RecursiveNode.createChildren(this, getNullable(), null);
- }
- return rs;
- }
-
- public class A implements Serializable {
- private static final long serialVersionUID = 1L;
-
- public String getLabel() {
- return ModelNode.this.getLabel() + "-A";
- }
- }
-
- public class B implements Serializable {
- private static final long serialVersionUID = 1L;
-
- int number;
-
- public B(int number) {
- this.number = number;
- }
-
- public String getLabel() {
- return ModelNode.this.getLabel() + "-B-" + number;
- }
- }
-
- public class K implements Serializable, Comparable<K> {
- private static final long serialVersionUID = 1L;
-
- int number;
-
- public K(int number) {
- this.number = number;
- }
-
- public String getLabel() {
- return ModelNode.this.getLabel() + "-K-" + number;
- }
-
- @Override
- public int compareTo(K o) {
- return this.number - o.number;
- }
-
- @Override
- public String toString() {
- return Integer.toString(number);
- }
- }
-
- public class V implements Serializable {
- private static final long serialVersionUID = 1L;
-
- int number;
-
- public V(int number) {
- this.number = number;
- }
-
- public String getLabel() {
- return ModelNode.this.getLabel() + "-V-" + number;
- }
- }
-
- @Override
- public String toString() {
- return getLabel();
- }
-}
\ No newline at end of file
+ List<RecursiveNode> getRecursive();
+}
Copied: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/ModelNodeImpl.java (from rev 22092, modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/ModelNode.java)
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/ModelNodeImpl.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/ModelNodeImpl.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.model.treeAdaptor;
+
+import java.io.Serializable;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class ModelNodeImpl extends AbstractNode implements ModelNode {
+ private static final long serialVersionUID = 1L;
+
+ private static final int BS = 3;
+ private static final int KS = 4;
+ List<B> bs;
+ Map<K, V> map;
+ List<RecursiveNode> rs;
+
+ protected ModelNodeImpl(boolean isRoot, int number, String parentLabel) {
+ super(isRoot, number, parentLabel);
+ }
+
+ public static ModelNode getInstance(boolean isRoot, int number, String parentLabel) {
+ ModelNodeImpl modelNode = new ModelNodeImpl(isRoot, number, parentLabel);
+ return LazyLoadingChecker.wrapInstance(modelNode);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IModelNode#getLabel()
+ */
+ @Override
+ public String getLabel() {
+ return isRoot() ? "M" : getParentLabel() + "-M";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IModelNode#getValue()
+ */
+ @Override
+ public A getValue() {
+ return new A(getLabel());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IModelNode#getList()
+ */
+ @Override
+ public List<B> getList() {
+ if (bs == null) {
+ bs = new LinkedList<B>();
+ for (int i = 0; i < BS; i++) {
+ bs.add(new B(getLabel(), i));
+ }
+ }
+ return bs;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IModelNode#getMap()
+ */
+ @Override
+ public Map<K, V> getMap() {
+ if (map == null) {
+ map = new LinkedHashMap<K, V>();
+ for (int i = 0; i < KS; i++) {
+ map.put(new K(getLabel(), i), new V(getLabel(), i));
+ }
+ }
+ return map;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IModelNode#getRecursive()
+ */
+ @Override
+ public List<RecursiveNode> getRecursive() {
+ if (rs == null) {
+ rs = RecursiveNodeImpl.createChildren(false, getLabel(), 1, true);
+ }
+ return rs;
+ }
+
+ public static class A implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ String parentLabel;
+
+ public A(String parentLabel) {
+ this.parentLabel = parentLabel;
+ }
+
+ public String getLabel() {
+ return parentLabel + "-A";
+ }
+ }
+
+ public static class B implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ int number;
+ String parentLabel;
+
+ public B(String parentLabel, int number) {
+ this.parentLabel = parentLabel;
+ this.number = number;
+ }
+
+ public String getLabel() {
+ return parentLabel + "-B-" + number;
+ }
+ }
+
+ public static class K implements Serializable, Comparable<K> {
+ private static final long serialVersionUID = 1L;
+
+ int number;
+ String parentLabel;
+
+ public K(String parentLabel, int number) {
+ this.parentLabel = parentLabel;
+ this.number = number;
+ }
+
+ public String getLabel() {
+ return parentLabel + "-K-" + number;
+ }
+
+ @Override
+ public int compareTo(K o) {
+ return this.getLabel().compareTo(o.getLabel());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ if (obj.getClass() != getClass()) {
+ return false;
+ }
+ K rhs = (K) obj;
+ return new EqualsBuilder().append(getLabel(), rhs.getLabel()).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37).append(getLabel()).toHashCode();
+
+ }
+
+ @Override
+ public String toString() {
+ return Integer.toString(number);
+ }
+ }
+
+ public static class V implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ int number;
+ String parentLabel;
+
+ public V(String parentLabel, int number) {
+ this.parentLabel = parentLabel;
+ this.number = number;
+ }
+
+ public String getLabel() {
+ return parentLabel + "-V-" + number;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getLabel();
+ }
+}
\ No newline at end of file
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/Node.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/Node.java 2011-03-09 09:26:00 UTC (rev 22092)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/Node.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -21,85 +21,18 @@
*******************************************************************************/
package org.richfaces.tests.metamer.model.treeAdaptor;
-import java.io.Serializable;
-import java.util.Deque;
-import java.util.LinkedList;
-import java.util.concurrent.atomic.AtomicReference;
-
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public abstract class Node implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private Node parent;
- private AtomicReference<Boolean> nullable;
- private Reference<LazyLoadingListener<Node>> lazyLoadingListenerReference = new NodeReference();
+public interface Node {
- protected Node(Node parent, AtomicReference<Boolean> nullable,
- Reference<LazyLoadingListener<Node>> lazyLoadingListenerReference) {
- this.parent = parent;
- this.nullable = nullable;
- if (lazyLoadingListenerReference != null) {
- this.lazyLoadingListenerReference = lazyLoadingListenerReference;
- }
- }
+ public abstract boolean isRoot();
- public static <T extends Node> T lazyLoadingChecker(T node) {
- return (T) LazyLoadingChecker.wrapInstance(node, node.getLazyLoadingListenerReference());
- }
+ public abstract int getNumber();
- public Node getParent() {
- return parent;
- }
+ public abstract String getParentLabel();
- public boolean isRoot() {
- return parent == null;
- }
-
- public AtomicReference<Boolean> getNullable() {
- return nullable;
- }
-
- public int getLevel() {
- return isRoot() ? 1 : parent.getLevel() + 1;
- }
-
- public Node getRoot() {
- return isRoot() ? this : parent.getRoot();
- }
-
- public Iterable<Node> getPredecessorsFromRoot() {
- Deque<Node> list = new LinkedList<Node>();
- list.addFirst(this);
-
- while (list.getFirst().parent != null) {
- list.addFirst(list.getFirst().parent);
- }
-
- return list;
- }
-
public abstract String getLabel();
- public Reference<LazyLoadingListener<Node>> getLazyLoadingListenerReference() {
- return lazyLoadingListenerReference;
- }
-
- public void setLazyLoadingListener(Reference<LazyLoadingListener<Node>> lazyLoadingListener) {
- this.lazyLoadingListenerReference = lazyLoadingListener;
- }
-
- public class NodeReference implements Reference<LazyLoadingListener<Node>> {
- @Override
- public LazyLoadingListener<Node> get() {
- Node root = getRoot();
- if (root == Node.this) {
- return null;
- }
- return getRoot().getLazyLoadingListenerReference().get();
- }
- }
-}
+}
\ No newline at end of file
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/RecursiveNode.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/RecursiveNode.java 2011-03-09 09:26:00 UTC (rev 22092)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/RecursiveNode.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -21,244 +21,23 @@
*******************************************************************************/
package org.richfaces.tests.metamer.model.treeAdaptor;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class RecursiveNode extends Node {
- private static final long serialVersionUID = 1L;
-
- private static final int CHILDREN = 4;
- private static final int LEVELS = 2;
- private static final List<RecursiveNode> EMPTY_LIST = new LinkedList<RecursiveNode>();
- private static final Map<Integer, RecursiveNode> EMPTY_MAP = new HashMap<Integer, RecursiveNode>();
+public interface RecursiveNode extends Node {
- int number;
- List<RecursiveNode> children = null;
- NodeMap nodeMap = new NodeMap();
- ModelNode model;
+ public abstract ModelNode getModel();
- public RecursiveNode() {
- super(null, null, null);
- }
+ public abstract boolean isLeaf();
- protected RecursiveNode(Node parent, AtomicReference<Boolean> nullable, int number,
- Reference<LazyLoadingListener<Node>> lazyLoadingListenerReference) {
- super(parent, nullable, lazyLoadingListenerReference);
- this.number = number;
- }
+ public abstract List<RecursiveNode> getRecursiveList();
- public static RecursiveNode getInstance(Node parent, AtomicReference<Boolean> nullable, int number,
- Reference<LazyLoadingListener<Node>> lazyLoadingListenerReference) {
- return lazyLoadingChecker(new RecursiveNode(parent, nullable, number, lazyLoadingListenerReference));
- }
+ public abstract Map<Integer, RecursiveNode> getRecursiveMap();
- public int getNumber() {
- return number;
- }
+ public abstract int getRecursionLevel();
- public boolean isLeaf() {
- return getRecursionLevel() >= LEVELS + (isOddBranch() ? 0 : 1);
- }
-
- public List<RecursiveNode> getRecursiveList() {
- if (isLeaf()) {
- return getEmptyList();
- }
- if (children == null) {
- children = createChildren(this, getNullable(), null);
- }
- return children;
- }
-
- public Map<Integer, RecursiveNode> getRecursiveMap() {
- if (isLeaf()) {
- return getEmptyMap();
- }
- return nodeMap;
- }
-
- private List<RecursiveNode> getEmptyList() {
- return getNullable().get() ? null : EMPTY_LIST;
- }
-
- private Map<Integer, RecursiveNode> getEmptyMap() {
- return getNullable().get() ? null : EMPTY_MAP;
- }
-
- public String getLabel() {
- String parentLabel = (isRoot() ? "" : getParent().getLabel() + "-") + "R-";
- String recursionLabel = (isRecursionRoot() ? parentLabel : getParent().getLabel() + ".") + number;
- return recursionLabel;
- }
-
- public ModelNode getModel() {
- if (isLeaf() && !isPreceededByModel()) {
- if (model == null) {
- model = ModelNode.getInstance(this, getNullable(), null);
- }
- return model;
- }
- return null;
- }
-
- public int getRecursionLevel() {
- return isRecursionRoot() ? 1 : 1 + ((RecursiveNode) getParent()).getRecursionLevel();
- }
-
- private boolean isRecursionRoot() {
- if (isRoot()) {
- return true;
- } else {
- return !(getParent() instanceof RecursiveNode);
- }
- }
-
- public static List<RecursiveNode> createChildren(Node parent, AtomicReference<Boolean> nullable,
- Reference<LazyLoadingListener<Node>> lazyLoadingListenerReference) {
- List<RecursiveNode> children = new LinkedList<RecursiveNode>();
- for (int i = 0; i < CHILDREN; i++) {
- RecursiveNode node = RecursiveNode.getInstance(parent, nullable, i, lazyLoadingListenerReference);
- children.add(node);
- }
- return children;
- }
-
- private boolean isPreceededByModel() {
- for (Node predecessor : getPredecessorsFromRoot()) {
- if (predecessor instanceof ModelNode) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isOddBranch() {
- for (Node predecessor : getPredecessorsFromRoot()) {
- if (predecessor instanceof RecursiveNode) {
- return ((RecursiveNode) predecessor).number % 2 == 1;
- }
- }
- return this.number % 2 == 1;
- }
-
- @Override
- public String toString() {
- return getLabel();
- }
-
- public class NodeMap implements Map<Integer, RecursiveNode>, Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public int size() {
- return getRecursiveList().size();
- }
-
- @Override
- public boolean isEmpty() {
- return getRecursiveList().isEmpty();
- }
-
- @Override
- public boolean containsKey(Object key) {
- throw new UnsupportedOperationException("not implemented");
- }
-
- @Override
- public boolean containsValue(Object value) {
- throw new UnsupportedOperationException("not implemented");
- }
-
- @Override
- public RecursiveNode get(Object key) {
- if (key instanceof Integer) {
- return getRecursiveList().get((Integer) key);
- }
- throw new IllegalStateException("there is no value for the key '" + key + "' (type "
- + key.getClass().getName() + ")");
- }
-
- @Override
- public RecursiveNode put(Integer key, RecursiveNode value) {
- throw new UnsupportedOperationException("not supported");
- }
-
- @Override
- public RecursiveNode remove(Object key) {
- throw new UnsupportedOperationException("not supported");
- }
-
- @Override
- public void putAll(Map<? extends Integer, ? extends RecursiveNode> m) {
- throw new UnsupportedOperationException("not supported");
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException("not supported");
- }
-
- @Override
- public Set<Integer> keySet() {
- HashSet<Integer> set = new HashSet<Integer>();
- for (int i = 0; i < getRecursiveList().size(); i++) {
- set.add(i);
- }
- return set;
- }
-
- @Override
- public Collection<RecursiveNode> values() {
- return getRecursiveList();
- }
-
- @Override
- public Set<java.util.Map.Entry<Integer, RecursiveNode>> entrySet() {
- HashSet<Map.Entry<Integer, RecursiveNode>> set = new HashSet<Map.Entry<Integer, RecursiveNode>>();
- int i = 0;
- for (RecursiveNode node : getRecursiveList()) {
- set.add(new MapEntry(i++, node));
- }
- return set;
- }
-
- }
-
- public class MapEntry implements Map.Entry<Integer, RecursiveNode> {
-
- int key;
- RecursiveNode node;
-
- public MapEntry(int key, RecursiveNode node) {
- this.key = key;
- this.node = node;
- }
-
- @Override
- public Integer getKey() {
- return key;
- }
-
- @Override
- public RecursiveNode getValue() {
- return node;
- }
-
- @Override
- public RecursiveNode setValue(RecursiveNode value) {
- throw new UnsupportedOperationException("not supported");
- }
- }
}
\ No newline at end of file
Copied: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/RecursiveNodeImpl.java (from rev 22092, modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/RecursiveNode.java)
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/RecursiveNodeImpl.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/RecursiveNodeImpl.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer.model.treeAdaptor;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.richfaces.tests.metamer.bean.RichTreeModelRecursiveAdaptorBean;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class RecursiveNodeImpl extends AbstractNode implements RecursiveNode {
+ private static final long serialVersionUID = 1L;
+
+ private static final int CHILDREN = 4;
+ private static final int LEVELS = 2;
+ private static final List<RecursiveNode> EMPTY_LIST = new LinkedList<RecursiveNode>();
+ private static final Map<Integer, RecursiveNode> EMPTY_MAP = new HashMap<Integer, RecursiveNode>();
+
+ int recursionLevel;
+ boolean oddBranch;
+ List<RecursiveNode> children = null;
+ NodeMap nodeMap = new NodeMap();
+ ModelNode model;
+
+ protected RecursiveNodeImpl(boolean isRoot, int number, String parentLabel, int recursionLevel, boolean oddBranch) {
+ super(isRoot, number, parentLabel);
+ this.recursionLevel = recursionLevel;
+ this.oddBranch = oddBranch;
+ }
+
+ public static RecursiveNode getInstance(boolean isRoot, int number, String parentLabel, int recursionLevel, boolean oddBranch) {
+ RecursiveNodeImpl recursiveNode = new RecursiveNodeImpl(isRoot, number, parentLabel, recursionLevel, oddBranch);
+ return LazyLoadingChecker.wrapInstance(recursiveNode);
+ }
+
+ public static List<RecursiveNode> createChildren(boolean createRoots, String parentLabel, int recursionLevel, boolean preferedOddBranch) {
+ List<RecursiveNode> children = new LinkedList<RecursiveNode>();
+ for (int i = 0; i < CHILDREN; i++) {
+ boolean oddBranch = preferedOddBranch;
+ if (createRoots) {
+ oddBranch = i % 2 == 1;
+ }
+ RecursiveNode node = RecursiveNodeImpl.getInstance(createRoots, i, parentLabel, recursionLevel, oddBranch);
+ children.add(node);
+ }
+ return children;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IRecursiveNode#getModel()
+ */
+ @Override
+ public ModelNode getModel() {
+ if (isLeaf() && model == null) {
+ model = ModelNodeImpl.getInstance(false, 1, getLabel());
+ }
+ return model;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IRecursiveNode#isLeaf()
+ */
+ @Override
+ public boolean isLeaf() {
+ return getRecursionLevel() >= LEVELS + (oddBranch ? 0 : 1);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IRecursiveNode#getRecursiveList()
+ */
+ @Override
+ public List<RecursiveNode> getRecursiveList() {
+ if (isLeaf()) {
+ return getEmptyList();
+ }
+ if (children == null) {
+ children = createChildren(false, getLabel(), recursionLevel + 1, this.oddBranch);
+ }
+ return children;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IRecursiveNode#getRecursiveMap()
+ */
+ @Override
+ public Map<Integer, RecursiveNode> getRecursiveMap() {
+ if (isLeaf()) {
+ return getEmptyMap();
+ }
+ return nodeMap;
+ }
+
+ private List<RecursiveNode> getEmptyList() {
+ return isNullable() ? null : EMPTY_LIST;
+ }
+
+ private Map<Integer, RecursiveNode> getEmptyMap() {
+ return isNullable() ? null : EMPTY_MAP;
+ }
+
+ private boolean isNullable() {
+ return RichTreeModelRecursiveAdaptorBean.getFacesContext().isLeafChildrenNullable();
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IRecursiveNode#getLabel()
+ */
+ @Override
+ public String getLabel() {
+ String parentLabel = (isRoot() ? "" : getParentLabel() + "-") + "R-";
+ String recursionLabel = (isRecursionRoot() ? parentLabel : getParentLabel() + ".") + getNumber();
+ return recursionLabel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.tests.metamer.model.treeAdaptor.IRecursiveNode#getRecursionLevel()
+ */
+ @Override
+ public int getRecursionLevel() {
+ return recursionLevel;
+ }
+
+ private boolean isRecursionRoot() {
+ return recursionLevel == 1;
+ }
+
+ @Override
+ public String toString() {
+ return getLabel();
+ }
+
+ public class NodeMap implements Map<Integer, RecursiveNode>, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public int size() {
+ return getRecursiveList().size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return getRecursiveList().isEmpty();
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ @Override
+ public RecursiveNode get(Object key) {
+ if (key instanceof Integer) {
+ return getRecursiveList().get((Integer) key);
+ }
+ throw new IllegalStateException("there is no value for the key '" + key + "' (type "
+ + key.getClass().getName() + ")");
+ }
+
+ @Override
+ public RecursiveNode put(Integer key, RecursiveNode value) {
+ throw new UnsupportedOperationException("not supported");
+ }
+
+ @Override
+ public RecursiveNode remove(Object key) {
+ throw new UnsupportedOperationException("not supported");
+ }
+
+ @Override
+ public void putAll(Map<? extends Integer, ? extends RecursiveNode> m) {
+ throw new UnsupportedOperationException("not supported");
+ }
+
+ @Override
+ public void clear() {
+ throw new UnsupportedOperationException("not supported");
+ }
+
+ @Override
+ public Set<Integer> keySet() {
+ HashSet<Integer> set = new HashSet<Integer>();
+ for (int i = 0; i < getRecursiveList().size(); i++) {
+ set.add(i);
+ }
+ return set;
+ }
+
+ @Override
+ public Collection<RecursiveNode> values() {
+ return getRecursiveList();
+ }
+
+ @Override
+ public Set<java.util.Map.Entry<Integer, RecursiveNode>> entrySet() {
+ HashSet<Map.Entry<Integer, RecursiveNode>> set = new HashSet<Map.Entry<Integer, RecursiveNode>>();
+ int i = 0;
+ for (RecursiveNode node : getRecursiveList()) {
+ set.add(new MapEntry(i++, node));
+ }
+ return set;
+ }
+
+ }
+
+ public class MapEntry implements Map.Entry<Integer, RecursiveNode> {
+
+ int key;
+ RecursiveNode node;
+
+ public MapEntry(int key, RecursiveNode node) {
+ this.key = key;
+ this.node = node;
+ }
+
+ @Override
+ public Integer getKey() {
+ return key;
+ }
+
+ @Override
+ public RecursiveNode getValue() {
+ return node;
+ }
+
+ @Override
+ public RecursiveNode setValue(RecursiveNode value) {
+ throw new UnsupportedOperationException("not supported");
+ }
+ }
+}
\ No newline at end of file
Deleted: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/Reference.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/Reference.java 2011-03-09 09:26:00 UTC (rev 22092)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/treeAdaptor/Reference.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -1,8 +0,0 @@
-package org.richfaces.tests.metamer.model.treeAdaptor;
-
-import java.io.Serializable;
-
-public interface Reference<T> extends Serializable {
-
- public T get();
-}
Added: modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/TestRichTreeModelRecursiveAdaptorBeanSerialization.java
===================================================================
--- modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/TestRichTreeModelRecursiveAdaptorBeanSerialization.java (rev 0)
+++ modules/tests/metamer/trunk/application/src/test/java/org/richfaces/tests/metamer/TestRichTreeModelRecursiveAdaptorBeanSerialization.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, 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.tests.metamer;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.richfaces.tests.metamer.bean.RichTreeModelRecursiveAdaptorBean;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.io.NullOutputStream;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestRichTreeModelRecursiveAdaptorBeanSerialization {
+
+ private Set<Integer> notEquals = new TreeSet<Integer>();
+
+ PrintStream sysout;
+
+ @BeforeClass
+ public void redirectOut() {
+ sysout = System.out;
+ System.setOut(new PrintStream(new NullOutputStream()));
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void returnOut() {
+ System.setOut(sysout);
+ }
+
+ @Test
+ public void testBeanSerialization() throws IOException, ClassNotFoundException, IllegalArgumentException,
+ IllegalAccessException {
+
+ RichTreeModelRecursiveAdaptorBean bean = new RichTreeModelRecursiveAdaptorBean();
+ bean.init();
+
+ Object obj1 = bean;
+
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ ObjectOutputStream outputStream = new ObjectOutputStream(byteArrayOutputStream);
+ outputStream.writeObject(obj1);
+
+ byte[] bytes = byteArrayOutputStream.toByteArray();
+
+ ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(bytes));
+ Object obj2 = inputStream.readObject();
+
+ verifyEqualsDeeply(obj1, obj2);
+ }
+
+ public void verifyEqualsDeeply(Object obj1, Object obj2) throws IllegalArgumentException, IllegalAccessException {
+
+ if (obj1 == null) {
+ if (obj2 == null) {
+ return;
+ }
+ throw new AssertionError("obj1 is null, but obj2 is not null");
+ }
+
+ Class<?> classO = obj1.getClass();
+ assertEquals(obj2.getClass(), classO, "Both objects should be instances of the same class");
+
+ if (obj1.equals(obj2)) {
+ return;
+ }
+
+ int hash = cohash(obj1, obj2);
+ if (notEquals.contains(hash)) {
+ return;
+ }
+
+ notEquals.add(hash);
+
+ if (Collection.class.isAssignableFrom(classO)) {
+ Collection<?> col1 = (Collection<?>) obj1;
+ Collection<?> col2 = (Collection<?>) obj2;
+ assertEquals(col1.toArray(new Object[col1.size()]), col2.toArray(new Object[col2.size()]));
+ } else if (Map.class.isAssignableFrom(classO)) {
+ Map map1 = (Map) obj1;
+ Map map2 = (Map) obj2;
+
+ Object[] array1 = map1.keySet().toArray(new Object[map1.size()]);
+ Arrays.sort(array1, new HashCodeComparator());
+
+ Object[] array2 = map2.keySet().toArray(new Object[map2.size()]);
+ Arrays.sort(array2, new HashCodeComparator());
+
+ assertEquals(array1, array2);
+
+ array1 = map1.values().toArray(new Object[map1.size()]);
+ Arrays.sort(array1, new HashCodeComparator());
+
+ array2 = map2.values().toArray(new Object[map2.size()]);
+ Arrays.sort(array2, new HashCodeComparator());
+
+ assertEquals(array1, array2);
+ } else {
+ for (Field field : classO.getDeclaredFields()) {
+
+ if (Modifier.isStatic(field.getModifiers())) {
+ continue;
+ }
+ if (Modifier.isTransient(field.getModifiers())) {
+ continue;
+ }
+
+ boolean accessible = field.isAccessible();
+ if (!accessible) {
+ field.setAccessible(true);
+ }
+ Object nObj1 = field.get(obj1);
+ Object nObj2 = field.get(obj2);
+ if (!accessible) {
+ field.setAccessible(false);
+ }
+ verifyEqualsDeeply(nObj1, nObj2);
+ }
+ }
+ }
+
+ public int cohash(Object obj1, Object obj2) {
+ return 17 * obj1.hashCode() * obj2.hashCode() + obj2.hashCode() + 11;
+ }
+
+ public class HashCodeComparator implements Comparator<Object> {
+ @Override
+ public int compare(Object o1, Object o2) {
+ return o1.hashCode() - o2.hashCode();
+ }
+ }
+}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTreeModelAdaptor/TestTreeModelAdaptorSelection.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTreeModelAdaptor/TestTreeModelAdaptorSelection.java 2011-03-09 09:26:00 UTC (rev 22092)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richTreeModelAdaptor/TestTreeModelAdaptorSelection.java 2011-03-09 09:27:32 UTC (rev 22093)
@@ -51,7 +51,7 @@
PathsCrate pathsForListModel = new PathsCrate("listModel", new Integer[][] { { 2, 1, 3 }, { 3, 3, 2, 2 } });
PathsCrate pathsForMapModel = new PathsCrate("mapModel", new Integer[][] { { 2, 1, 5 }, { 3, 3, 2, 6 } });
PathsCrate pathsForRecursiveModel = new PathsCrate("recursiveModel", new Integer[][] { { 4, 1, 10, 2 },
- { 1, 4, 3, 11, 4, 1 } });
+ { 1, 4, 3, 11, 4 } });
@Inject
@Use(enumeration = true)
13 years, 8 months
JBoss Rich Faces SVN: r22092 - modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-03-09 04:26:00 -0500 (Wed, 09 Mar 2011)
New Revision: 22092
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attribute.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Extensions.java
Log:
updated Attribute and Extensions with equals, hashCode and toString
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attribute.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attribute.java 2011-03-09 09:25:27 UTC (rev 22091)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attribute.java 2011-03-09 09:26:00 UTC (rev 22092)
@@ -30,8 +30,10 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
/**
* Representation an attribute of a JSF component.
@@ -41,9 +43,9 @@
*/
@XmlRootElement(name = "property", namespace = "http://java.sun.com/xml/ns/javaee")
public class Attribute implements Serializable {
-
- private static final long serialVersionUID = -6716974687380275186L;
- private Logger logger;
+
+ private static final long serialVersionUID = 6142493504360646686L;
+
private String name;
private Object value;
private Class<?> type;
@@ -53,11 +55,9 @@
private Extensions extensions;
public Attribute() {
- logger = LoggerFactory.getLogger(getClass());
}
public Attribute(String name) {
- logger = LoggerFactory.getLogger(getClass());
this.name = name;
}
@@ -176,4 +176,19 @@
public boolean isRequired() {
return extensions.getRequired();
}
+
+ @Override
+ public boolean equals(Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this, true);
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
}
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Extensions.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Extensions.java 2011-03-09 09:25:27 UTC (rev 22091)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Extensions.java 2011-03-09 09:26:00 UTC (rev 22092)
@@ -26,6 +26,11 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
/**
* Representation of CDK extension of a RichFaces component in faces-config.xml.
*
@@ -97,4 +102,19 @@
public void setRequired(boolean required) {
this.required = required;
}
+
+ @Override
+ public boolean equals(Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this, true);
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
}
13 years, 8 months
JBoss Rich Faces SVN: r22091 - modules/tests/metamer/trunk/application/src/main/webapp/components/richTree.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-03-09 04:25:27 -0500 (Wed, 09 Mar 2011)
New Revision: 22091
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/treeAdaptors.xhtml
Log:
added @for for all outputLabels in tree sample
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/treeAdaptors.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/treeAdaptors.xhtml 2011-03-09 09:24:55 UTC (rev 22090)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/treeAdaptors.xhtml 2011-03-09 09:25:27 UTC (rev 22091)
@@ -162,22 +162,22 @@
<a4j:outputPanel ajaxRendered="true">
<h:panelGrid id="selectionOutput" columns="2">
- <h:outputLabel value="Test Loading Facet:" />
+ <h:outputLabel for="loadingFacet" value="Test Loading Facet:" />
<h:selectBooleanCheckbox id="loadingFacet" value="#{richTreeBean.testLoadingFacet}">
<a4j:ajax render="#{nestedComponentId}" />
</h:selectBooleanCheckbox>
- <h:outputLabel value="Delayed Render (1sec):" />
- <h:selectBooleanCheckbox value="#{richTreeBean.delayedRender}">
+ <h:outputLabel for="delayedRender" value="Delayed Render (1sec):" />
+ <h:selectBooleanCheckbox id="delayedRender" value="#{richTreeBean.delayedRender}">
<a4j:ajax />
</h:selectBooleanCheckbox>
- <h:outputLabel value="Recursive Leaf Children Nullable:" />
+ <h:outputLabel for="recursiveLeafChildrenNullable" value="Recursive Leaf Children Nullable:" />
<h:selectBooleanCheckbox id="recursiveLeafChildrenNullable" value="#{richTreeModelRecursiveAdaptorBean.leafChildrenNullable}">
<a4j:ajax render="#{nestedComponentId}" />
</h:selectBooleanCheckbox>
- <h:outputLabel value="Recursive Model Representation:" />
+ <h:outputLabel for="recursiveModelRepresentation" value="Recursive Model Representation:" />
<h:selectOneRadio id="recursiveModelRepresentation" value="#{richTreeModelRecursiveAdaptorBean.useMapModel}">
<f:selectItem itemLabel="List<RecursiveNode>" itemValue="false" />
<f:selectItem itemLabel="Map<Integer, RecursiveNode>" itemValue="true" />
@@ -185,33 +185,33 @@
<a4j:ajax render="#{nestedComponentId}" />
</h:selectOneRadio>
- <h:outputLabel value="Selection:" />
+ <h:outputLabel for="selection" value="Selection:" />
<h:outputText id="selection" value="#{richTreeBean.selection}" />
- <h:outputLabel value="Lazy Initialized:" />
+ <h:outputLabel for="lazyInitialized" value="Lazy Initialized:" />
<h:outputText id="lazyInitialized" value="#{richTreeModelRecursiveAdaptorBean.lazyInitializedNodes}" />
- <h:outputLabel value="Selection Change Event:" rendered="#{not empty richTreeListenerBean.treeSelectionChangeEvent}" />
- <h:panelGrid columns="2" rendered="#{not empty richTreeListenerBean.treeSelectionChangeEvent}">
- <h:outputLabel value="Client ID:" />
+ <h:outputLabel for="selectionChangeEventDetails" value="Selection Change Event:" rendered="#{not empty richTreeListenerBean.treeSelectionChangeEvent}" />
+ <h:panelGrid id="selectionChangeEventDetails" columns="2" rendered="#{not empty richTreeListenerBean.treeSelectionChangeEvent}">
+ <h:outputLabel for="selectionEventClientId" value="Client ID:" />
<h:outputText id="selectionEventClientId" value="#{richTreeListenerBean.treeSelectionChangeEvent.component.id}" />
- <h:outputLabel value="New Selection:" />
+ <h:outputLabel for="selectionEventNewSelection" value="New Selection:" />
<h:outputText id="selectionEventNewSelection" value="#{richTreeListenerBean.treeSelectionChangeEvent.newSelection}" />
- <h:outputLabel value="Old Selection:" />
+ <h:outputLabel for="selectionEventOldSelection" value="Old Selection:" />
<h:outputText id="selectionEventOldSelection" value="#{richTreeListenerBean.treeSelectionChangeEvent.oldSelection}" />
</h:panelGrid>
- <h:outputLabel value="Tree Toggle Event:" rendered="#{not empty richTreeListenerBean.treeToggleEvent}" />
- <h:panelGrid columns="2" rendered="#{not empty richTreeListenerBean.treeToggleEvent}">
- <h:outputLabel value="Client ID:" />
+ <h:outputLabel for="treeToggleEventDetails" value="Tree Toggle Event:" rendered="#{not empty richTreeListenerBean.treeToggleEvent}" />
+ <h:panelGrid id="treeToggleEventDetails" columns="2" rendered="#{not empty richTreeListenerBean.treeToggleEvent}">
+ <h:outputLabel for="toggleEventClientId" value="Client ID:" />
<h:outputText id="toggleEventClientId" value="#{richTreeListenerBean.treeToggleEvent.component.id}" />
- <h:outputLabel value="Collapsed:" />
+ <h:outputLabel for="toggleEventCollapsed" value="Collapsed:" />
<h:outputText id="toggleEventCollapsed" value="#{richTreeListenerBean.treeToggleEvent.collapsed}" />
- <h:outputLabel value="Expanded:" />
+ <h:outputLabel for="toggleEventExpanded" value="Expanded:" />
<h:outputText id="toggleEventExpanded" value="#{richTreeListenerBean.treeToggleEvent.expanded}" />
</h:panelGrid>
</h:panelGrid>
13 years, 8 months
JBoss Rich Faces SVN: r22090 - modules/tests/metamer/trunk/application/src/main/webapp/components/richDataScroller.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-03-09 04:24:55 -0500 (Wed, 09 Mar 2011)
New Revision: 22090
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataScroller/simple.xhtml
Log:
fixed nested rendering in data scroller sample
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataScroller/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataScroller/simple.xhtml 2011-03-09 09:24:26 UTC (rev 22089)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataScroller/simple.xhtml 2011-03-09 09:24:55 UTC (rev 22090)
@@ -46,7 +46,7 @@
<h:outputText value="Show data in table: " />
<h:selectBooleanCheckbox id="noDataCheckbox" value="#{richDataScrollerBean.state}">
- <a4j:ajax render="richDataTable scroller1"/>
+ <a4j:ajax render="scroller1 #{nestedComponentId}"/>
</h:selectBooleanCheckbox>
<br/><br/>
<rich:dataScroller id="scroller1"
13 years, 8 months