JBoss Rich Faces SVN: r19862 - in branches/RF-8742/ui/validator/ui/src: main/java/org/richfaces/component/behavior and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-01 15:50:05 -0400 (Mon, 01 Nov 2010)
New Revision: 19862
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorBehavior.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/TestBean.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseTestRunner.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BooleanConverterTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ConverterTestRunner.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/LengthValidatorTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/TestData.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/TestDataHolder.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ValidatorTestRunner.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java
Log:
CODING IN PROGRESS - issue RF-9593: CSV - create tests and implementation for AJAX transport.
https://jira.jboss.org/browse/RF-9593
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIAjaxValidator.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -128,7 +128,7 @@
public void encodeAjax(FacesContext context) throws IOException {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
Set<String> renderedAreas = ajaxContext.getAjaxRenderedAreas();
- for (UIComponent message : getMessages(context)) {
+ for (UIComponent message : getMessages(context, this)) {
if (message.isRendered()) {
message.encodeAll(context);
renderedAreas.add(message.getClientId(context));
@@ -138,9 +138,9 @@
// AjaxRendererUtils.encodeAreas(context, this);
}
- public Set<UIComponent> getMessages(FacesContext context) {
+ public Set<UIComponent> getMessages(FacesContext context, UIComponent component) {
Set<UIComponent> messages = new HashSet<UIComponent>();
- findMessages(this.getParent(), this, messages, false);
+ findMessages(component.getParent(), component, messages, false);
findRichMessages(context, context.getViewRoot(), messages);
return messages;
}
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorBehavior.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorBehavior.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorBehavior.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -48,5 +48,11 @@
Class<?>[] getGroups();
void setGroups(Class<?> ...groups);
+
+ boolean isDisabled();
+
+ boolean isImmediateSet();
+
+ boolean isImmediate();
}
\ No newline at end of file
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -23,22 +23,32 @@
package org.richfaces.component.behavior;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
import javax.faces.component.ActionSource;
import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIMessage;
+import javax.faces.component.UIMessages;
import javax.faces.component.behavior.AjaxBehavior;
import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.context.FacesContext;
+import javax.faces.context.PartialViewContext;
import javax.faces.convert.Converter;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.BehaviorEvent;
import javax.faces.render.ClientBehaviorRenderer;
import javax.faces.render.RenderKit;
import javax.faces.validator.Validator;
import org.richfaces.application.ServiceTracker;
+import org.richfaces.component.UIRichMessages;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.renderkit.html.ClientValidatorRenderer;
@@ -86,18 +96,92 @@
}
@Override
- public void decode(FacesContext context, UIComponent component) {
- if (null == context || null == component) {
- throw new NullPointerException();
+ public void broadcast(BehaviorEvent event) throws AbortProcessingException {
+ // Add message components to re-render list ( if any )
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ PartialViewContext partialViewContext = facesContext.getPartialViewContext();
+ if(partialViewContext.isAjaxRequest()){
+ UIComponent component = event.getComponent();
+ if(component instanceof EditableValueHolder){
+ EditableValueHolder input = (EditableValueHolder) component;
+ Set<UIComponent> messages = getMessages(facesContext, component);
+ Collection<String> renderIds = partialViewContext.getRenderIds();
+ for (UIComponent uiComponent : messages) {
+ renderIds.add(uiComponent.getClientId(facesContext));
+ }
+ }
}
- ClientBehaviorRenderer renderer = getRenderer(context, AjaxBehavior.BEHAVIOR_ID);
- if (null != renderer) {
- renderer.decode(context, component, this);
- // TODO - setup phase and render area to rerender.
+ super.broadcast(event);
+ }
+
+ public Set<UIComponent> getMessages(FacesContext context, UIComponent component) {
+ Set<UIComponent> messages = new HashSet<UIComponent>();
+ findMessages(component.getParent(),component, messages, false,component.getId());
+ // TODO - enable then UIRichMessages will be done
+// findRichMessages(context, context.getViewRoot(), messages);
+ return messages;
+ }
+
+ /**
+ * Find all instances of the {@link UIRichMessages} and update list of the rendered messages.
+ *
+ * @param context
+ * @param component
+ * @param messages
+ */
+ protected void findRichMessages(FacesContext context, UIComponent component, String id, Set<UIComponent> messages) {
+ Iterator<UIComponent> facetsAndChildren = component.getFacetsAndChildren();
+ while (facetsAndChildren.hasNext()) {
+ UIComponent child = (UIComponent) facetsAndChildren.next();
+ if (child instanceof UIRichMessages) {
+ UIRichMessages richMessage = (UIRichMessages) child;
+ if (null == richMessage.getFor()) {
+ richMessage.updateMessages(context, id);
+ messages.add(richMessage);
+ }
+ } else {
+ findRichMessages(context, child, id, messages);
+ }
}
}
/**
+ * Recursive search messages for the parent component.
+ *
+ * @param parent
+ * @param component
+ * @param messages
+ * @param id
+ * @return
+ */
+ protected boolean findMessages(UIComponent parent, UIComponent component, Set<UIComponent> messages, boolean found, Object id) {
+ Iterator<UIComponent> facetsAndChildren = parent.getFacetsAndChildren();
+ while (facetsAndChildren.hasNext()) {
+ UIComponent child = (UIComponent) facetsAndChildren.next();
+ if (child != component) {
+ if (child instanceof UIMessage || child instanceof UIMessages) {
+ UIComponent message = (UIComponent) child;
+ Object targetId = message.getAttributes().get("for");
+ if (null != targetId && targetId.equals(id)) {
+ messages.add(message);
+ found = true;
+ }
+ } else {
+ found |= findMessages(child, null, messages, found,id);
+ }
+ }
+ }
+ if (!(found && parent instanceof NamingContainer) && component != null) {
+ UIComponent newParent = parent.getParent();
+ if (null != newParent) {
+ found = findMessages(newParent, parent, messages, found,id);
+ }
+ }
+ return found;
+ }
+
+
+ /**
* <p class="changed_added_4_0">
* Look up for {@link ClientBehaviorRenderer} instence
* </p>
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -7,11 +7,15 @@
import java.util.List;
import javax.faces.FacesException;
+import javax.faces.component.ActionSource;
+import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.context.FacesContext;
+import javax.faces.event.AjaxBehaviorEvent;
+import javax.faces.event.PhaseId;
import javax.faces.render.ClientBehaviorRenderer;
import org.ajax4jsf.javascript.JSLiteral;
@@ -22,10 +26,10 @@
import org.richfaces.component.behavior.ConverterNotFoundException;
import org.richfaces.validator.ClientScriptService;
import org.richfaces.validator.ConverterDescriptor;
+import org.richfaces.validator.FacesObjectDescriptor;
import org.richfaces.validator.LibraryFunction;
import org.richfaces.validator.LibraryScriptString;
import org.richfaces.validator.ScriptNotFoundException;
-import org.richfaces.validator.FacesObjectDescriptor;
import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Lists;
@@ -69,9 +73,56 @@
@Override
public void decode(FacesContext context, UIComponent component, ClientBehavior behavior) {
- // TODO - properly set phase and re-render.
+ if (null == context || null == component || null == behavior) {
+ throw new NullPointerException();
+ }
+
+ if (!(behavior instanceof ClientValidatorBehavior)) {
+ throw new IllegalArgumentException(
+ "Instance of org.ruchvaces.component.behaviot.ClientValidatorBehavior required: " + behavior);
+ }
+ ClientValidatorBehavior ajaxBehavior = (ClientValidatorBehavior)behavior;
+
+ // First things first - if AjaxBehavior is disabled, we are done.
+ if (!ajaxBehavior.isDisabled()) {
+ component.queueEvent(createEvent(component, ajaxBehavior));
+ }
}
- /**
+
+ // Creates an AjaxBehaviorEvent for the specified component/behavior
+ private static AjaxBehaviorEvent createEvent(UIComponent component,
+ ClientValidatorBehavior ajaxBehavior) {
+
+ AjaxBehaviorEvent event = new AjaxBehaviorEvent(component, ajaxBehavior);
+
+ PhaseId phaseId = isImmediate(component, ajaxBehavior) ?
+ PhaseId.APPLY_REQUEST_VALUES :
+ PhaseId.PROCESS_VALIDATIONS;
+
+ event.setPhaseId(phaseId);
+
+ return event;
+ }
+
+
+ // Tests whether we should perform immediate processing. Note
+ // that we "inherit" immediate from the parent if not specified
+ // on the behavior.
+ private static boolean isImmediate(UIComponent component,
+ ClientValidatorBehavior ajaxBehavior) {
+
+ boolean immediate = false;
+
+ if (ajaxBehavior.isImmediateSet()) {
+ immediate = ajaxBehavior.isImmediate();
+ } else if (component instanceof EditableValueHolder) {
+ immediate = ((EditableValueHolder)component).isImmediate();
+ } else if (component instanceof ActionSource) {
+ immediate = ((ActionSource)component).isImmediate();
+ }
+
+ return immediate;
+ } /**
* <p class="changed_added_4_0">
* This method builds client-side validation script and stores it in View resource component
* </p>
@@ -86,7 +137,7 @@
FacesContext facesContext = behaviorContext.getFacesContext();
UIValidatorScript scriptResource = getOrCreateValidatorScriptResource(facesContext);
validatorScript = scriptResource.addOrFindScript(validatorScript);
- return validatorScript.createCallScript(behaviorContext.getComponent().getClientId(facesContext));
+ return validatorScript.createCallScript(behaviorContext.getComponent().getClientId(facesContext),behaviorContext.getSourceId());
} else {
return null;
}
@@ -186,11 +237,17 @@
String ajaxScript = behavior.getAjaxScript(behaviorContext);
ajaxScript=ajaxScript.replace("this", "element");
String clientId = getComponentClientId(behaviorContext);
- ajaxScript=ajaxScript.replace("'"+clientId+"'",ValidatorScriptBase.CLIENT_ID);
- ajaxScript=ajaxScript.replace("\""+clientId+"\"",ValidatorScriptBase.CLIENT_ID);
+ ajaxScript = replaceTextToVariable(ajaxScript, clientId, ValidatorScriptBase.CLIENT_ID);
+ ajaxScript = replaceTextToVariable(ajaxScript, behaviorContext.getSourceId(), ValidatorScriptBase.SOURCE_ID);
return ajaxScript;
}
+ private String replaceTextToVariable(String ajaxScript, String clientId, String variableName) {
+ ajaxScript=ajaxScript.replace("'"+clientId+"'",variableName);
+ ajaxScript=ajaxScript.replace("\""+clientId+"\"",variableName);
+ return ajaxScript;
+ }
+
/**
* <p class="changed_added_4_0">
* Build client-side function call for Server-side component descriptor.
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -14,9 +14,10 @@
/**
* <p class="changed_added_4_0">Creates JavasCript that calls validator function.</p>
* @param clientId
+ * @param sourceId
* @return
*/
- String createCallScript(String clientId);
+ String createCallScript(String clientId, String sourceId);
}
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -13,6 +13,8 @@
protected static final String EOL = "\n;";
protected static final String CLIENT_ID = "clientId";
protected static final JSLiteral CLIENT_ID_LITERAL = new JSLiteral(CLIENT_ID);
+ protected static final String SOURCE_ID = "sourceId";
+ protected static final JSLiteral SOURCE_ID_LITERAL = new JSLiteral(SOURCE_ID);
protected static final NullConverterScript NULL_CONVERTER_SCRIPT = new NullConverterScript();
protected static final String CSV_NAMESPACE = "RichFaces.csv.";
protected static final String VALUE_FUNCTION_NAME = CSV_NAMESPACE+"getValue";
@@ -23,7 +25,7 @@
private boolean bodyProcessed = false;
public ValidatorScriptBase() {
- super(CLIENT_ID,"element",EVENT,DISABLE_AJAX);
+ super(CLIENT_ID,SOURCE_ID,"element",EVENT,DISABLE_AJAX);
}
public void appendScript(StringBuffer functionString) {
@@ -37,8 +39,8 @@
protected abstract Object buildBody();
- public String createCallScript(String clientId) {
- JSFunction callFunction = new JSFunction(getName(),clientId,THIS,EVENT_LITERAL);
+ public String createCallScript(String clientId,String sourceId) {
+ JSFunction callFunction = new JSFunction(getName(),clientId,sourceId,THIS,EVENT_LITERAL);
return callFunction.toScript();
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/TestBean.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/TestBean.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/TestBean.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -48,7 +48,7 @@
return FOO;
}
- public String createCallScript(String clientId) {
+ public String createCallScript(String clientId,String sourceId) {
return FOO+"("+clientId+")";
}
};
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseTest.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseTest.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -69,356 +69,355 @@
*/
public abstract class BaseTest {
- public static final String TEST_COMPONENT_LABEL = "input";
+ public static final String TEST_COMPONENT_LABEL = "input";
- public class TestBean {
+ public class TestBean {
- private static final String CONVERTER_VAR = "__converter";
+ private static final String CONVERTER_VAR = "__converter";
- private static final String VALIDATOR_VAR = "__validator";
+ private static final String VALIDATOR_VAR = "__validator";
- private String objectId;
+ private String objectId;
- private String clientFunction;
+ private String clientFunction;
- private String valueAsScript;
+ private String valueAsScript;
- private String errorMessage;
+ private String errorMessage;
- private Enum<?>[] errorMessageEnums;
+ private Enum<?>[] errorMessageEnums;
- private Exception resultException;
+ private Exception resultException;
- private Map<String, Object> attributes = new HashMap<String, Object>();
+ private Map<String, Object> attributes = new HashMap<String, Object>();
- private String parametersString;
-
- private String componentLabel;
-
- public String getComponentLabel() {
- return this.componentLabel;
- }
-
- public void setComponentLabel(String componentLabel) {
- this.componentLabel = componentLabel;
- }
+ private String parametersString;
- public void setClientFunction(String clientFunction) {
- this.clientFunction = clientFunction;
- }
+ private String componentLabel;
- public String getClientFunction() {
- return clientFunction;
- }
+ public String getComponentLabel() {
+ return this.componentLabel;
+ }
- public void setObjectId(String objectId) {
- this.objectId = objectId;
- }
+ public void setComponentLabel(String componentLabel) {
+ this.componentLabel = componentLabel;
+ }
- public String getSubmittedValue() {
- return submittedValue;
- }
+ public void setClientFunction(String clientFunction) {
+ this.clientFunction = clientFunction;
+ }
- public String getSubmittedValueAsScript() {
- return ScriptUtils.toScript(submittedValue);
- }
+ public String getClientFunction() {
+ return clientFunction;
+ }
- public String getErrorMessagesAsScript() {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- final Map<Object, Object> result = Maps.newHashMap();
-
- if (errorMessageEnums != null) {
- for (Enum<?> errorMessageEnum : errorMessageEnums) {
- MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
- String errorMessage = messageFactory.getMessageFormat(facesContext, errorMessageEnum);
-
- result.put(errorMessageEnum.name(), MessageFormat.format(errorMessage , "{0}"));
- }
- }
- return ScriptUtils.toScript(result);
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
+ public void setObjectId(String objectId) {
+ this.objectId = objectId;
+ }
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
+ public String getSubmittedValue() {
+ return submittedValue;
+ }
- public void setAttribute(String name, Object value) {
- attributes.put(name, value);
- }
+ public String getSubmittedValueAsScript() {
+ return ScriptUtils.toScript(submittedValue);
+ }
- public String getParametersString() {
- return parametersString;
- }
+ public String getErrorMessagesAsScript() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ final Map<Object, Object> result = Maps.newHashMap();
- public Exception getResultException() {
- return resultException;
- }
+ if (errorMessageEnums != null) {
+ for (Enum<?> errorMessageEnum : errorMessageEnums) {
+ MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
+ String errorMessage = messageFactory.getMessageFormat(facesContext, errorMessageEnum);
- public void setErrorMessageEnums(
- Enum<?>[] errorMessageEnums) {
- this.errorMessageEnums = errorMessageEnums;
- }
+ result.put(errorMessageEnum.name(), MessageFormat.format(errorMessage, "{0}"));
+ }
+ }
+ return ScriptUtils.toScript(result);
+ }
- private void configure(FacesContext facesContext, Object object, String bindingVarName) {
- ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
+ public String getErrorMessage() {
+ return errorMessage;
+ }
- VariableMapper varMapper = facesContext.getELContext().getVariableMapper();
- ValueExpression originalExpr = varMapper.resolveVariable(bindingVarName);
- try {
- varMapper.setVariable(bindingVarName, expressionFactory.createValueExpression(object, Object.class));
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
- for (Entry<String, Object> mapEntry: attributes.entrySet()) {
+ public void setAttribute(String name, Object value) {
+ attributes.put(name, value);
+ }
- String exprString = MessageFormat.format("#'{'{0}.{1}'}'", bindingVarName, mapEntry.getKey());
- ValueExpression ve = expressionFactory.createValueExpression(facesContext.getELContext(), exprString, Object.class);
+ public String getParametersString() {
+ return parametersString;
+ }
- ve.setValue(facesContext.getELContext(), mapEntry.getValue());
- }
- } finally {
- varMapper.setVariable(bindingVarName, originalExpr);
- }
- }
+ public Exception getResultException() {
+ return resultException;
+ }
- private Converter createConverter(FacesContext facesContext) {
- Converter converter = facesContext.getApplication().createConverter(objectId);
- configure(facesContext, converter, CONVERTER_VAR);
- return converter;
- }
-
- private Validator createValidator(FacesContext facesContext) {
- Validator validator = facesContext.getApplication().createValidator(objectId);
- configure(facesContext, validator, VALIDATOR_VAR);
- return validator;
- }
+ public void setErrorMessageEnums(Enum<?>[] errorMessageEnums) {
+ this.errorMessageEnums = errorMessageEnums;
+ }
- private UIComponent createTestComponent() {
- HtmlInputText testComponent = new HtmlInputText();
- testComponent.setLabel(TEST_COMPONENT_LABEL);
- testBean.componentLabel = TEST_COMPONENT_LABEL;
- return testComponent;
- }
+ private void configure(FacesContext facesContext, Object object, String bindingVarName) {
+ ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
- public String getConvertedValueAsScript() {
- return valueAsScript != null ? valueAsScript : "null";
- }
+ VariableMapper varMapper = facesContext.getELContext().getVariableMapper();
+ ValueExpression originalExpr = varMapper.resolveVariable(bindingVarName);
+ try {
+ varMapper.setVariable(bindingVarName, expressionFactory.createValueExpression(object, Object.class));
- public void initConverter() {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Converter converter = createConverter(facesContext);
- try {
- Object convertedObject = converter.getAsObject(facesContext, createTestComponent(), submittedValue);
- valueAsScript = serializeObjectToScript(convertedObject);
- } catch (ConverterException e) {
- this.resultException = e;
- }
+ for (Entry<String, Object> mapEntry : attributes.entrySet()) {
- init();
- }
-
- public void initValidator() {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Validator validator = createValidator(facesContext);
- try {
- validator.validate(facesContext, createTestComponent(), submittedValue);
- } catch (ValidatorException e) {
- this.resultException = e;
- }
+ String exprString = MessageFormat.format("#'{'{0}.{1}'}'", bindingVarName, mapEntry.getKey());
+ ValueExpression ve =
+ expressionFactory.createValueExpression(facesContext.getELContext(), exprString, Object.class);
- init();
- }
-
- protected void init() {
- if (objectId == null || clientFunction == null) {
- throw new NullPointerException();
- }
+ ve.setValue(facesContext.getELContext(), mapEntry.getValue());
+ }
+ } finally {
+ varMapper.setVariable(bindingVarName, originalExpr);
+ }
+ }
- Map<String,Object> map = new HashMap<String, Object>(attributes);
- map.put("componentId", TEST_COMPONENT_LABEL);
- if (errorMessage!=null) {
- map.put("customMessage", MessageFormat.format(errorMessage , "{0}"));
- }
+ private Converter createConverter(FacesContext facesContext) {
+ Converter converter = facesContext.getApplication().createConverter(objectId);
+ configure(facesContext, converter, CONVERTER_VAR);
+ return converter;
+ }
- parametersString = ScriptUtils.toScript(map);
- }
- }
+ private Validator createValidator(FacesContext facesContext) {
+ Validator validator = facesContext.getApplication().createValidator(objectId);
+ configure(facesContext, validator, VALIDATOR_VAR);
+ return validator;
+ }
- private TestBean testBean;
+ private UIComponent createTestComponent() {
+ HtmlInputText testComponent = new HtmlInputText();
+ testComponent.setLabel(TEST_COMPONENT_LABEL);
+ testBean.componentLabel = TEST_COMPONENT_LABEL;
+ return testComponent;
+ }
- private HtmlUnitEnvironment environment;
+ public String getConvertedValueAsScript() {
+ return valueAsScript != null ? valueAsScript : "null";
+ }
- private String converterScriptName;
+ public void initConverter() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Converter converter = createConverter(facesContext);
+ try {
+ Object convertedObject = converter.getAsObject(facesContext, createTestComponent(), submittedValue);
+ valueAsScript = serializeObjectToScript(convertedObject);
+ } catch (ConverterException e) {
+ this.resultException = e;
+ }
- private String submittedValue;
+ init();
+ }
- private String failureMessage;
+ public void initValidator() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Validator validator = createValidator(facesContext);
+ try {
+ validator.validate(facesContext, createTestComponent(), submittedValue);
+ } catch (ValidatorException e) {
+ this.resultException = e;
+ }
- public BaseTest(String converterScriptName) {
- this.converterScriptName = converterScriptName;
- }
+ init();
+ }
- @Before
- public void setUp() throws Exception {
- testBean = new TestBean();
+ protected void init() {
+ if (objectId == null || clientFunction == null) {
+ throw new NullPointerException();
+ }
- environment = new HtmlUnitEnvironment(new JettyServer());
- environment.getServer().addResource("/testConverter.xhtml", BaseTest.class.getResource("testConverter.xhtml"));
- environment.getServer().addResource("/testValidator.xhtml", BaseTest.class.getResource("testValidator.xhtml"));
- environment.getServer().addResource("/resources/resource.js", converterScriptName);
- environment.getServer().addWebListener(new ServletRequestListener() {
+ Map<String, Object> map = new HashMap<String, Object>(attributes);
+ map.put("componentId", TEST_COMPONENT_LABEL);
+ if (errorMessage != null) {
+ map.put("customMessage", MessageFormat.format(errorMessage, "{0}"));
+ }
- public void requestInitialized(ServletRequestEvent sre) {
- sre.getServletRequest().setAttribute("testBean", testBean);
- }
+ parametersString = ScriptUtils.toScript(map);
+ }
+ }
- public void requestDestroyed(ServletRequestEvent sre) {
- }
- });
+ private TestBean testBean;
- environment.start();
- }
+ private HtmlUnitEnvironment environment;
- @After
- public void tearDown() throws Exception {
- submittedValue = null;
- failureMessage = null;
+ private String converterScriptName;
- testBean = null;
- if (environment!=null) {
- environment.release();
- environment = null;
- }
- }
+ private String submittedValue;
- protected String serializeObjectToScript(Object object) {
- if (object instanceof Date) {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime((Date) object);
- calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+ private String failureMessage;
- return new JSFunction("new Date", calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
- calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE),
- calendar.get(Calendar.SECOND), calendar.get(Calendar.MILLISECOND)).toScript();
- }
+ public BaseTest(String converterScriptName) {
+ this.converterScriptName = converterScriptName;
+ }
- return ScriptUtils.toScript(object);
- }
+ @Before
+ public void setUp() throws Exception {
+ testBean = new TestBean();
- public void setErrorMessage(String errorMessage) {
- testBean.setErrorMessage(errorMessage);
- }
+ environment = new HtmlUnitEnvironment(new JettyServer());
+ environment.getServer().addResource("/testConverter.xhtml", BaseTest.class.getResource("testConverter.xhtml"));
+ environment.getServer().addResource("/testValidator.xhtml", BaseTest.class.getResource("testValidator.xhtml"));
+ environment.getServer().addResource("/resources/resource.js", converterScriptName);
+ environment.getServer().addWebListener(new ServletRequestListener() {
- public void setObjectId(String objectId) {
- testBean.setObjectId(objectId);
- }
+ public void requestInitialized(ServletRequestEvent sre) {
+ sre.getServletRequest().setAttribute("testBean", testBean);
+ }
- public void setClientFunction(String clientFunction) {
- testBean.setClientFunction(clientFunction);
- }
+ public void requestDestroyed(ServletRequestEvent sre) {
+ }
+ });
- public void setAttribute(String name, Object value) {
- testBean.setAttribute(name, value);
- }
+ environment.start();
+ }
- public void setSubmittedValue(String submittedValue) {
- this.submittedValue = submittedValue;
- }
+ @After
+ public void tearDown() throws Exception {
+ submittedValue = null;
+ failureMessage = null;
- public void setFailureMessage(String failureMessage) {
- this.failureMessage = failureMessage;
- }
+ testBean = null;
+ if (environment != null) {
+ environment.release();
+ environment = null;
+ }
+ }
- public void setErrorMessageEnums(
- Enum<?>... errorMessageEnums) {
- testBean.setErrorMessageEnums(errorMessageEnums);
- }
+ protected String serializeObjectToScript(Object object) {
+ if (object instanceof Date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime((Date) object);
+ calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
- public void assertConversionOk() throws Exception {
- HtmlPage page = environment.getPage("/testConverter.jsf");
- System.out.println(page.asXml());
- assertTrue(page.getWebClient().isJavaScriptEnabled());
- ScriptResult conversionMessageResult = page.executeJavaScript("verifyConversion()");
- if (!ScriptResult.isUndefined(conversionMessageResult)) {
- fail(conversionMessageResult.getJavaScriptResult().toString());
- }
- }
-
- public void assertValidationOk() throws Exception {
- HtmlPage page = environment.getPage("/testValidator.jsf");
- System.out.println(page.asXml());
- assertTrue(page.getWebClient().isJavaScriptEnabled());
- ScriptResult messageResult = page.executeJavaScript("verifyValidation()");
- if (!ScriptResult.isUndefined(messageResult)) {
- fail(messageResult.getJavaScriptResult().toString());
- }
- }
+ return new JSFunction("new Date", calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
+ calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE),
+ calendar.get(Calendar.SECOND), calendar.get(Calendar.MILLISECOND)).toScript();
+ }
- public void assertConversionFailure() throws Exception {
- HtmlPage page = environment.getPage("/testConverter.jsf");
+ return ScriptUtils.toScript(object);
+ }
- assertNotNull(testBean.getResultException());
+ public void setErrorMessage(String errorMessage) {
+ testBean.setErrorMessage(errorMessage);
+ }
- assertTrue(page.getWebClient().isJavaScriptEnabled());
- ScriptResult conversionErrorResult = page.executeJavaScript("window.conversionError");
+ public void setObjectId(String objectId) {
+ testBean.setObjectId(objectId);
+ }
- if (ScriptResult.isUndefined(conversionErrorResult)) {
- fail("converter has not thrown an error");
- return;
- }
+ public void setClientFunction(String clientFunction) {
+ testBean.setClientFunction(clientFunction);
+ }
- Object conversionErrorMessage;
+ public void setAttribute(String name, Object value) {
+ testBean.setAttribute(name, value);
+ }
- Object scriptResult = conversionErrorResult.getJavaScriptResult();
- if (scriptResult instanceof Scriptable) {
- Scriptable scriptable = (Scriptable) scriptResult;
- conversionErrorMessage = scriptable.get("message", scriptable);
- } else {
- conversionErrorMessage = scriptResult;
- }
+ public void setSubmittedValue(String submittedValue) {
+ this.submittedValue = submittedValue;
+ }
- if (failureMessage != null) {
- assertEquals(failureMessage, conversionErrorMessage);
- } else {
- assertEquals(testBean.getResultException().getMessage(), conversionErrorMessage);
- }
- }
-
- public void assertValidationFailure() throws Exception {
- HtmlPage page = environment.getPage("/testValidator.jsf");
+ public void setFailureMessage(String failureMessage) {
+ this.failureMessage = failureMessage;
+ }
- assertNotNull(testBean.getResultException());
+ public void setErrorMessageEnums(Enum<?>... errorMessageEnums) {
+ testBean.setErrorMessageEnums(errorMessageEnums);
+ }
- assertTrue(page.getWebClient().isJavaScriptEnabled());
- ScriptResult validationErrorResult = page.executeJavaScript("window.validationError");
+ public void assertConversionOk() throws Exception {
+ HtmlPage page = environment.getPage("/testConverter.jsf");
+ System.out.println(page.asXml());
+ assertTrue(page.getWebClient().isJavaScriptEnabled());
+ ScriptResult conversionMessageResult = page.executeJavaScript("verifyConversion()");
+ if (!ScriptResult.isUndefined(conversionMessageResult)) {
+ fail(conversionMessageResult.getJavaScriptResult().toString());
+ }
+ }
- if (ScriptResult.isUndefined(validationErrorResult)) {
- fail("validator has not thrown an error");
- return;
- }
+ public void assertValidationOk() throws Exception {
+ HtmlPage page = environment.getPage("/testValidator.jsf");
+ System.out.println(page.asXml());
+ assertTrue(page.getWebClient().isJavaScriptEnabled());
+ ScriptResult messageResult = page.executeJavaScript("verifyValidation()");
+ if (!ScriptResult.isUndefined(messageResult)) {
+ fail(messageResult.getJavaScriptResult().toString());
+ }
+ }
- Object validationErrorMessage;
+ public void assertConversionFailure() throws Exception {
+ HtmlPage page = environment.getPage("/testConverter.jsf");
- Object scriptResult = validationErrorResult.getJavaScriptResult();
- if (scriptResult instanceof Scriptable) {
- Scriptable scriptable = (Scriptable) scriptResult;
- validationErrorMessage = scriptable.get("message", scriptable);
- } else {
- validationErrorMessage = scriptResult;
- }
+ assertNotNull(testBean.getResultException());
- if (failureMessage != null) {
- assertEquals(failureMessage, validationErrorMessage);
- } else {
- assertEquals(testBean.getResultException().getMessage(), validationErrorMessage);
- }
- }
+ assertTrue(page.getWebClient().isJavaScriptEnabled());
+ ScriptResult conversionErrorResult = page.executeJavaScript("window.conversionError");
- public void setup(TestData testData) {
- setSubmittedValue(testData.submittedValue());
- setFailureMessage(testData.failureMessage());
- }
+ if (ScriptResult.isUndefined(conversionErrorResult)) {
+ fail("converter has not thrown an error");
+ return;
+ }
+ Object conversionErrorMessage;
+
+ Object scriptResult = conversionErrorResult.getJavaScriptResult();
+ if (scriptResult instanceof Scriptable) {
+ Scriptable scriptable = (Scriptable) scriptResult;
+ conversionErrorMessage = scriptable.get("message", scriptable);
+ } else {
+ conversionErrorMessage = scriptResult;
+ }
+
+ if (failureMessage != null) {
+ assertEquals(failureMessage, conversionErrorMessage);
+ } else {
+ assertEquals(testBean.getResultException().getMessage(), conversionErrorMessage);
+ }
+ }
+
+ public void assertValidationFailure() throws Exception {
+ HtmlPage page = environment.getPage("/testValidator.jsf");
+
+ assertNotNull(testBean.getResultException());
+
+ assertTrue(page.getWebClient().isJavaScriptEnabled());
+ ScriptResult validationErrorResult = page.executeJavaScript("window.validationError");
+
+ if (ScriptResult.isUndefined(validationErrorResult)) {
+ fail("validator has not thrown an error");
+ return;
+ }
+
+ Object validationErrorMessage;
+
+ Object scriptResult = validationErrorResult.getJavaScriptResult();
+ if (scriptResult instanceof Scriptable) {
+ Scriptable scriptable = (Scriptable) scriptResult;
+ validationErrorMessage = scriptable.get("message", scriptable);
+ } else {
+ validationErrorMessage = scriptResult;
+ }
+
+ if (failureMessage != null) {
+ assertEquals(failureMessage, validationErrorMessage);
+ } else {
+ assertEquals(testBean.getResultException().getMessage(), validationErrorMessage);
+ }
+ }
+
+ public void setup(TestData testData) {
+ setSubmittedValue(testData.submittedValue());
+ setFailureMessage(testData.failureMessage());
+ }
+
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseTestRunner.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseTestRunner.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BaseTestRunner.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -47,11 +47,11 @@
public abstract class BaseTestRunner extends Suite {
private final class ParameterizedFrameworkMethod extends FrameworkMethod {
-
+
private TestData testData;
-
+
private boolean failure;
-
+
public ParameterizedFrameworkMethod(Method method, TestData testData, boolean failure) {
super(method);
this.testData = testData;
@@ -62,7 +62,7 @@
if (testData == null) {
return "no test data";
}
-
+
StringBuilder sb = new StringBuilder();
if (failure) {
@@ -70,57 +70,56 @@
} else {
sb.append("<success>");
}
-
+
sb.append(" @TestData {");
-
+
sb.append("submittedValue=" + testData.submittedValue());
-
+
if (!Strings.isNullOrEmpty(testData.failureMessage())) {
sb.append(", failureMessage=" + testData.failureMessage());
}
-
+
sb.append("}");
-
+
return sb.toString();
}
-
+
@Override
public Object invokeExplosively(final Object target, final Object... params) throws Throwable {
return new ReflectiveCallable() {
@Override
protected Object runReflectiveCall() throws Throwable {
- BaseTest baseTest = (BaseTest) target;
-
- baseTest.setSubmittedValue(testData.submittedValue());
-
- if (!Strings.isNullOrEmpty(testData.failureMessage())) {
- baseTest.setFailureMessage(testData.failureMessage());
- }
-
- Object returnValue = getMethod().invoke(target, params);
- checkResult(baseTest, failure);
-
- return returnValue;
+ BaseTest baseTest = (BaseTest) target;
+
+ baseTest.setSubmittedValue(testData.submittedValue());
+
+ if (!Strings.isNullOrEmpty(testData.failureMessage())) {
+ baseTest.setFailureMessage(testData.failureMessage());
+ }
+
+ Object returnValue = getMethod().invoke(target, params);
+ checkResult(baseTest, failure);
+
+ return returnValue;
}
}.run();
}
}
-
+
protected abstract void checkResult(BaseTest baseTest, boolean failure) throws Throwable;
-
+
private class ParameterizedTestRunner extends BlockJUnit4ClassRunner {
-
+
private String testMethodName;
-
+
private List<FrameworkMethod> children = Lists.newArrayList();
-
- public ParameterizedTestRunner(Class<?> klass, FrameworkMethod testMethod)
- throws InitializationError {
+ public ParameterizedTestRunner(Class<?> klass, FrameworkMethod testMethod) throws InitializationError {
+
super(klass);
-
+
this.testMethodName = testMethod.getName();
-
+
TestDataHolder testDataHolder = testMethod.getAnnotation(TestDataHolder.class);
if (testDataHolder != null) {
for (TestData testData : testDataHolder.successes()) {
@@ -149,10 +148,10 @@
protected String testName(final FrameworkMethod method) {
if (method instanceof ParameterizedFrameworkMethod) {
String formattedParamsString = ((ParameterizedFrameworkMethod) method).getFormattedParameters();
-
+
return String.format("%s %s", testMethodName, formattedParamsString);
}
-
+
return testMethodName;
}
@@ -165,12 +164,12 @@
protected Statement classBlock(RunNotifier notifier) {
return childrenInvoker(notifier);
}
-
+
@Override
protected List<FrameworkMethod> getChildren() {
return children;
}
-
+
}
private final ArrayList<Runner> runners = new ArrayList<Runner>();
@@ -179,11 +178,11 @@
* Only called reflectively. Do not use programmatically.
*/
public BaseTestRunner(Class<?> klass) throws Throwable {
- super(klass, Collections.<Runner>emptyList());
-
+ super(klass, Collections.<Runner> emptyList());
+
TestClass testClass = getTestClass();
List<FrameworkMethod> testMethods = testClass.getAnnotatedMethods(Test.class);
- for (FrameworkMethod testMethod: testMethods) {
+ for (FrameworkMethod testMethod : testMethods) {
runners.add(new ParameterizedTestRunner(klass, testMethod));
}
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BooleanConverterTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BooleanConverterTest.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/BooleanConverterTest.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -39,18 +39,9 @@
}
@Test
- @TestDataHolder(
- successes = {
- @TestData(submittedValue = "true"),
- @TestData(submittedValue = "True"),
- @TestData(submittedValue = "TRUE"),
- @TestData(submittedValue = "false"),
- @TestData(submittedValue = "0"),
- @TestData(submittedValue = "1"),
- @TestData(submittedValue = "")
- },
- failures = {}
- )
+ @TestDataHolder(successes = { @TestData(submittedValue = "true"), @TestData(submittedValue = "True"),
+ @TestData(submittedValue = "TRUE"), @TestData(submittedValue = "false"), @TestData(submittedValue = "0"),
+ @TestData(submittedValue = "1"), @TestData(submittedValue = "") }, failures = {})
public void testSuccess() throws Exception {
setClientFunction("RichFaces.csv.getConverter('boolean')");
setObjectId(BooleanConverter.CONVERTER_ID);
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -39,22 +39,10 @@
}
@Test
- @TestDataHolder(
- successes = {
- @TestData(submittedValue = "-128"),
- @TestData(submittedValue = "0"),
- @TestData(submittedValue = "127")
- },
- failures = {
- @TestData(submittedValue = "-129"),
- @TestData(submittedValue = "128"),
- @TestData(submittedValue = "1.0"),
- @TestData(submittedValue = "1.2"),
- @TestData(submittedValue = "1a"),
- @TestData(submittedValue = "aaa"),
- @TestData(submittedValue = "- 127")
- }
- )
+ @TestDataHolder(successes = { @TestData(submittedValue = "-128"), @TestData(submittedValue = "0"),
+ @TestData(submittedValue = "127") }, failures = { @TestData(submittedValue = "-129"),
+ @TestData(submittedValue = "128"), @TestData(submittedValue = "1.0"), @TestData(submittedValue = "1.2"),
+ @TestData(submittedValue = "1a"), @TestData(submittedValue = "aaa"), @TestData(submittedValue = "- 127") })
public void testSuccess() throws Exception {
setClientFunction("RichFaces.csv.getConverter('byte')");
setObjectId(ByteConverter.CONVERTER_ID);
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ConverterTestRunner.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ConverterTestRunner.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ConverterTestRunner.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -27,15 +27,15 @@
*/
public class ConverterTestRunner extends BaseTestRunner {
- public ConverterTestRunner(Class<?> klass) throws Throwable {
- super(klass);
- }
+ public ConverterTestRunner(Class<?> klass) throws Throwable {
+ super(klass);
+ }
- protected void checkResult (BaseTest baseTest, boolean failure) throws Throwable {
- if (failure) {
- baseTest.assertConversionFailure();
- } else {
- baseTest.assertConversionOk();
- }
- }
+ protected void checkResult(BaseTest baseTest, boolean failure) throws Throwable {
+ if (failure) {
+ baseTest.assertConversionFailure();
+ } else {
+ baseTest.assertConversionOk();
+ }
+ }
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -36,25 +36,21 @@
public DateTimeConverterTest() {
super("org/richfaces/convert/testConverter.js");
}
-
+
@Test
- @TestDataHolder(
- successes = {
- @TestData(submittedValue = "18-10-2010"),
- //@TestData(submittedValue = "17-10-2010")
- },
- failures = {
- //@TestData(submittedValue = "10/17/2010")
- }
- )
+ @TestDataHolder(successes = { @TestData(submittedValue = "18-10-2010"),
+ // @TestData(submittedValue = "17-10-2010")
+ }, failures = {
+ // @TestData(submittedValue = "10/17/2010")
+ })
public void testPattern() throws Exception {
setClientFunction("org.rf.DateTimeConverter");
setObjectId(DateTimeConverter.CONVERTER_ID);
setAttribute("pattern", "dd-MM-yyyy");
}
-
+
@Test
public void testNoPattern() throws Exception {
-
+
}
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/LengthValidatorTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/LengthValidatorTest.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/LengthValidatorTest.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -39,18 +39,11 @@
}
@Test
- @TestDataHolder(
- successes = {
- @TestData(submittedValue = "dddd")
- },
- failures = {
- @TestData(submittedValue = "1234567890A")
- }
- )
+ @TestDataHolder(successes = { @TestData(submittedValue = "dddd") }, failures = { @TestData(submittedValue = "1234567890A") })
public void testSuccess() throws Exception {
- setClientFunction("RichFaces.csv.getValidator('length')");
+ setClientFunction("RichFaces.csv.getValidator('length')");
setObjectId(LengthValidator.VALIDATOR_ID);
- Enum<?>[] messages = {FacesMessages.LENGTH_VALIDATOR_MAXIMUM, FacesMessages.LENGTH_VALIDATOR_MINIMUM};
+ Enum<?>[] messages = { FacesMessages.LENGTH_VALIDATOR_MAXIMUM, FacesMessages.LENGTH_VALIDATOR_MINIMUM };
setErrorMessageEnums(messages);
setAttribute("maximum", 10);
setAttribute("minimum", 0);
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -39,18 +39,11 @@
}
@Test
- @TestDataHolder(
- successes = {
- @TestData(submittedValue = "111")
- },
- failures = {
- @TestData(submittedValue = "aaa")
- }
- )
+ @TestDataHolder(successes = { @TestData(submittedValue = "111") }, failures = { @TestData(submittedValue = "aaa") })
public void testSuccess() throws Exception {
setClientFunction("RichFaces.csv.getConverter('number')");
setObjectId(NumberConverter.CONVERTER_ID);
setErrorMessageEnums(FacesMessages.NUMBER_CONVERTER_NUMBER);
}
-
+
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -39,22 +39,10 @@
}
@Test
- @TestDataHolder(
- successes = {
- @TestData(submittedValue = "-32768"),
- @TestData(submittedValue = "0"),
- @TestData(submittedValue = "32767")
- },
- failures = {
- @TestData(submittedValue = "-32769"),
- @TestData(submittedValue = "32768"),
- @TestData(submittedValue = "1.0"),
- @TestData(submittedValue = "1.2"),
- @TestData(submittedValue = "1a"),
- @TestData(submittedValue = "aaa"),
- @TestData(submittedValue = "- 10")
- }
- )
+ @TestDataHolder(successes = { @TestData(submittedValue = "-32768"), @TestData(submittedValue = "0"),
+ @TestData(submittedValue = "32767") }, failures = { @TestData(submittedValue = "-32769"),
+ @TestData(submittedValue = "32768"), @TestData(submittedValue = "1.0"), @TestData(submittedValue = "1.2"),
+ @TestData(submittedValue = "1a"), @TestData(submittedValue = "aaa"), @TestData(submittedValue = "- 10") })
public void testSuccess() throws Exception {
setClientFunction("RichFaces.csv.getConverter('short')");
setObjectId(ShortConverter.CONVERTER_ID);
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/TestData.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/TestData.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/TestData.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -28,6 +28,7 @@
/**
* Test data annotation for {@link BaseTest}
+ *
* @author Nick Belaevski
*
*/
@@ -36,7 +37,7 @@
public @interface TestData {
public String submittedValue();
-
+
public String failureMessage() default "";
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/TestDataHolder.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/TestDataHolder.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/TestDataHolder.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -28,6 +28,7 @@
/**
* Holder element for multiple {@link TestData} elements
+ *
* @author Nick Belaevski
*
*/
@@ -36,7 +37,7 @@
public @interface TestDataHolder {
public TestData[] successes();
-
+
public TestData[] failures();
-
+
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ValidatorTestRunner.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ValidatorTestRunner.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ValidatorTestRunner.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -27,15 +27,15 @@
*/
public class ValidatorTestRunner extends BaseTestRunner {
- public ValidatorTestRunner(Class<?> klass) throws Throwable {
- super(klass);
- }
+ public ValidatorTestRunner(Class<?> klass) throws Throwable {
+ super(klass);
+ }
- protected void checkResult (BaseTest baseTest, boolean failure) throws Throwable {
- if (failure) {
- baseTest.assertValidationFailure();
- } else {
- baseTest.assertValidationOk();
- }
- }
+ protected void checkResult(BaseTest baseTest, boolean failure) throws Throwable {
+ if (failure) {
+ baseTest.assertValidationFailure();
+ } else {
+ baseTest.assertValidationOk();
+ }
+ }
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -40,7 +40,7 @@
@RunWith(MockTestRunner.class)
public class RendererGetComponentScriptTest extends RendererTestBase {
- private static final String JSF_AJAX_REQUEST = "jsf.ajax.request(this,event)";
+ private static final String JSF_AJAX_REQUEST = "jsf.ajax.request(element,event)";
private static final String NUMBER_CONVERTER = "numConverter";
@@ -87,6 +87,7 @@
private void exceptGetAjaxScript() {
expect(mockBehavior.getAjaxScript(behaviorContext)).andReturn(JSF_AJAX_REQUEST);
+ expect(behaviorContext.getSourceId()).andStubReturn("clientValidator");
}
/**
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java 2010-11-01 19:48:34 UTC (rev 19861)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java 2010-11-01 19:50:05 UTC (rev 19862)
@@ -25,6 +25,8 @@
public class RendererGetOrCreateResourceTest extends RendererTestBase {
private static final String FUNCTION_NAME = "inputValidate";
+
+ private static final String SOURCE_ID ="clientValidator";
@Mock
private UIViewRoot viewRoot;
@@ -105,7 +107,8 @@
};
};
setupBehaviorContext(input);
- expect(validatorScript.createCallScript(FUNCTION_NAME)).andReturn(FUNCTION_NAME);
+ expect(behaviorContext.getSourceId()).andStubReturn(SOURCE_ID);
+ expect(validatorScript.createCallScript(FUNCTION_NAME,SOURCE_ID)).andReturn(FUNCTION_NAME);
expect(input.getClientId(facesContext)).andReturn(FUNCTION_NAME);
controller.replay();
assertEquals(FUNCTION_NAME, renderer.buildAndStoreValidatorScript(behaviorContext, mockBehavior));
13 years, 6 months
JBoss Rich Faces SVN: r19860 - trunk.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 15:15:29 -0400 (Mon, 01 Nov 2010)
New Revision: 19860
Modified:
trunk/
Log:
Added mergeinfo for RF-7817
Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
- /branches/RF-9309:1-19112,19378
+ /branches/RF-7817:1-19154 /branches/RF-9309:1-19112,19378
13 years, 6 months
JBoss Rich Faces SVN: r19859 - trunk/examples.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 15:11:05 -0400 (Mon, 01 Nov 2010)
New Revision: 19859
Modified:
trunk/examples/pom.xml
Log:
https://jira.jboss.org/browse/RF-9600
Modified: trunk/examples/pom.xml
===================================================================
--- trunk/examples/pom.xml 2010-11-01 19:09:23 UTC (rev 19858)
+++ trunk/examples/pom.xml 2010-11-01 19:11:05 UTC (rev 19859)
@@ -45,7 +45,7 @@
<module>output-demo</module>
<module>input-demo</module>
<module>repeater-demo</module>
- <!--module>iteration-demo</module-->
+ <module>iteration-demo</module>
<module>richfaces-showcase</module>
<!--<module>dist</module>-->
</modules>
13 years, 6 months
JBoss Rich Faces SVN: r19858 - in trunk/ui/iteration: ui/src/main/java/org/richfaces/component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 15:09:23 -0400 (Mon, 01 Nov 2010)
New Revision: 19858
Added:
trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
Removed:
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
Log:
https://jira.jboss.org/browse/RF-9609
Added: trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
===================================================================
--- trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java (rev 0)
+++ trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java 2010-11-01 19:09:23 UTC (rev 19858)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Iterator;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+//TODO - add necessary methods for tree adaptors support
+public interface TreeDataModel<E> {
+
+ public Object getRowKey();
+
+ public void setRowKey(Object rowKey);
+
+ public boolean isDataAvailable();
+
+ public E getData();
+
+ public Iterator<Object> getChildrenRowKeysIterator(Object rowKey);
+
+ public Object getParentRowKey(Object rowKey);
+
+ public Object getWrappedData();
+
+ public void setWrappedData(Object data);
+
+}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01 18:02:02 UTC (rev 19857)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01 19:09:23 UTC (rev 19858)
@@ -43,6 +43,7 @@
import javax.faces.event.ExceptionQueuedEventContext;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
+import javax.swing.tree.TreeNode;
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.ExtendedDataModel;
@@ -62,7 +63,9 @@
import org.richfaces.event.TreeSelectionListener;
import org.richfaces.event.TreeToggleEvent;
import org.richfaces.event.TreeToggleListener;
-import org.richfaces.model.TreeDataModelImpl;
+import org.richfaces.model.ExtendedTreeDataModelImpl;
+import org.richfaces.model.SwingTreeNodeDataModelImpl;
+import org.richfaces.model.TreeDataModel;
import org.richfaces.renderkit.MetaComponentRenderer;
import com.google.common.base.Predicate;
@@ -210,12 +213,9 @@
getStateHelper().put(PropertyKeys.expanded, this.getClientId(getFacesContext()), newValue);
}
- /* (non-Javadoc)
- * @see org.richfaces.component.UIDataAdaptor#createExtendedDataModel()
- */
@Override
protected ExtendedDataModel<?> createExtendedDataModel() {
- TreeDataModelImpl model = new TreeDataModelImpl();
+ ExtendedTreeDataModelImpl<?> model = new ExtendedTreeDataModelImpl<TreeNode>(new SwingTreeNodeDataModelImpl());
model.setWrappedData(getValue());
return model;
}
@@ -235,8 +235,9 @@
return converter;
}
- public Iterator<Object> getChildrenIterator(FacesContext faces, Object rowKey) {
- return ((TreeDataModelImpl) getExtendedDataModel()).getChildrenIterator(faces, rowKey);
+ public Iterator<Object> getChildrenRowKeysIterator(FacesContext faces, Object rowKey) {
+ TreeDataModel<?> dataModel = (TreeDataModel<?>) getExtendedDataModel();
+ return dataModel.getChildrenRowKeysIterator(rowKey);
}
public AbstractTreeNode getTreeNodeComponent() {
Copied: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java (from rev 19848, trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java)
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java 2010-11-01 19:09:23 UTC (rev 19858)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Iterator;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.richfaces.component.TreeRange;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ExtendedTreeDataModelImpl<E> extends ExtendedDataModel<E> implements TreeDataModel<E> {
+
+ private TreeDataModel<E> wrappedModel;
+
+ public ExtendedTreeDataModelImpl(TreeDataModel<E> wrappedModel) {
+ super();
+ this.wrappedModel = wrappedModel;
+ }
+
+ public boolean isDataAvailable() {
+ return wrappedModel.isDataAvailable();
+ }
+
+ public E getData() {
+ return wrappedModel.getData();
+ }
+
+ public Iterator<Object> getChildrenRowKeysIterator(Object rowKey) {
+ return wrappedModel.getChildrenRowKeysIterator(rowKey);
+ }
+
+ public Object getParentRowKey(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setRowKey(Object key) {
+ wrappedModel.setRowKey(key);
+ }
+
+ @Override
+ public Object getRowKey() {
+ return wrappedModel.getRowKey();
+ }
+
+ protected void walk(FacesContext context, DataVisitor visitor, Range range, Object argument, Iterator<Object> keysIterator) {
+ while (keysIterator.hasNext()) {
+ Object object = (Object) keysIterator.next();
+
+ DataVisitResult visitResult = visitor.process(context, object, argument);
+ if (visitResult == DataVisitResult.CONTINUE) {
+ if (((TreeRange) range).shouldIterateChildren(object)) {
+ Iterator<Object> childrenIterator = getChildrenRowKeysIterator(object);
+ walk(context, visitor, range, argument, childrenIterator);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
+ TreeRange treeRange = (TreeRange) range;
+ if (treeRange.shouldIterateChildren(null)) {
+ Iterator<Object> iterator = getChildrenRowKeysIterator(null);
+ walk(context, visitor, range, argument, iterator);
+ }
+ }
+
+ @Override
+ public boolean isRowAvailable() {
+ return wrappedModel.isDataAvailable();
+ }
+
+ @Override
+ public int getRowCount() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public E getRowData() {
+ return wrappedModel.getData();
+ }
+
+ @Override
+ public int getRowIndex() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setRowIndex(int rowIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object getWrappedData() {
+ return wrappedModel.getWrappedData();
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ wrappedModel.setWrappedData(data);
+ }
+
+
+}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-11-01 19:09:23 UTC (rev 19858)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import javax.swing.tree.TreeNode;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SwingTreeNodeDataModelImpl implements TreeDataModel<TreeNode> {
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private final class FakeRootNode implements TreeNode {
+ public boolean isLeaf() {
+ return !wrappedData.isEmpty();
+ }
+
+ public TreeNode getParent() {
+ return null;
+ }
+
+ public int getIndex(TreeNode node) {
+ if (wrappedData == null) {
+ return -1;
+ }
+
+ return Iterables.indexOf(wrappedData, Predicates.equalTo(node));
+ }
+
+ public int getChildCount() {
+ if (wrappedData == null) {
+ return 0;
+ }
+
+ return wrappedData.size();
+ }
+
+ public TreeNode getChildAt(int childIndex) {
+ if (wrappedData == null) {
+ throw new NoSuchElementException(String.valueOf(childIndex));
+ }
+
+ return Iterables.get(wrappedData, childIndex);
+ }
+
+ public boolean getAllowsChildren() {
+ return true;
+ }
+
+ public Enumeration<?> children() {
+ if (wrappedData == null) {
+ return Iterators.asEnumeration(Iterators.emptyIterator());
+ }
+
+ return Iterators.asEnumeration(wrappedData.iterator());
+ }
+ }
+
+ private static final SequenceRowKey<Integer> EMPTY_SEQUENCE_ROW_KEY = new SequenceRowKey<Integer>();
+
+ private Collection<TreeNode> wrappedData = null;
+
+ private TreeNode fakeRootNode = new FakeRootNode();
+
+ private TreeNode selectedNode;
+
+ private SequenceRowKey<Integer> selectedRowKey;
+
+ private Iterator<TreeNode> findChildren(SequenceRowKey<Integer> compositeKey) {
+ TreeNode treeNode = findNode(compositeKey);
+
+ if (treeNode == null) {
+ return Iterators.emptyIterator();
+ }
+
+ return Iterators.forEnumeration((Enumeration<TreeNode>) treeNode.children());
+ }
+
+ private TreeNode findNode(SequenceRowKey<Integer> compositeKey) {
+ if (compositeKey == null) {
+ return null;
+ }
+
+ TreeNode result = fakeRootNode;
+
+ for (Integer simpleKey : compositeKey.getSimpleKeys()) {
+ int idx = simpleKey.intValue();
+
+ if (idx < result.getChildCount()) {
+ result = result.getChildAt(idx);
+ } else {
+ result = null;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ public void setRowKey(Object key) {
+ this.selectedRowKey = (SequenceRowKey<Integer>) key;
+ this.selectedNode = findNode(selectedRowKey);
+ }
+
+ public Object getRowKey() {
+ return selectedRowKey;
+ }
+
+ private SequenceRowKey<Integer> castKeyAndWrapNull(Object rowKey) {
+ if (rowKey == null) {
+ return EMPTY_SEQUENCE_ROW_KEY;
+ }
+
+ return (SequenceRowKey<Integer>) rowKey;
+ }
+
+ public Iterator<Object> getChildrenRowKeysIterator(Object rowKey) {
+ SequenceRowKey<Integer> sequenceKey = castKeyAndWrapNull(rowKey);
+ Iterator<TreeNode> itr = findChildren(sequenceKey);
+
+ return new SequenceRowKeyIterator<TreeNode>(sequenceKey, itr);
+ }
+
+ public TreeNode getData() {
+ if (!isDataAvailable()) {
+ throw new IllegalArgumentException();
+ }
+
+ return selectedNode;
+ }
+
+ public Object getParentRowKey(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isDataAvailable() {
+ return selectedNode != null;
+ }
+
+ public Object getWrappedData() {
+ return wrappedData;
+ }
+
+ public void setWrappedData(Object wrappedData) {
+ this.wrappedData = (Collection<TreeNode>) wrappedData;
+ }
+}
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-11-01 18:02:02 UTC (rev 19857)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-11-01 19:09:23 UTC (rev 19858)
@@ -1,184 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.model;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-import javax.swing.tree.TreeNode;
-
-import org.ajax4jsf.model.DataVisitResult;
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.richfaces.component.TreeRange;
-
-import com.google.common.collect.Iterators;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class TreeDataModelImpl extends ExtendedDataModel<TreeNode> {
-
- private static final SequenceRowKey<Integer> EMPTY_SEQUENCE_ROW_KEY = new SequenceRowKey<Integer>();
-
- private SwingTreeNodeImpl<?> rootNode;
-
- private TreeNode selectedNode;
-
- private SequenceRowKey<Integer> selectedRowKey;
-
- private Iterator<TreeNode> findChildren(SequenceRowKey<Integer> compositeKey) {
- TreeNode treeNode = findNode(compositeKey);
-
- if (treeNode == null) {
- return Iterators.emptyIterator();
- }
-
- return Iterators.forEnumeration((Enumeration<TreeNode>) treeNode.children());
- }
-
- private TreeNode findNode(SequenceRowKey<Integer> compositeKey) {
- if (compositeKey == null) {
- return null;
- }
-
- TreeNode result = rootNode;
-
- for (Integer simpleKey : compositeKey.getSimpleKeys()) {
- int idx = simpleKey.intValue();
-
- if (idx < result.getChildCount()) {
- result = result.getChildAt(idx);
- } else {
- result = null;
- break;
- }
- }
-
- return result;
- }
-
- @Override
- public void setRowKey(Object key) {
- this.selectedRowKey = (SequenceRowKey<Integer>) key;
- this.selectedNode = findNode(selectedRowKey);
- }
-
- @Override
- public Object getRowKey() {
- return selectedRowKey;
- }
-
- @Override
- public boolean isRowAvailable() {
- return selectedNode != null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- @Override
- public int getRowCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public TreeNode getRowData() {
- return selectedNode;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- @Override
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- @Override
- public void setRowIndex(int rowIndex) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Object getWrappedData() {
- return rootNode.getChildrenList();
- }
-
- @Override
- public void setWrappedData(Object data) {
- this.rootNode = new SwingTreeNodeImpl((List<TreeNode>) data);
- }
-
- private SequenceRowKey<Integer> castKeyAndWrapNull(Object rowKey) {
- if (rowKey == null) {
- return EMPTY_SEQUENCE_ROW_KEY;
- }
-
- return (SequenceRowKey<Integer>) rowKey;
- }
-
- public Iterator<Object> getChildrenIterator(FacesContext faces, Object rowKey) {
- SequenceRowKey<Integer> sequenceKey = castKeyAndWrapNull(rowKey);
- Iterator<TreeNode> itr = findChildren(sequenceKey);
-
- return new SequenceRowKeyIterator<TreeNode>(sequenceKey, itr);
- }
-
- protected void walk(FacesContext context, DataVisitor visitor, Range range, Object argument, Iterator<Object> keysIterator) {
- while (keysIterator.hasNext()) {
- Object object = (Object) keysIterator.next();
-
- DataVisitResult visitResult = visitor.process(context, object, argument);
- if (visitResult == DataVisitResult.CONTINUE) {
- if (((TreeRange) range).shouldIterateChildren(object)) {
- Iterator<Object> childrenIterator = getChildrenIterator(context, object);
- walk(context, visitor, range, argument, childrenIterator);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
- */
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
- // TODO Auto-generated method stub
-
- if (((TreeRange) range).shouldIterateChildren(null)) {
- Iterator<Object> iterator = getChildrenIterator(context, null);
- walk(context, visitor, range, argument, iterator);
- }
- }
-
-}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-01 18:02:02 UTC (rev 19857)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-01 19:09:23 UTC (rev 19858)
@@ -104,7 +104,7 @@
boolean iterateChildren = treeRange.shouldIterateChildren(rowKey);
if (iterateChildren) {
- encodeTree(tree.getChildrenIterator(context, rowKey));
+ encodeTree(tree.getChildrenRowKeysIterator(context, rowKey));
}
QueuedData data = queuedData.removeLast();
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java 2010-11-01 18:02:02 UTC (rev 19857)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java 2010-11-01 19:09:23 UTC (rev 19858)
@@ -38,7 +38,7 @@
public void encode() throws java.io.IOException {
Object initialRowKey = tree.getRowKey();
try {
- encodeTree(tree.getChildrenIterator(context, null));
+ encodeTree(tree.getChildrenRowKeysIterator(context, null));
} finally {
try {
tree.setRowKey(context, initialRowKey);
13 years, 6 months
JBoss Rich Faces SVN: r19857 - in trunk/ui/iteration/ui/src/main: resources/META-INF/resources/org.richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 14:02:02 -0400 (Mon, 01 Nov 2010)
New Revision: 19857
Added:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java
Removed:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/last.gif
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/line.gif
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/minus.gif
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/plus.gif
Modified:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
trunk/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
Log:
https://jira.jboss.org/browse/RF-9316
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java 2010-11-01 18:02:02 UTC (rev 19857)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.CacheableResource;
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.StateHolderResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public abstract class BaseTreeImage implements Java2DUserResource, StateHolderResource, CacheableResource {
+
+ private Dimension dimension;
+
+ protected BaseTreeImage(Dimension dimension) {
+ super();
+ this.dimension = dimension;
+ }
+ public boolean isCacheable(FacesContext context) {
+ return true;
+ }
+ public Date getExpires(FacesContext context) {
+ return null;
+ }
+
+ public int getTimeToLive(FacesContext context) {
+ return -1;
+ }
+
+ public String getEntityTag(FacesContext context) {
+ return null;
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.PNG;
+ }
+
+ public Dimension getDimension() {
+ return dimension;
+ }
+
+}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java 2010-11-01 18:02:02 UTC (rev 19857)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreeLineImage extends BaseTreeImage {
+
+ private static final Dimension DIMENSION = new Dimension(16, 16);
+
+ protected Integer trimColorValue;
+
+ public TreeLineImage() {
+ super(DIMENSION);
+ }
+
+ protected TreeLineImage(Dimension dimension) {
+ super(dimension);
+ }
+
+ @PostConstructResource
+ public void init() {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ trimColorValue = skin.getColorParameter(context, Skin.TRIM_COLOR);
+ }
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ g2d.setColor(new Color(trimColorValue));
+
+ g2d.drawLine(7, 0, 7, 15);
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ dataOutput.writeInt(trimColorValue);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException {
+ trimColorValue = dataInput.readInt();
+ }
+
+
+
+}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java 2010-11-01 18:02:02 UTC (rev 19857)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+import org.richfaces.resource.DynamicResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreeLineLastImage extends TreeLineImage {
+
+ private static final Dimension DIMENSION = new Dimension(16, 200);
+
+ public TreeLineLastImage() {
+ super(DIMENSION);
+ }
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ g2d.setColor(new Color(trimColorValue));
+
+ g2d.drawLine(7, 0, 7, 99);
+ g2d.drawLine(7, 99, 15, 99);
+ }
+
+}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java 2010-11-01 18:02:02 UTC (rev 19857)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+import org.richfaces.resource.DynamicResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreeMinusImage extends TreePlusImage {
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ drawFrame(g2d);
+ drawHorizontalCrossLine(g2d);
+ }
+
+}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java 2010-11-01 18:02:02 UTC (rev 19857)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreePlusImage extends BaseTreeImage {
+
+ private static final Dimension DIMENSION = new Dimension(16, 16);
+
+ protected Integer generalColorValue;
+
+ protected Integer controlColorValue;
+
+ protected Integer trimColorValue;
+
+ public TreePlusImage() {
+ super(DIMENSION);
+ }
+
+ @PostConstructResource
+ public void init() {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ generalColorValue = skin.getColorParameter(context, Skin.GENERAL_TEXT_COLOR);
+ controlColorValue = skin.getColorParameter(context, Skin.CONTROL_BACKGROUND_COLOR);
+ trimColorValue = skin.getColorParameter(context, Skin.TRIM_COLOR);
+ }
+
+ protected void drawFrame(Graphics2D g2d) {
+ Color trimColor = new Color(trimColorValue);
+ Color controlColor = new Color(controlColorValue);
+
+ g2d.setColor(trimColor);
+ g2d.drawRect(3, 3, 8, 8);
+
+ Rectangle2D rect = new Rectangle2D.Float(4, 4, 7, 7);
+ GradientPaint gragient = new GradientPaint(4, 4, controlColor, 13, 13, trimColor);
+ g2d.setPaint(gragient);
+ g2d.fill(rect);
+ }
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ drawFrame(g2d);
+
+ drawHorizontalCrossLine(g2d);
+ drawVerticalCrossLine(g2d);
+ }
+
+ protected void drawVerticalCrossLine(Graphics2D g2d) {
+ g2d.setColor(new Color(generalColorValue));
+ //vertical cross line
+ g2d.drawLine(7, 5, 7, 9);
+ }
+
+ protected void drawHorizontalCrossLine(Graphics2D g2d) {
+ g2d.setColor(new Color(generalColorValue));
+ //horizontal cross line
+ g2d.drawLine(5, 7, 9, 7);
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ dataOutput.writeInt(generalColorValue);
+ dataOutput.writeInt(controlColorValue);
+ dataOutput.writeInt(trimColorValue);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException {
+ generalColorValue = dataInput.readInt();
+ controlColorValue = dataInput.readInt();
+ trimColorValue = dataInput.readInt();
+ }
+
+}
Deleted: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/last.gif
===================================================================
(Binary files differ)
Deleted: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/line.gif
===================================================================
(Binary files differ)
Deleted: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/minus.gif
===================================================================
(Binary files differ)
Deleted: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/plus.gif
===================================================================
(Binary files differ)
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-11-01 16:54:36 UTC (rev 19856)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-11-01 18:02:02 UTC (rev 19857)
@@ -1,5 +1,5 @@
.rf-trn {
- background: "url(#{resource['org.richfaces.images:last.gif']}) no-repeat center left";
+ background: "url(#{resource['org.richfaces.images:last.png']}) no-repeat center left";
cursor: default;
font-size: '#{richSkin.generalSizeFont}';
font-family: '#{richSkin.generalFamilyFont}';
@@ -26,7 +26,7 @@
}
.rf-tr-nd {
- background: "url(#{resource['org.richfaces.images:line.gif']}) repeat-y";
+ background: "url(#{resource['org.richfaces.images:line.png']}) repeat-y";
}
.rf-tr-nd-last {
@@ -51,11 +51,11 @@
}
.rf-trn-hnd-colps {
- background: "url(#{resource['org.richfaces.images:plus.gif']}) no-repeat center";
+ background: "url(#{resource['org.richfaces.images:plus.png']}) no-repeat center";
}
.rf-trn-hnd-exp {
- background: "url(#{resource['org.richfaces.images:minus.gif']}) no-repeat center";
+ background: "url(#{resource['org.richfaces.images:minus.png']}) no-repeat center";
}
.rf-trn-ico-nd {
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-11-01 16:54:36 UTC (rev 19856)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-11-01 18:02:02 UTC (rev 19857)
@@ -6,9 +6,9 @@
{baseColorParam=additionalBackgroundColor, gradientColorParam=tableBackgroundColor}
org.richfaces.images\:colHdrGrad.png=org.richfaces.renderkit.html.BaseGradient\
{baseColorParam=tableSubHeaderBackgroundColor, gradientColorParam=tableHeaderBackgroundColor}
-org.richfaces.images\:last.gif=org.richfaces\:last.gif
-org.richfaces.images\:line.gif=org.richfaces\:line.gif
-org.richfaces.images\:plus.gif=org.richfaces\:plus.gif
-org.richfaces.images\:minus.gif=org.richfaces\:minus.gif
+org.richfaces.images\:last.png=org.richfaces.renderkit.html.images.TreeLineLastImage
+org.richfaces.images\:line.png=org.richfaces.renderkit.html.images.TreeLineImage
+org.richfaces.images\:plus.png=org.richfaces.renderkit.html.images.TreePlusImage
+org.richfaces.images\:minus.png=org.richfaces.renderkit.html.images.TreeMinusImage
org.richfaces.images\:node_icon.gif=org.richfaces\:node_icon.gif
org.richfaces.images\:leaf_icon.gif=org.richfaces\:leaf_icon.gif
\ No newline at end of file
13 years, 6 months
JBoss Rich Faces SVN: r19855 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-11-01 12:54:18 -0400 (Mon, 01 Nov 2010)
New Revision: 19855
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss
Log:
RF-9598, RF-9594
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss 2010-11-01 16:42:07 UTC (rev 19854)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss 2010-11-01 16:54:18 UTC (rev 19855)
@@ -243,7 +243,6 @@
.rf-ca-edtr-shdw {
background: '#{richSkin.tableBackgroundColor}';
opacity: 0.5;
- filter: alpha(opacity=50);
}
.rf-ca-time-layout {
@@ -328,18 +327,20 @@
margin: 0px 2px;
}
-.rf-ca-sp-up {
- background-image: "url(#{resource['org.richfaces.renderkit.html.images.StandardButtonBgImage']})";
+.rf-ca-sp-up, .rf-ca-sp-down {
+ background-repeat: no-repeat;
+ background-position: 50% 40%;
height: 7px;
width: 14px;
- margin: 0px 1px 1px 0px;
+ margin: 0px 1px 1px 0px;
}
+.rf-ca-sp-up {
+ background-image: "url(#{resource['org.richfaces.renderkit.html.images.SpinnerArrowTop']})";
+}
+
.rf-ca-sp-down {
- background-image: "url(#{resource['org.richfaces.renderkit.html.images.StandardButtonPressedBgImage']})";
- height: 7px;
- width: 14px;
- margin: 0px 1px 1px 0px;
+ background-image: "url(#{resource['org.richfaces.renderkit.html.images.SpinnerArrowBottom']})";
}
.rf-ca-sp-press {
@@ -356,7 +357,6 @@
background-color: '#{richSkin.shadowBackgroundColor}';
position: absolute;
opacity: 0.3;
- filter: alpha(opacity=30);
}
.rf-ca-edtr-btn {
13 years, 6 months
JBoss Rich Faces SVN: r19854 - in trunk: examples/iteration-demo/src/main/webapp and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 12:42:07 -0400 (Mon, 01 Nov 2010)
New Revision: 19854
Added:
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java
Modified:
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
trunk/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
Log:
https://jira.jboss.org/browse/RF-9315
- selection refactoring
Added: trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java
===================================================================
--- trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java (rev 0)
+++ trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java 2010-11-01 16:42:07 UTC (rev 19854)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.richfaces.log.LogFactory;
+import org.richfaces.log.Logger;
+
+import com.google.common.collect.ForwardingIterator;
+import com.google.common.collect.ForwardingSet;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TracingSet<E> extends ForwardingSet<E> implements Serializable {
+
+ private static final long serialVersionUID = 267329344963751893L;
+
+ private static final Logger LOGGER = LogFactory.getLogger(TracingSet.class);
+
+ private class TracingIterator extends ForwardingIterator<E> {
+
+ private final Iterator<E> itr = backingCollection.iterator();
+
+ private E lastObject;
+
+ @Override
+ protected Iterator<E> delegate() {
+ return itr;
+ }
+
+ @Override
+ public E next() {
+ try {
+ lastObject = super.next();
+ return lastObject;
+ } catch (NoSuchElementException e) {
+ lastObject = null;
+ throw e;
+ }
+ }
+
+ @Override
+ public void remove() {
+ LOGGER.info("TracingSet.TracingIterator.remove() " + lastObject);
+ super.remove();
+ }
+ }
+
+ private Set<E> backingCollection = new HashSet<E>();
+
+ @Override
+ protected Set<E> delegate() {
+ return backingCollection;
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> collection) {
+ LOGGER.info("TracingSet.removeAll() " + collection);
+ return super.removeAll(collection);
+ }
+
+ @Override
+ public boolean add(E element) {
+ LOGGER.info("TracingSet.add() " + element);
+ return super.add(element);
+ }
+
+ @Override
+ public boolean remove(Object object) {
+ LOGGER.info("TracingSet.remove() " + object);
+ return super.remove(object);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends E> collection) {
+ LOGGER.info("TracingSet.addAll() " + collection);
+ return super.addAll(collection);
+ }
+
+ @Override
+ public void clear() {
+ LOGGER.info("TracingSet.clear()");
+ super.clear();
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return new TracingIterator();
+ }
+}
Modified: trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
===================================================================
--- trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-11-01 16:23:04 UTC (rev 19853)
+++ trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-11-01 16:42:07 UTC (rev 19854)
@@ -56,7 +56,7 @@
private Object nodeData;
- private Collection<Object> selection;
+ private Collection<Object> selection = new TracingSet<Object>();
@PostConstruct
public void init() {
Modified: trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-01 16:23:04 UTC (rev 19853)
+++ trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-01 16:42:07 UTC (rev 19854)
@@ -24,7 +24,8 @@
</h:form>
<h:form id="form">
- <it:tree id="tree" nodeType="#{node.parent == null ? 'rootNode': 'childNode'}" var="node" value="#{treeBean.rootNodes}" selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
+ <it:tree id="tree" nodeType="#{node.parent == null ? 'rootNode': 'childNode'}" var="node" value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}" selection="#{treeBean.selection}">
<it:treeNode type="rootNode">
<h:panelGroup id="rootNodeGroup">
Root node: #{node.data} -
Modified: trunk/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java
===================================================================
--- trunk/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java 2010-11-01 16:23:04 UTC (rev 19853)
+++ trunk/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java 2010-11-01 16:42:07 UTC (rev 19854)
@@ -22,7 +22,6 @@
package org.richfaces.event;
import java.util.Collection;
-import java.util.HashSet;
import javax.faces.component.UIComponent;
import javax.faces.event.FacesEvent;
@@ -36,15 +35,15 @@
private static final long serialVersionUID = 6292604445872458007L;
- private Collection<Object> addedKeys = new HashSet<Object>();
+ private Collection<Object> oldSelection;
- private Collection<Object> removedKeys = new HashSet<Object>();
+ private Collection<Object> newSelection;
- public TreeSelectionEvent(UIComponent component, Collection<Object> addedKeys, Collection<Object> removedKeys) {
+ public TreeSelectionEvent(UIComponent component, Collection<Object> oldSelection, Collection<Object> newSelection) {
super(component);
-
- this.addedKeys = addedKeys;
- this.removedKeys = removedKeys;
+
+ this.oldSelection = oldSelection;
+ this.newSelection = newSelection;
}
@Override
@@ -57,11 +56,12 @@
((TreeSelectionListener) listener).processSelection(this);
}
- public Collection<Object> getAddedKeys() {
- return addedKeys;
+ public Collection<Object> getOldSelection() {
+ return oldSelection;
}
- public Collection<Object> getRemovedKeys() {
- return removedKeys;
+ public Collection<Object> getNewSelection() {
+ return newSelection;
}
+
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01 16:23:04 UTC (rev 19853)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01 16:42:07 UTC (rev 19854)
@@ -66,6 +66,7 @@
import org.richfaces.renderkit.MetaComponentRenderer;
import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
/**
@@ -313,14 +314,18 @@
} else if (event instanceof TreeSelectionEvent) {
TreeSelectionEvent selectionEvent = (TreeSelectionEvent) event;
- Collection<Object> selection = getSelection();
+ final Collection<Object> newSelection = selectionEvent.getNewSelection();
+
+ Collection<Object> selectionCollection = getSelection();
- for (Object addedKey: selectionEvent.getAddedKeys()) {
- selection.add(addedKey);
- }
+ Iterables.removeIf(selectionCollection, new Predicate<Object>() {
+ public boolean apply(Object input) {
+ return !newSelection.contains(input);
+ };
+ });
- for (Object removedKey: selectionEvent.getRemovedKeys()) {
- selection.remove(removedKey);
+ if (!newSelection.isEmpty()) {
+ Iterables.addAll(selectionCollection, newSelection);
}
}
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-11-01 16:23:04 UTC (rev 19853)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-11-01 16:42:07 UTC (rev 19854)
@@ -74,4 +74,9 @@
}
return true;
}
+
+ @Override
+ public String toString() {
+ return getClass().getName() + Arrays.toString(simpleKeys);
+ }
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-01 16:23:04 UTC (rev 19853)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-01 16:42:07 UTC (rev 19854)
@@ -29,10 +29,9 @@
import java.io.IOException;
import java.util.Collection;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import javax.faces.component.UIComponent;
import javax.faces.component.UINamingContainer;
@@ -54,6 +53,7 @@
import org.richfaces.log.RichfacesLogger;
import com.google.common.base.Strings;
+import com.google.common.collect.Sets;
/**
@@ -304,18 +304,20 @@
Collection<Object> selection = tree.getSelection();
- Set<Object> addedKeys = new HashSet<Object>(2);
- Set<Object> removedKeys = new HashSet<Object>(2);
-
+ Collection<Object> newSelection = null;
+
if (selectionRowKey == null) {
- removedKeys.addAll(selection);
- } else if (!selection.contains(selectionRowKey)) {
- addedKeys.add(selectionRowKey);
- removedKeys.addAll(selection);
+ if (!selection.isEmpty()) {
+ newSelection = Collections.emptySet();
+ }
+ } else {
+ if (!selection.contains(selectionRowKey)) {
+ newSelection = Collections.singleton(selectionRowKey);
+ }
}
-
- if (!removedKeys.isEmpty() || !addedKeys.isEmpty()) {
- new TreeSelectionEvent(component, addedKeys, removedKeys).queue();
+
+ if (newSelection != null) {
+ new TreeSelectionEvent(component, Sets.newHashSet(selection), newSelection).queue();
}
PartialViewContext pvc = context.getPartialViewContext();
13 years, 6 months
JBoss Rich Faces SVN: r19853 - in trunk/examples/input-demo/src/main: webapp/examples and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-11-01 12:23:04 -0400 (Mon, 01 Nov 2010)
New Revision: 19853
Added:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
Modified:
trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
Log:
extend calendar demo
Added: trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java (rev 0)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-01 16:23:04 UTC (rev 19853)
@@ -0,0 +1,86 @@
+package org.richfaces.demo;
+
+import java.util.Date;
+import java.util.Locale;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.event.ValueChangeEvent;
+
+@ManagedBean
+@RequestScoped
+public class CalendarBean {
+
+ private Locale locale;
+ private boolean popup;
+ private String pattern;
+ private Date selectedDate;
+ private boolean showApply = true;
+ private boolean useCustomDayLabels;
+
+ public CalendarBean() {
+
+ locale = Locale.US;
+ popup = true;
+ pattern = "d/M/yy HH:mm";
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ public boolean isPopup() {
+ return popup;
+ }
+
+ public void setPopup(boolean popup) {
+ this.popup = popup;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public void setPattern(String pattern) {
+ this.pattern = pattern;
+ }
+
+ public void selectLocale(ValueChangeEvent event) {
+
+ String tLocale = (String) event.getNewValue();
+ if (tLocale != null) {
+ String lang = tLocale.substring(0, 2);
+ String country = tLocale.substring(3);
+ locale = new Locale(lang, country, "");
+ }
+ }
+
+ public boolean isUseCustomDayLabels() {
+ return useCustomDayLabels;
+ }
+
+ public void setUseCustomDayLabels(boolean useCustomDayLabels) {
+ this.useCustomDayLabels = useCustomDayLabels;
+ }
+
+ public Date getSelectedDate() {
+ return selectedDate;
+ }
+
+ public void setSelectedDate(Date selectedDate) {
+ this.selectedDate = selectedDate;
+ }
+
+ public boolean isShowApply() {
+ return showApply;
+ }
+
+ public void setShowApply(boolean showApply) {
+ this.showApply = showApply;
+ }
+
+}
\ No newline at end of file
Modified: trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-01 16:20:40 UTC (rev 19852)
+++ trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-01 16:23:04 UTC (rev 19853)
@@ -29,13 +29,52 @@
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
- <h:head>
- <title>Richfaces Calendar Demo</title>
- </h:head>
- <h:body>
- <h:form id="form">
- <calendar:calendar popup="true"/>
- <h:commandButton value="submit"></h:commandButton>
- </h:form>
- </h:body>
+<h:head>
+ <title>Richfaces Calendar Demo</title>
+</h:head>
+<h:body>
+ <h:form id="form">
+ <h:panelGrid id="panel" columns="2">
+ <h:panelGroup layout="block">
+ <calendar:calendar value="#{calendarBean.selectedDate}" id="calendar"
+ locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
+ datePattern="#{calendarBean.pattern}"
+ showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
+ cellHeight="22px" style="width:200px">
+ <f:convertDateTime pattern="#{calendarBean.pattern}"
+ onchange="alert('1')" />
+ </calendar:calendar>
+ </h:panelGroup>
+ <h:panelGrid columns="2">
+ <h:outputText value="Popup Mode:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.popup}">
+ <f:ajax event="click" execute="@form" render="calendar @this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Apply Button:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.showApply}">
+ <f:ajax event="click" execute="@form" render="calendar @this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Select Locale" />
+ <h:selectOneRadio value="en/US"
+ valueChangeListener="#{calendarBean.selectLocale}">
+ <f:ajax execute="@form" event="click" render="calendar @this" />
+ <f:selectItem itemLabel="US" itemValue="en/US" />
+ <f:selectItem itemLabel="DE" itemValue="de/DE" />
+ <f:selectItem itemLabel="FR" itemValue="fr/FR" />
+ <f:selectItem itemLabel="RU" itemValue="ru/RU" />
+ </h:selectOneRadio>
+
+ <h:outputText value="Select Date Pattern:" />
+ <h:selectOneMenu value="#{calendarBean.pattern}">
+ <f:ajax execute="@form" event="change" render="calendar @this" />
+ <f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy HH:mm" />
+ <f:selectItem itemLabel="dd/M/yy hh:mm a"
+ itemValue="dd/M/yy hh:mm a" />
+ <f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
+ <f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy" />
+ </h:selectOneMenu>
+ </h:panelGrid>
+ </h:panelGrid>
+ </h:form>
+</h:body>
</html>
13 years, 6 months
JBoss Rich Faces SVN: r19852 - trunk/ui/input/ui/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-11-01 12:20:40 -0400 (Mon, 01 Nov 2010)
New Revision: 19852
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
Log:
RF-9603
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-01 15:51:49 UTC (rev 19851)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-01 16:20:40 UTC (rev 19852)
@@ -572,7 +572,7 @@
public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext, UIComponent component) throws IOException {
if(component instanceof AbstractCalendar) {
AbstractCalendar calendar = (AbstractCalendar)component;
- JSFunction function = new JSFunction("RichFaces.ui.Calendar.addLocale", CalendarHelper.getAsLocale(facesContext, calendar), getLocaleOptions(facesContext, calendar));
+ JSFunction function = new JSFunction("RichFaces.ui.Calendar.addLocale", CalendarHelper.getAsLocale(facesContext, calendar).toString(), getLocaleOptions(facesContext, calendar));
writer.write(function.toScript());
writer.write(";");
}
@@ -582,7 +582,7 @@
if(component instanceof AbstractCalendar) {
AbstractCalendar calendar = (AbstractCalendar)component;
ScriptOptions scriptOptions = createCalendarScriptOption(facesContext, calendar);
- JSFunction function = new JSFunction("new RichFaces.ui.Calendar", calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar), scriptOptions, "");
+ JSFunction function = new JSFunction("new RichFaces.ui.Calendar", calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar).toString(), scriptOptions, "");
StringBuffer scriptBuffer = new StringBuffer();
scriptBuffer.append(function.toScript()).append(".load();");
writer.write(scriptBuffer.toString());
13 years, 6 months
JBoss Rich Faces SVN: r19851 - trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 11:51:49 -0400 (Mon, 01 Nov 2010)
New Revision: 19851
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/popupPanel.ecss
Log:
Fixed broken popupPanel.ecss
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/popupPanel.ecss
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/popupPanel.ecss 2010-11-01 15:51:02 UTC (rev 19850)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/popupPanel.ecss 2010-11-01 15:51:49 UTC (rev 19851)
@@ -8,7 +8,7 @@
top: 0px;
z-index: -300;
opacity: 0.1;
- filter: 'alpha(opacity = 10)';
+ filter: 'alpha(opacity \5C 3D 10)';
}
.rf-pp-shade {
@@ -19,13 +19,13 @@
left: 0px;
background-color: #D0D0D0;
opacity: 0.5;
- filter: 'alpha(opacity = 50)';
+ filter: 'alpha(opacity \5C 3D 50)';
}
.rf-pp-shdw {
background-color: #000000;
opacity: 0.1;
- filter: 'alpha(opacity = 10)';
+ filter: 'alpha(opacity \5C 3D 10)';
}
.rf-pp-cntr {
@@ -82,7 +82,7 @@
opacity:0;
position : absolute;
margin : -4px;
- filter : 'alpha(opacity = 0)';
+ filter : 'alpha(opacity \5C 3D 0)';
}
.rf-pp-hndlr-l {
13 years, 6 months