Author: alexsmirnov
Date: 2010-11-18 18:14:43 -0500 (Thu, 18 Nov 2010)
New Revision: 20108
Added:
branches/RF-8742-1/.gitignore
branches/RF-8742-1/core/api/src/main/java/org/richfaces/component/ComponentPredicates.java
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java
branches/RF-8742-1/examples/iteration-demo/src/main/java/org/richfaces/demo/LazyTreeNode.java
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/leaf.png
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/minus.png
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/plus.png
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeEvent.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeListener.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeSource.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeToggleSource.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java
branches/RF-8742-1/ui/iteration/ui/src/main/config/
branches/RF-8742-1/ui/iteration/ui/src/main/config/faces-config.xml
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeSelectionChangeListener.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeToggleListener.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeState.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeHandler.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeNodeHandler.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeSelectionChangeListenerExpressionMetadata.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeToggleListenerExpressionMetadata.java
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java
Removed:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/StringBuilderWriter.java
branches/RF-8742-1/core/api/src/test/java/org/ajax4jsf/javascript/StringBuilderWriterTest.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/component/util/ViewUtil.java
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/leaf.png
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/minus.png
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/plus.png
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionListener.java
branches/RF-8742-1/ui/iteration/ui/src/main/config/faces-config.xml
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeHandler.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeNodeHandler.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeSelectionChangeListenerExpressionMetadata.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeToggleListenerExpressionMetadata.java
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java
Modified:
branches/RF-8742-1/
branches/RF-8742-1/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java
branches/RF-8742-1/cdk/generator/src/main/resources/META-INF/templates/listenerTagHandler.ftl
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSBind.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSFunction.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptString.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptStringBase.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java
branches/RF-8742-1/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java
branches/RF-8742-1/core/impl/src/main/resources/META-INF/resources/jquery.position.js
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml
branches/RF-8742-1/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/WEB-INF/web.xml
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/tree.xhtml
branches/RF-8742-1/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
branches/RF-8742-1/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java
branches/RF-8742-1/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/ClientSelectItem.java
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeToggleListener.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/TreeRange.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKeyIterator.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
branches/RF-8742-1/ui/iteration/ui/src/main/templates/tree.template.xml
branches/RF-8742-1/ui/iteration/ui/src/main/templates/treeNode.template.xml
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
Log:
Merged revisions 20079-20080,20083-20084,20088-20107 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r20079 | amarkhel | 2010-11-17 08:53:40 -0800 (Wed, 17 Nov 2010) | 1 line
RF-9683 Calendar component: data model support, RF-9684 Calendar component: AJAX
scrolling
.......
r20080 | amarkhel | 2010-11-17 08:58:18 -0800 (Wed, 17 Nov 2010) | 1 line
RF-9683 Calendar component: data model support, RF-9684 Calendar component: AJAX
scrolling. Demo is updated.
.......
r20083 | pyaschenko | 2010-11-18 00:29:52 -0800 (Thu, 18 Nov 2010) | 2 lines
https://jira.jboss.org/browse/RF-9650
https://jira.jboss.org/browse/RF-9644
.......
r20084 | pyaschenko | 2010-11-18 00:34:56 -0800 (Thu, 18 Nov 2010) | 2 lines
http://jira.jboss.com/jira/browse/RF-9672
.......
r20088 | nbelaevski | 2010-11-18 08:02:06 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9715
.......
r20089 | nbelaevski | 2010-11-18 08:03:02 -0800 (Thu, 18 Nov 2010) | 1 line
added
.......
r20090 | nbelaevski | 2010-11-18 08:05:30 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9715
.......
r20091 | nbelaevski | 2010-11-18 08:10:17 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9715
.......
r20092 | nbelaevski | 2010-11-18 08:15:48 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9716
.......
r20093 | nbelaevski | 2010-11-18 08:17:55 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9715
.......
r20094 | nbelaevski | 2010-11-18 08:20:00 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9715
.......
r20095 | nbelaevski | 2010-11-18 08:21:47 -0800 (Thu, 18 Nov 2010) | 1 line
Checkstyle error fixed
.......
r20096 | nbelaevski | 2010-11-18 08:24:23 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9715
.......
r20097 | nbelaevski | 2010-11-18 08:26:56 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9715
.......
r20098 | nbelaevski | 2010-11-18 08:28:44 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9716
.......
r20099 | nbelaevski | 2010-11-18 08:31:41 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9715
.......
r20100 | nbelaevski | 2010-11-18 08:33:28 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9715
.......
r20101 | nbelaevski | 2010-11-18 08:35:18 -0800 (Thu, 18 Nov 2010) | 1 line
Checkstyle error fixed
.......
r20102 | nbelaevski | 2010-11-18 08:37:36 -0800 (Thu, 18 Nov 2010) | 1 line
RF-9714
.......
r20103 | nbelaevski | 2010-11-18 08:54:07 -0800 (Thu, 18 Nov 2010) | 1 line
RF-9714
.......
r20104 | nbelaevski | 2010-11-18 08:56:05 -0800 (Thu, 18 Nov 2010) | 1 line
svn rebase...
.......
r20105 | nbelaevski | 2010-11-18 09:01:46 -0800 (Thu, 18 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9714
.......
r20106 | nbelaevski | 2010-11-18 09:10:13 -0800 (Thu, 18 Nov 2010) | 2 lines
https://jira.jboss.org/browse/RF-9714
https://jira.jboss.org/browse/RF-9717
.......
r20107 | nbelaevski | 2010-11-18 10:50:06 -0800 (Thu, 18 Nov 2010) | 1 line
Rest of tree work merged manually from GIT
.......
Property changes on: branches/RF-8742-1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-20077
+ /trunk:1-20107
Copied: branches/RF-8742-1/.gitignore (from rev 20107, trunk/.gitignore)
===================================================================
--- branches/RF-8742-1/.gitignore (rev 0)
+++ branches/RF-8742-1/.gitignore 2010-11-18 23:14:43 UTC (rev 20108)
@@ -0,0 +1,8 @@
+target
+.settings
+.project
+.classpath
+.clover
+.externalToolBuilders
+
+
Modified:
branches/RF-8742-1/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java
===================================================================
---
branches/RF-8742-1/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -48,6 +48,7 @@
private ClassName sourceInterface;
private ClassName type;
private List<TagModel> tags = Lists.newArrayList();
+ private String listenerMethod;
/**
* <p class="changed_added_4_0"></p>
@@ -165,4 +166,19 @@
public void setTags(List<TagModel> tags) {
this.tags = tags;
}
+
+ /**
+ * @return the listenerMethod
+ */
+ @XmlElement(name = "listener-method", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public String getListenerMethod() {
+ return listenerMethod;
+ }
+
+ /**
+ * @param listenerMethod the listenerMethod to set
+ */
+ public void setListenerMethod(String listenerMethod) {
+ this.listenerMethod = listenerMethod;
+ }
}
Modified:
branches/RF-8742-1/cdk/generator/src/main/resources/META-INF/templates/listenerTagHandler.ftl
===================================================================
---
branches/RF-8742-1/cdk/generator/src/main/resources/META-INF/templates/listenerTagHandler.ftl 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/cdk/generator/src/main/resources/META-INF/templates/listenerTagHandler.ftl 2010-11-18
23:14:43 UTC (rev 20108)
@@ -98,7 +98,7 @@
private TagAttribute listenerMethod;
- public TestListenerHandler(TagConfig config) {
+ public ${tag.targetClass.simpleName}(TagConfig config) {
super(config);
this.binding = this.getAttribute("binding");
Modified: branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSBind.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSBind.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSBind.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,6 +23,8 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
/**
* Created 04.08.2008
* @author Nick Belaevski
@@ -38,9 +40,9 @@
this.vars = vars;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append("function () {");
- functionString.append("var vars = {");
+ public void appendScript(Appendable target) throws IOException {
+ target.append("function () {");
+ target.append("var vars = {");
boolean isFirst = true;
@@ -48,17 +50,18 @@
if (isFirst) {
isFirst = false;
} else {
- functionString.append(',');
+ target.append(',');
}
- functionString.append(var);
- functionString.append(':');
- functionString.append(var);
+ target.append(var);
+ target.append(':');
+ target.append(var);
}
- functionString.append("};");
- functionString.append("return function() { with (vars) {");
- functionString.append(function.toScript());
- functionString.append("}}}()");
+ target.append("};");
+ target.append("return function() { with (vars) {");
+ target.append(function.toScript());
+ target.append("}}}()");
}
+
}
Modified:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSFunction.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSFunction.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSFunction.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,6 +23,7 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -52,8 +53,8 @@
return this;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(name).append('(');
+ public void appendScript(Appendable target) throws IOException {
+ target.append(name).append('(');
boolean first = true;
List<?> parameters = getParameters();
@@ -63,26 +64,27 @@
Object element = param.next();
if (!first) {
- functionString.append(',');
+ target.append(',');
}
if (null != element) {
- functionString.append(ScriptUtils.toScript(element));
+ ScriptUtils.appendScript(target, element);
} else {
- functionString.append("null");
+ target.append("null");
}
first = false;
}
}
- functionString.append(")");
+ target.append(")");
}
-
+
/**
* @return the parameters
*/
public List<Object> getParameters() {
return this.parameters;
}
+
}
Modified:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,6 +23,7 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -56,18 +57,14 @@
return this;
}
- /*
- * (non-Javadoc)
- * @see
org.ajax4jsf.components.renderkit.scriptutils.ScriptString#appendScript(java.lang.StringBuffer)
- */
- public void appendScript(StringBuffer functionString) {
- functionString.append("function");
+ public void appendScript(Appendable target) throws IOException {
+ target.append("function");
if (null != name) {
- functionString.append(" ").append(name);
+ target.append(" ").append(name);
}
- functionString.append("(");
+ target.append("(");
boolean first = true;
@@ -75,16 +72,16 @@
Object element = param.next();
if (!first) {
- functionString.append(',');
+ target.append(',');
}
- functionString.append(element.toString());
+ target.append(element.toString());
first = false;
}
- functionString.append("){").append(body).append("}");
+ target.append("){").append(body).append("}");
}
-
+
/**
* @return the name
*/
@@ -98,4 +95,5 @@
public void setName(String name) {
this.name = name;
}
+
}
Modified:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,6 +23,7 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
import java.io.Serializable;
/**
@@ -53,14 +54,10 @@
this.literal = literal;
}
- /*
- * (non-Javadoc)
- * @see org.ajax4jsf.javascript.ScriptString#appendScript(java.lang.StringBuffer)
- */
- public void appendScript(StringBuffer jsString) {
- jsString.append(literal);
+ public void appendScript(Appendable target) throws IOException {
+ target.append(literal);
}
-
+
/**
* @return the literal
*/
Modified: branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,6 +23,8 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:30 $
@@ -40,8 +42,8 @@
// TODO Auto-generated constructor stub
}
- public void appendScript(StringBuffer functionString) {
- functionString.append("new ");
- super.appendScript(functionString);
+ public void appendScript(Appendable target) throws IOException {
+ target.append("new ");
+ super.appendScript(target);
}
}
Modified:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,6 +23,8 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
/**
* Create reference to JavaScript variable with optional index.
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
@@ -58,15 +60,14 @@
this.index = index;
}
- /*
- * (non-Javadoc)
- * @see org.ajax4jsf.javascript.ScriptString#appendScript(java.lang.StringBuffer)
- */
- public void appendScript(StringBuffer functionString) {
- functionString.append(name);
+ public void appendScript(Appendable target) throws IOException {
+ target.append(name);
if (null != index) {
-
functionString.append("[").append(ScriptUtils.toScript(index)).append("]");
+ target.append("[");
+ ScriptUtils.appendScript(target, index);
+ target.append("]");
}
}
+
}
Modified:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptString.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptString.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptString.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,6 +23,9 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
+
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:32 $
@@ -37,8 +40,15 @@
public abstract String toScript();
/**
- * Append JavaScript code to @link StringBuffer
- * @param functionString
+ * Append JavaScript code to @link {@link Appendable}
+ * @param target
+ * @throws IOException
*/
- public void appendScript(StringBuffer functionString);
+ public void appendScript(Appendable target) throws IOException;
+
+ /**
+ * Append JavaScript code to @link {@link StringBuilder}
+ * @param stringBuilder
+ */
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder);
}
Modified:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptStringBase.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptStringBase.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptStringBase.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,6 +23,11 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
+import javax.faces.FacesException;
+
+
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.2 $ $Date: 2007/01/26 10:38:52 $
@@ -30,13 +35,24 @@
*/
public abstract class ScriptStringBase implements ScriptString {
public String toScript() {
- StringBuffer functionString = new StringBuffer();
+ StringBuilder builder = new StringBuilder();
- appendScript(functionString);
+ try {
+ appendScript(builder);
+ return builder.toString();
+ } catch (IOException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
- return functionString.toString();
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
}
-
+
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
@@ -44,4 +60,5 @@
public String toString() {
return toScript();
}
+
}
Modified:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -26,8 +26,8 @@
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.io.Writer;
import java.lang.reflect.Array;
+import java.nio.CharBuffer;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
@@ -66,7 +66,7 @@
return cs;
}
- private static void writeScriptToStream(Writer writer, Object obj, Map<Object,
Boolean> cycleBusterMap) throws IOException {
+ private static void appendScript(Appendable appendable, Object obj, Map<Object,
Boolean> cycleBusterMap) throws IOException {
Boolean cycleBusterValue = cycleBusterMap.put(obj, Boolean.TRUE);
if (cycleBusterValue != null) {
@@ -81,14 +81,14 @@
LOG.debug(formattedMessage);
}
- writer.write("null");
+ appendable.append("null");
} else if (null == obj) {
//TODO nick - skip non-rendered values like Integer.MIN_VALUE
- writer.write("null");
+ appendable.append("null");
} else if (obj instanceof ScriptString) {
- writer.write(((ScriptString) obj).toScript());
+ ((ScriptString) obj).appendScript(appendable);
} else if (obj.getClass().isArray()) {
- writer.write("[");
+ appendable.append("[");
boolean first = true;
@@ -96,20 +96,20 @@
Object element = Array.get(obj, i);
if (!first) {
- writer.write(',');
+ appendable.append(',');
}
- writeScriptToStream(writer, element, cycleBusterMap);
+ appendScript(appendable, element, cycleBusterMap);
first = false;
}
- writer.write("] ");
+ appendable.append("] ");
} else if (obj instanceof Collection<?>) {
// Collections put as JavaScript array.
@SuppressWarnings("unchecked") Collection<Object> collection
= (Collection<Object>) obj;
- writer.write("[");
+ appendable.append("[");
boolean first = true;
@@ -117,51 +117,51 @@
Object element = iter.next();
if (!first) {
- writer.write(',');
+ appendable.append(',');
}
- writeScriptToStream(writer, element, cycleBusterMap);
+ appendScript(appendable, element, cycleBusterMap);
first = false;
}
- writer.write("] ");
+ appendable.append("] ");
} else if (obj instanceof Map<?, ?>) {
// Maps put as JavaScript hash.
@SuppressWarnings("unchecked") Map<Object, Object> map =
(Map<Object, Object>) obj;
- writer.write("{");
+ appendable.append("{");
boolean first = true;
for (Map.Entry<Object, Object> entry : map.entrySet()) {
if (!first) {
- writer.write(',');
+ appendable.append(',');
}
- writeEncodedString(writer, entry.getKey());
- writer.write(":");
- writeScriptToStream(writer, entry.getValue(), cycleBusterMap);
+ appendEncodedString(appendable, entry.getKey());
+ appendable.append(":");
+ appendScript(appendable, entry.getValue(), cycleBusterMap);
first = false;
}
- writer.write("} ");
+ appendable.append("} ");
} else if (obj instanceof Number || obj instanceof Boolean) {
// numbers and boolean put as-is, without conversion
- writer.write(obj.toString());
+ appendable.append(obj.toString());
} else if (obj instanceof String) {
// all other put as encoded strings.
- writeEncodedString(writer, obj);
+ appendEncodedString(appendable, obj);
} else if (obj instanceof Enum<?>) {
// all other put as encoded strings.
- writeEncodedString(writer, obj);
+ appendEncodedString(appendable, obj);
} else {
// All other objects threaded as Java Beans.
- writer.write("{");
+ appendable.append("{");
PropertyDescriptor[] propertyDescriptors;
@@ -194,16 +194,16 @@
}
if (!first) {
- writer.write(',');
+ appendable.append(',');
}
- writeEncodedString(writer, key);
- writer.write(":");
- writeScriptToStream(writer, propertyValue, cycleBusterMap);
+ appendEncodedString(appendable, key);
+ appendable.append(":");
+ appendScript(appendable, propertyValue, cycleBusterMap);
first = false;
}
- writer.write("} ");
+ appendable.append("} ");
}
if (cycleBusterValue == null) {
@@ -220,7 +220,7 @@
* @throws IOException
*/
public static void writeToStream(final ResponseWriter responseWriter, Object obj)
throws IOException {
- writeScriptToStream(new ResponseWriterWrapper(responseWriter), obj, new
IdentityHashMap<Object, Boolean>());
+ appendScript(new ResponseWriterWrapper(responseWriter), obj, new
IdentityHashMap<Object, Boolean>());
}
/**
@@ -233,7 +233,7 @@
StringBuilder sb = new StringBuilder();
try {
- writeScriptToStream(new StringBuilderWriter(sb), obj, new
IdentityHashMap<Object, Boolean>());
+ appendScript(sb, obj, new IdentityHashMap<Object, Boolean>());
} catch (IOException e) {
// ignore
@@ -242,22 +242,17 @@
return sb.toString();
}
- public static void writeEncodedString(Writer w, Object obj) throws IOException {
- w.write("\"");
- writeEncoded(w, obj);
- w.write("\"");
+ public static void appendScript(Appendable appendable, Object obj) throws IOException
{
+ appendScript(appendable, obj, new IdentityHashMap<Object, Boolean>());
}
-
- public static void addEncodedString(StringBuilder buff, Object obj) {
- try {
- writeEncodedString(new StringBuilderWriter(buff), obj);
- } catch (IOException e) {
-
- // ignore
- }
+
+ public static void appendEncodedString(Appendable appendable, Object obj) throws
IOException {
+ appendable.append("\"");
+ appendEncoded(appendable, obj);
+ appendable.append("\"");
}
- public static void writeEncoded(Writer w, Object obj) throws IOException {
+ public static void appendEncoded(Appendable appendable, Object obj) throws
IOException {
JSEncoder encoder = new JSEncoder();
char[] chars = obj.toString().toCharArray();
@@ -265,22 +260,13 @@
char c = chars[i];
if (!encoder.compile(c)) {
- w.write(encoder.encode(c));
+ appendable.append(CharBuffer.wrap(encoder.encode(c)));
} else {
- w.write(c);
+ appendable.append(c);
}
}
}
- public static void addEncoded(StringBuilder buff, Object obj) {
- try {
- writeEncoded(new StringBuilderWriter(buff), obj);
- } catch (IOException e) {
-
- // ignore
- }
- }
-
public static String getValidJavascriptName(String s) {
StringBuffer buf = null;
final int len = s.length();
Deleted:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/StringBuilderWriter.java
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/StringBuilderWriter.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/StringBuilderWriter.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,88 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.javascript;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.2
- */
-final class StringBuilderWriter extends Writer {
- private StringBuilder builder;
-
- public StringBuilderWriter(StringBuilder builder) {
- super();
- this.builder = builder;
- }
-
- /**
- * Closing this writer doesn't have any effect
- */
- @Override
- public void close() throws IOException {
-
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.Writer#flush()
- */
- @Override
- public void flush() throws IOException {
-
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.Writer#write(char[], int, int)
- */
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- builder.append(cbuf, off, len);
- }
-
- @Override
- public void write(char[] cbuf) throws IOException {
- builder.append(cbuf);
- }
-
- @Override
- public void write(String str) throws IOException {
- builder.append(str);
- }
-
- @Override
- public void write(String str, int off, int len) throws IOException {
- builder.append(str, off, off + len);
- }
-
- @Override
- public void write(int c) throws IOException {
- builder.append((char) c);
- }
-}
Copied:
branches/RF-8742-1/core/api/src/main/java/org/richfaces/component/ComponentPredicates.java
(from rev 20107,
trunk/core/api/src/main/java/org/richfaces/component/ComponentPredicates.java)
===================================================================
---
branches/RF-8742-1/core/api/src/main/java/org/richfaces/component/ComponentPredicates.java
(rev 0)
+++
branches/RF-8742-1/core/api/src/main/java/org/richfaces/component/ComponentPredicates.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,45 @@
+/*
+ * 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.component;
+
+import javax.faces.component.UIComponent;
+
+import com.google.common.base.Predicate;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class ComponentPredicates {
+
+ private static final Predicate<UIComponent> IS_RENDERED = new
Predicate<UIComponent>() {
+ public boolean apply(UIComponent input) {
+ return input.isRendered();
+ };
+ };
+
+ private ComponentPredicates() {}
+
+ public static Predicate<UIComponent> isRendered() {
+ return IS_RENDERED;
+ }
+}
Modified:
branches/RF-8742-1/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java
===================================================================
---
branches/RF-8742-1/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -246,21 +246,23 @@
/**
* Test method for {@link
org.ajax4jsf.javascript.ScriptUtils#addEncodedString(java.lang.StringBuffer,
java.lang.Object)}.
+ * @throws Exception
*/
- public void testAddEncodedString() {
+ public void testAddEncodedString() throws Exception {
StringBuilder buff = new StringBuilder();
- ScriptUtils.addEncodedString(buff, "foo");
+ ScriptUtils.appendEncodedString(buff, "foo");
assertEquals("\"foo\"", buff.toString());
}
/**
* Test method for {@link
org.ajax4jsf.javascript.ScriptUtils#addEncoded(java.lang.StringBuffer,
java.lang.Object)}.
+ * @throws Exception
*/
- public void testAddEncoded() {
+ public void testAddEncoded() throws Exception {
StringBuilder buff = new StringBuilder();
- ScriptUtils.addEncoded(buff, "foo");
+ ScriptUtils.appendEncoded(buff, "foo");
assertEquals("foo", buff.toString());
}
Deleted:
branches/RF-8742-1/core/api/src/test/java/org/ajax4jsf/javascript/StringBuilderWriterTest.java
===================================================================
---
branches/RF-8742-1/core/api/src/test/java/org/ajax4jsf/javascript/StringBuilderWriterTest.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/api/src/test/java/org/ajax4jsf/javascript/StringBuilderWriterTest.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,96 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.javascript;
-
-import java.io.Writer;
-
-import junit.framework.TestCase;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.2
- */
-public class StringBuilderWriterTest extends TestCase {
- private StringBuilder builder;
- private Writer writer;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.builder = new StringBuilder();
- this.writer = new StringBuilderWriter(this.builder);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- this.builder = null;
- this.writer = null;
- }
-
- public void testWrite() throws Exception {
- writer.write(new char[] {'a', 'b'});
- assertEquals("ab", builder.toString());
- }
-
- public void testWrite2() throws Exception {
- writer.write(0x12345678);
-
- String s = builder.toString();
-
- assertEquals(1, s.length());
- assertEquals(0x5678, s.charAt(0));
- }
-
- public void testWrite3() throws Exception {
- writer.write("test");
- assertEquals("test", builder.toString());
- }
-
- public void testWrite4() throws Exception {
- writer.write("abcd".toCharArray(), 1, 2);
- assertEquals("bc", builder.toString());
- writer.write("efgh".toCharArray(), 0, 3);
- assertEquals("bcefg", builder.toString());
- writer.write("ijkl".toCharArray(), 2, 2);
- assertEquals("bcefgkl", builder.toString());
- }
-
- public void testWrite5() throws Exception {
- writer.write("abcd", 1, 2);
- assertEquals("bc", builder.toString());
- writer.write("efgh", 0, 3);
- assertEquals("bcefg", builder.toString());
- writer.write("ijklm", 2, 3);
- assertEquals("bcefgklm", builder.toString());
- }
-
- public void testFlush() throws Exception {
- writer.flush();
- }
-
- public void testClose() throws Exception {
- writer.close();
- }
-}
Modified:
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java
===================================================================
---
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -70,17 +70,31 @@
}
public String toScript() {
+ Map<String, Object> map = createScriptMap();
+
+ return ScriptUtils.toScript(map);
+ }
+
+ private Map<String, Object> createScriptMap() {
Map<String,Object> map = new HashMap<String, Object>(2);
map.put(TOPIC_KEY, topicKey.getTopicAddress());
map.put(DATA_KEY, new JSLiteral(serializedData));
-
- return ScriptUtils.toScript(map);
+ return map;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(toScript());
+ public void appendScript(Appendable target) throws IOException {
+ target.append(toScript());
}
+
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+
}
private static final class FlushMessagesTask implements Runnable {
Deleted:
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/component/util/ViewUtil.java
===================================================================
---
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/component/util/ViewUtil.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/component/util/ViewUtil.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.util;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 19.02.2007
- */
-public final class ViewUtil {
- private ViewUtil() {
- }
-
- public static String getResourceURL(String url) {
- if (null == url) {
- return null;
- }
-
- return ViewUtil.getResourceURL(url, FacesContext.getCurrentInstance());
- }
-
- public static String getResourceURL(String url, FacesContext context) {
- if (null == url) {
- return null;
- }
-
- String value = url;
-
- value = context.getApplication().getViewHandler().getResourceURL(context,
value);
-
- return context.getExternalContext().encodeResourceURL(value);
- }
-}
Modified:
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java
===================================================================
---
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -21,16 +21,18 @@
package org.richfaces.renderkit;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.ScriptStringBase;
-import org.ajax4jsf.javascript.ScriptUtils;
-
-import javax.faces.component.UIComponent;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.ScriptStringBase;
+import org.ajax4jsf.javascript.ScriptUtils;
+
/**
* @author Maksim Kaszynski
*/
@@ -42,8 +44,8 @@
this.component = component;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(ScriptUtils.toScript(opts));
+ public void appendScript(Appendable target) throws IOException {
+ ScriptUtils.appendScript(target, opts);
}
public void addOption(String name) {
Modified:
branches/RF-8742-1/core/impl/src/main/resources/META-INF/resources/jquery.position.js
===================================================================
---
branches/RF-8742-1/core/impl/src/main/resources/META-INF/resources/jquery.position.js 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/core/impl/src/main/resources/META-INF/resources/jquery.position.js 2010-11-18
23:14:43 UTC (rev 20108)
@@ -5,7 +5,7 @@
*/
// draft examples of usage
-// jQuery('#tooltip').setPosition('#aaa',{from:'LB',
to:'AA'});
+// jQuery('#tooltip').setPosition('#aaa',{from:'bottom-left',
to:'auto-auto'});
//
jQuery('#bbb').bind("click",function(e){jQuery('#tooltip').setPosition(e);});
// TODO: clear code
// TODO: optimization
@@ -81,6 +81,14 @@
var def = params.type || params.from || params.to ? $.PositionTypes[params.type ||
defaultType] : {noPositionType:true};
var options = $.extend({}, defaults, def, params);
+ if (!options.noPositionType) {
+ if (options.from.length>2) {
+ options.from = positionDefinition[options.from.toLowerCase()];
+ }
+ if (options.to.length>2) {
+ options.to = positionDefinition[options.to.toLowerCase()];
+ }
+ }
return this.each(function() {
element = $(this);
//alert(rect.left+" "+rect.top+" "+rect.width+"
"+rect.height);
@@ -98,6 +106,17 @@
var re = /^(left|right)-(top|buttom|auto)$/i;
// TODO: make it private
+ var positionDefinition = {
+ 'top-left':'LT',
+ 'top-right':'RT',
+ 'bottom-left':'LB',
+ 'bottom-right':'RB',
+ 'top-auto':'AT',
+ 'bottom-auto':'AB',
+ 'auto-left':'LA',
+ 'auto-right':'RA',
+ 'auto-auto':'AA'
+ };
$.PositionTypes = {
// horisontal constants: L-left, R-right, C-center, A-auto
// vertical constants: T-top, B-bottom, M-middle, A-auto
@@ -147,15 +166,15 @@
offset = e.offset();
var d = rect.left - offset.left;
if (d<0) {
- rect.width = (width > rect.width) ? width : rect.width - d;
+ if (width-d > rect.width) rect.width = width - d;
} else {
- if (d + width > rect.width) rect.width = d + width;
+ rect.width += d;
}
var d = rect.top - offset.top;
if (d<0) {
- rect.height = (height > rect.height) ? height : rect.height - d;
+ if (height-d > rect.height) rect.height = height -d;
} else {
- if (d + height > rect.height) rect.height = d + height;
+ rect.height += d;
}
if (offset.left < rect.left) rect.left = offset.left;
if (offset.top < rect.top) rect.top = offset.top;
Modified:
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
===================================================================
---
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -4,11 +4,11 @@
import java.util.Locale;
import javax.faces.bean.ManagedBean;
-import javax.faces.bean.RequestScoped;
+import javax.faces.bean.SessionScoped;
import javax.faces.event.ValueChangeEvent;
@ManagedBean
-@RequestScoped
+@SessionScoped
public class CalendarBean {
private Locale locale;
@@ -17,6 +17,9 @@
private Date selectedDate;
private boolean showApply = true;
private boolean useCustomDayLabels;
+ private String mode = "client";
+ private String jointPoint = "auto-auto";
+ private String direction = "auto-auto";
public CalendarBean() {
@@ -25,6 +28,14 @@
pattern = "d/M/yy HH:mm";
}
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
public Locale getLocale() {
return locale;
}
@@ -83,4 +94,20 @@
this.showApply = showApply;
}
+ public void setJointPoint(String jointPoint) {
+ this.jointPoint = jointPoint;
+ }
+
+ public String getJointPoint() {
+ return jointPoint;
+ }
+
+ public void setDirection(String direction) {
+ this.direction = direction;
+ }
+
+ public String getDirection() {
+ return direction;
+ }
+
}
\ No newline at end of file
Copied:
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java
(from rev 20107,
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java)
===================================================================
---
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java
(rev 0)
+++
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import java.util.Date;
+import java.util.Random;
+
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+
+import org.richfaces.model.CalendarDataModel;
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 30.06.2007
+ *
+ */
+@ManagedBean(name="calendarDataModel")
+@ApplicationScoped
+public class CalendarDataModelImpl implements CalendarDataModel {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModel#getData(java.util.Date[])
+ */
+ public CalendarDataModelItem[] getData(Date[] dateArray) {
+ if (dateArray == null) {
+ return null;
+ }
+
+ CalendarDataModelItem[] items = new CalendarDataModelItem[dateArray.length];
+ for (int i = 0; i < dateArray.length; i++) {
+ items[i] = createDataModelItem(dateArray[i]);
+ }
+
+ return items;
+ }
+
+ protected CalendarDataModelItem createDataModelItem(Date date) {
+ CalendarDataModelItemImpl item = new CalendarDataModelItemImpl();
+
+ if (new Random().nextInt(10) > 5) {
+ item.setEnabled(true);
+
+ } else {
+ item.setEnabled(false);
+ }
+
+ return item;
+ }
+}
Copied:
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java
(from rev 20107,
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java)
===================================================================
---
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java
(rev 0)
+++
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 04.07.2007
+ *
+ */
+public class CalendarDataModelItemImpl implements CalendarDataModelItem {
+
+ private boolean enabled = true;
+ private String styleClass = "";
+
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModelItem#isEnabled()
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getStyleClass() {
+ return styleClass;
+ }
+
+ public void setStyleClass(String styleClass) {
+ this.styleClass = styleClass;
+ }
+}
Modified:
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml
===================================================================
---
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml 2010-11-18
23:14:43 UTC (rev 20108)
@@ -38,7 +38,7 @@
</script>
<input:autocomplete autofill="false" id="myAutocomplete"
clientFilterFunction="customFilterFunction"
mode="#{autoCompleteBean.mode}" minChars="2"
autocompleteMethod="#{autoCompleteBean.autocomplete}" var="country"
fetchValue="#{country.name}" showButton="true"
- value = "#{autoCompleteBean.value}"
+ value = "#{autoCompleteBean.value}" layout="list"
onchange="return onEvent.call(this, event);" onselectitem="return
onEvent.call(this, event);" onblur="return onEvent.call(this, event);"
onfocus="return onEvent.call(this, event);">
#{country.name} #{country.iso} #{country.domain}
<a4j:ajax event="change" render="output"/>
@@ -88,6 +88,29 @@
<a4j:log mode="inline"></a4j:log>
</div>
</h:form>
+ <h:form>
+ RF-9567:<br/><br/>
+ <a4j:outputPanel ajaxRendered="true"><h:messages
/></a4j:outputPanel>
+
+
+ <input:autocomplete mode="ajax" id="autocomplete"
autocompleteMethod="#{autoCompleteBean.autocomplete}"
value="#{autoCompleteBean.value}">
+ <f:validateRegex pattern="Alabama" />
+ </input:autocomplete>
+
+ <a4j:commandButton render="@form" execute="autocomplete" />
+ </h:form>
+ <h:form>
+ <input:autocomplete mode="cachedAjax" tokens=","
minChars="0"
+autofill="true" selectFirst="false" layout="table"
+autocompleteMethod="#{autoCompleteBean.autocomplete}" var="country"
fetchValue="#{country.name}">
+<h:column>
+#{country.name}
+</h:column>
+<h:column>
+#{country.iso}
+</h:column>
+</input:autocomplete>
+</h:form>
</ui:define>
</ui:composition>
Modified: branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
---
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-18
23:14:43 UTC (rev 20108)
@@ -37,12 +37,14 @@
<h:panelGrid id="panel" columns="2">
<h:panelGroup layout="block">
<calendar:calendar value="#{calendarBean.selectedDate}"
id="calendar"
+ jointPoint="#{calendarBean.jointPoint}"
direction="#{calendarBean.direction}"
locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
+ dataModel="#{calendarDataModel}"
+ mode="#{calendarBean.mode}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
- cellHeight="22px" style="width:200px">
- <f:convertDateTime pattern="#{calendarBean.pattern}"
- onchange="alert('1')" />
+ cellHeight="22px" style="width:200px"
minDaysInFirstWeek="3">
+ <f:convertDateTime pattern="#{calendarBean.pattern}" />
</calendar:calendar>
</h:panelGroup>
<h:panelGrid columns="2">
@@ -73,6 +75,31 @@
<f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
<f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"
/>
</h:selectOneMenu>
+
+ <h:outputText value="Mode" />
+ <h:selectOneMenu value="#{calendarBean.mode}"
onchange="submit()">
+ <f:selectItem itemValue="client"/>
+ <f:selectItem itemValue="ajax"/>
+ </h:selectOneMenu><br/>
+
+ <h:outputText value="Select joint point:" />
+ <h:selectOneMenu value="#{calendarBean.jointPoint}">
+ <f:ajax execute="@form" event="change" render="calendar
@this" />
+ <f:selectItem itemLabel="auto-auto" itemValue="auto-auto"
/>
+ <f:selectItem itemLabel="top-left" itemValue="top-left"
/>
+ <f:selectItem itemLabel="top-right" itemValue="top-right"
/>
+ <f:selectItem itemLabel="bottom-left" itemValue="bottom-left"
/>
+ <f:selectItem itemLabel="bottom-right"
itemValue="bottom-right" />
+ </h:selectOneMenu>
+ <h:outputText value="Select direction:" />
+ <h:selectOneMenu value="#{calendarBean.direction}">
+ <f:ajax execute="@form" event="change" render="calendar
@this" />
+ <f:selectItem itemLabel="auto-auto" itemValue="auto-auto"
/>
+ <f:selectItem itemLabel="top-left" itemValue="top-left"
/>
+ <f:selectItem itemLabel="top-right" itemValue="top-right"
/>
+ <f:selectItem itemLabel="bottom-left" itemValue="bottom-left"
/>
+ <f:selectItem itemLabel="bottom-right"
itemValue="bottom-right" />
+ </h:selectOneMenu>
</h:panelGrid>
</h:panelGrid>
</h:form>
Copied:
branches/RF-8742-1/examples/iteration-demo/src/main/java/org/richfaces/demo/LazyTreeNode.java
(from rev 20107,
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/LazyTreeNode.java)
===================================================================
---
branches/RF-8742-1/examples/iteration-demo/src/main/java/org/richfaces/demo/LazyTreeNode.java
(rev 0)
+++
branches/RF-8742-1/examples/iteration-demo/src/main/java/org/richfaces/demo/LazyTreeNode.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,112 @@
+/*
+ * 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.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.swing.tree.TreeNode;
+
+import com.google.common.collect.Iterators;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class LazyTreeNode implements TreeNode, Serializable {
+
+ private static final long serialVersionUID = 7222747310505408841L;
+
+ private TreeNode srcNode;
+
+ private LazyTreeNode parentNode;
+
+ private List<LazyTreeNode> children = null;
+
+ public LazyTreeNode(LazyTreeNode parentNode, TreeNode srcNode) {
+ super();
+ this.parentNode = parentNode;
+ this.srcNode = srcNode;
+ }
+
+ public LazyTreeNode(TreeNode srcNode) {
+ this(null, srcNode);
+ }
+
+ private void initializeChildren() {
+ if (children != null) {
+ return;
+ }
+
+ children = new ArrayList<LazyTreeNode>();
+
+ Enumeration srcChildren = srcNode.children();
+ while (srcChildren.hasMoreElements()) {
+ TreeNode srcChild = (TreeNode) srcChildren.nextElement();
+ children.add(new LazyTreeNode(this, srcChild));
+ }
+ }
+
+ public TreeNode getChildAt(int childIndex) {
+ initializeChildren();
+
+ return children.get(childIndex);
+ }
+
+ public int getChildCount() {
+ initializeChildren();
+
+ return children.size();
+ }
+
+ public TreeNode getParent() {
+ return parentNode;
+ }
+
+ public int getIndex(TreeNode node) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean getAllowsChildren() {
+ return true;
+ }
+
+ public boolean isLeaf() {
+ if (children == null) {
+ return false;
+ }
+
+ return children.isEmpty();
+ }
+
+ public Enumeration children() {
+ initializeChildren();
+
+ return Iterators.asEnumeration(children.iterator());
+ }
+
+ public TreeNode getWrappedNode() {
+ return srcNode;
+ }
+}
Modified:
branches/RF-8742-1/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
===================================================================
---
branches/RF-8742-1/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -22,6 +22,7 @@
package org.richfaces.demo;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -30,9 +31,18 @@
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.AjaxBehaviorEvent;
+import javax.faces.event.FacesEvent;
import javax.swing.tree.TreeNode;
+import org.richfaces.component.AbstractTree;
+import org.richfaces.component.AbstractTreeNode;
import org.richfaces.component.SwitchType;
+import org.richfaces.event.TreeSelectionChangeEvent;
+import org.richfaces.event.TreeSelectionChangeListener;
+import org.richfaces.event.TreeToggleEvent;
+import org.richfaces.event.TreeToggleListener;
import org.richfaces.log.LogFactory;
import org.richfaces.log.Logger;
@@ -44,26 +54,98 @@
@SessionScoped
public class TreeBean implements Serializable {
+ public static final class SelectionChangeHandler implements
TreeSelectionChangeListener {
+
+ private boolean fromExpression = false;
+
+ public SelectionChangeHandler() {
+ }
+
+ public SelectionChangeHandler(boolean fromExpression) {
+ super();
+ this.fromExpression = fromExpression;
+ }
+
+ public void processSelectionChange(TreeSelectionChangeEvent event) throws
AbortProcessingException {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ facesContext.addMessage(getTree(event).getBaseClientId(facesContext),
createEventMessage(event, fromExpression));
+ }
+
+ }
+
+ public static final class ToggleHandler implements TreeToggleListener {
+
+ private boolean fromExpression = false;
+
+ public ToggleHandler() {
+ }
+
+ public ToggleHandler(boolean fromExpression) {
+ super();
+ this.fromExpression = fromExpression;
+ }
+
+ public void processToggle(TreeToggleEvent event) throws AbortProcessingException
{
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage(getTree(event).getBaseClientId(facesContext),
createEventMessage(event, fromExpression));
+ }
+
+ }
+
private static final long serialVersionUID = 3368885134614548497L;
private static final Logger LOGGER = LogFactory.getLogger(TreeBean.class);
private List<TreeNode> rootNodes;
+ private List<TreeNode> lazyRootNodes;
+
private SwitchType toggleType = SwitchType.DEFAULT;
private SwitchType selectionType = SwitchType.client;
- private Object nodeData;
+ private boolean showCustomClasses = true;
private Collection<Object> selection = new TracingSet<Object>();
+
+ private String toggleNodeEvent = "";
+ private static Object staticGetNodeData() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ return facesContext.getApplication().evaluateExpressionGet(facesContext,
"#{node}", Object.class);
+ }
+
+ private static FacesMessage createEventMessage(FacesEvent event, boolean
fromExpression) {
+ String summary = event + (fromExpression ? " called from attribute" :
" called from tag") + ", data: " + staticGetNodeData();
+ return new FacesMessage(summary);
+ }
+
+ private static AbstractTree getTree(FacesEvent event) {
+ if (event.getComponent() instanceof AbstractTree) {
+ return (AbstractTree) event.getComponent();
+ }
+
+ return ((AbstractTreeNode) event.getComponent()).findTreeComponent();
+ }
+
+ private List<TreeNode> createLazyNodes(List<TreeNode> nodes) {
+ List<TreeNode> result = new ArrayList<TreeNode>(nodes.size());
+
+ for (TreeNode srcNode : nodes) {
+ result.add(new LazyTreeNode(srcNode));
+ }
+
+ return result;
+ }
+
@PostConstruct
public void init() {
try {
TreeNodeParser parser = new TreeNodeParser();
parser.parse(TreeBean.class.getResource("plants.xml"));
rootNodes = parser.getRootNodes();
+ lazyRootNodes = createLazyNodes(rootNodes);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
@@ -73,6 +155,10 @@
return rootNodes;
}
+ public List<TreeNode> getLazyRootNodes() {
+ return lazyRootNodes;
+ }
+
public SwitchType[] getTypes() {
return SwitchType.values();
}
@@ -94,13 +180,9 @@
}
public Object getNodeData() {
- return nodeData;
+ return staticGetNodeData();
}
- public void setNodeData(Object nodeData) {
- this.nodeData = nodeData;
- }
-
public Collection<Object> getSelection() {
return selection;
}
@@ -113,4 +195,40 @@
FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.addMessage(null, new FacesMessage("Clicked node: " +
getNodeData()));
}
+
+ public boolean isShowCustomClasses() {
+ return showCustomClasses;
+ }
+
+ public void setShowCustomClasses(boolean showCustomClasses) {
+ this.showCustomClasses = showCustomClasses;
+ }
+
+ public void behaviorToggleListener(AjaxBehaviorEvent event) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage(null, new FacesMessage("Toggle node: " +
getNodeData() + ", source is: " + event.getSource()));
+ }
+
+ public void behaviorSelectionChangeListener(AjaxBehaviorEvent event) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage(event.getComponent().getClientId(facesContext), new
FacesMessage("Selection changed, source is: " + event.getSource()));
+ }
+
+ public void processSelectionChange(TreeSelectionChangeEvent event) {
+ new SelectionChangeHandler(true).processSelectionChange(event);
+ }
+
+ public void processToggle(TreeToggleEvent event) {
+ new ToggleHandler(true).processToggle(event);
+ }
+
+ public String getToggleNodeEvent() {
+ return toggleNodeEvent;
+ }
+
+ public void setToggleNodeEvent(String toggleNodeEvent) {
+ this.toggleNodeEvent = toggleNodeEvent;
+ }
+
+
}
Modified: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/RF-8742-1/examples/iteration-demo/src/main/webapp/WEB-INF/web.xml 2010-11-18
18:50:06 UTC (rev 20107)
+++ branches/RF-8742-1/examples/iteration-demo/src/main/webapp/WEB-INF/web.xml 2010-11-18
23:14:43 UTC (rev 20108)
@@ -72,6 +72,11 @@
<param-value>true</param-value>
</context-param>
+ <context-param>
+ <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
<context-param>
<description>
Set this flag to true if you want the JavaServer Faces
Copied: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images (from rev 20107,
trunk/examples/iteration-demo/src/main/webapp/images)
Deleted: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/leaf.png
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/images/leaf.png 2010-11-18 18:50:06 UTC
(rev 20107)
+++ branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/leaf.png 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,4 +0,0 @@
-�PNG
-
-
\ No newline at end of file
Copied: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/leaf.png (from
rev 20107, trunk/examples/iteration-demo/src/main/webapp/images/leaf.png)
===================================================================
--- branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/leaf.png
(rev 0)
+++ branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/leaf.png 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,4 @@
+�PNG
+
+
\ No newline at end of file
Deleted: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/minus.png
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/images/minus.png 2010-11-18 18:50:06 UTC
(rev 20107)
+++ branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/minus.png 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,4 +0,0 @@
-�PNG
-
-
\ No newline at end of file
Copied: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/minus.png (from
rev 20107, trunk/examples/iteration-demo/src/main/webapp/images/minus.png)
===================================================================
--- branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/minus.png
(rev 0)
+++ branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/minus.png 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,4 @@
+�PNG
+
+
\ No newline at end of file
Deleted: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/plus.png
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/images/plus.png 2010-11-18 18:50:06 UTC
(rev 20107)
+++ branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/plus.png 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,5 +0,0 @@
-�PNG
-
-
-�<n3�%ϥh�
\ No newline at end of file
Copied: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/plus.png (from
rev 20107, trunk/examples/iteration-demo/src/main/webapp/images/plus.png)
===================================================================
--- branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/plus.png
(rev 0)
+++ branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/plus.png 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,5 @@
+�PNG
+
+
+�<n3�%ϥh�
\ No newline at end of file
Modified: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- branches/RF-8742-1/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18
18:50:06 UTC (rev 20107)
+++ branches/RF-8742-1/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18
23:14:43 UTC (rev 20108)
@@ -3,14 +3,80 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:it="http://richfaces.org/iteration">
+
xmlns:it="http://richfaces.org/iteration"
+
xmlns:a4j="http://richfaces.org/a4j">
<f:view contentType="text/html" />
<h:head>
<title>Richfaces Tree</title>
+
+ <h:outputStylesheet>/*<![CDATA[*/
+ .customClass .customNodeClass {
+ border: 1px solid navy;
+ }
+
+ .customClass .customHandleClass {
+ border: 1px solid red;
+ }
+
+ .customClass .customIconClass {
+ border: 1px solid yellow;
+ }
+
+ .customClass .customLabelClass {
+ border: 1px solid green;
+ }
+
+ /*]]>*/</h:outputStylesheet>
</h:head>
<h:body>
+ <h:outputScript>
+ function nodesArrayToString(nodes) {
+ var result = new Array();
+ jQuery.each(nodes, function(k, v) {
+ result.push(v.getId());
+ });
+
+ return result.join('');
+ }
+
+ function getNodeStateString(treeNode) {
+ return treeNode.isLeaf() ?
+ 'leaf'
+ : (treeNode.isExpanded() ? 'expanded' : 'collapsed');
+ }
+
+ function handleNodeToggle(nodeData, event, isTreeNodeLevel) {
+ var treeNode = RichFaces.$(event.target);
+ RichFaces.log.info('Toggle event ' + (isTreeNodeLevel ? '(treeNode
level)' : '')
+ + '[' + nodeData + ']:\n ' + treeNode.getId() + ' became ' +
getNodeStateString(treeNode));
+ }
+
+ function handleBeforeNodeToggle(event, isTreeNodeLevel) {
+ var treeNode = RichFaces.$(event.target);
+ return confirm('Tree' + (isTreeNodeLevel ? ' node ' : ' ') +
'asks: really toggle node ' + treeNode.getId() + '?');
+ }
+
+ function handleBeforeNodeSelect(event) {
+ var treeNode = RichFaces.$(event.target);
+
+ var oldSelectionString = nodesArrayToString(event.rf.data.oldSelection);
+ var newSelectionString = nodesArrayToString(event.rf.data.newSelection);
+
+ return confirm('Selection will be changed from: [' + oldSelectionString +
'] to: [' + newSelectionString + ']');
+ }
+
+ function handleNodeSelect(event) {
+ var treeNode = RichFaces.$(event.target);
+
+ var oldSelectionString = nodesArrayToString(event.rf.data.oldSelection);
+ var newSelectionString = nodesArrayToString(event.rf.data.newSelection);
+
+ RichFaces.log.info('Selection changed from: [' + oldSelectionString + ']
to: [' + newSelectionString + ']');
+ }
+ </h:outputScript>
+
<h:messages id="messages" />
<h:form>
@@ -21,17 +87,27 @@
Selection mode: <h:selectOneRadio value="#{treeBean.selectionType}"
onclick="submit()">
<f:selectItems value="#{treeBean.types}" itemDisabled="#{item ==
'server'}" var="item" itemValue="#{item}" />
</h:selectOneRadio>
+
+ Show custom classes: <h:selectBooleanCheckbox
value="#{treeBean.showCustomClasses}" onclick="submit()" />
+
+ <br />
+ Toggle node event:
+ <h:selectOneMenu value="#{treeBean.toggleNodeEvent}"
onchange="submit()">
+ <f:selectItem itemLabel="none" itemValue="" />
+ <f:selectItem itemLabel="click" itemValue="click" />
+ <f:selectItem itemLabel="mouseenter" itemValue="mouseenter"
/>
+ <f:selectItem itemLabel="dblclick" itemValue="dblclick" />
+ </h:selectOneMenu>
</h:form>
<h:form id="form">
+ Base tree:
<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} -
<h:commandLink value="link"
action="#{treeBean.clickNode}">
- <f:setPropertyActionListener value="#{node.data}"
target="#{treeBean.nodeData}" />
-
<f:ajax render=":messages" />
</h:commandLink>
</h:panelGroup>
@@ -40,8 +116,6 @@
<h:panelGroup id="childNodeGroup">
#{node.data} -
<h:commandLink value="link"
action="#{treeBean.clickNode}">
- <f:setPropertyActionListener value="#{node.data}"
target="#{treeBean.nodeData}" />
-
<f:ajax render=":messages" />
</h:commandLink>
</h:panelGroup>
@@ -51,6 +125,94 @@
<h:commandLink value="Re-render">
<f:ajax render=":form:tree" execute="@all" />
</h:commandLink>
+
+ Tree with customized look:
+ <it:tree id="customizedTree" var="node"
value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}"
+ styleClass="#{treeBean.showCustomClasses ? 'customClass' :
''}"
+ nodeClass="customNodeClassFromTree"
+ handleClass="customHandleClassFromTree"
iconClass="customIconClassFromTree"
labelClass="customLabelClassFromTree">
+
+ <it:treeNode iconLeaf="/images/leaf.png"
iconExpanded="/images/minus.png" iconCollapsed="/images/plus.png"
+ styleClass="customNodeClass" handleClass="customHandleClass"
iconClass="customIconClass" labelClass="customLabelClass">
+ #{node.data}
+ </it:treeNode>
+ </it:tree>
+
+ Tree with default node:
+ <it:tree id="defaultNodeTree" var="node"
value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}">
+ </it:tree>
+
+ Tree with client-side event handlers:
+ <it:tree id="clientSideEventsTree" var="node"
value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}"
+ onnodetoggle="handleNodeToggle("#{node.data}", event,
false)"
+ onselectionchange="handleNodeSelect(event)"
+ onbeforeselectionchange="return handleBeforeNodeSelect(event)"
+ onbeforenodetoggle="return handleBeforeNodeToggle(event, false)">
+
+ <it:treeNode ontoggle="handleNodeToggle("#{node.data}",
event, true)"
+ onbeforetoggle="return handleBeforeNodeToggle(event, true)">
+ #{node.data}
+ </it:treeNode>
+ </it:tree>
+
+ Tree with attached behaviors:
+ <h:messages id="treeBehaviorsMessages"
for="behaviorsAttachedTree" />
+ <h:messages id="treeNodeBehaviorsMessages" globalOnly="true"
/>
+
+ <it:tree id="behaviorsAttachedTree" var="node"
value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}">
+
+ <f:ajax event="nodetoggle"
listener="#{treeBean.behaviorToggleListener}"
render=":form:treeBehaviorsMessages" />
+ <f:ajax event="selectionchange"
listener="#{treeBean.behaviorSelectionChangeListener}"
render=":form:treeBehaviorsMessages :form:treeNodeBehaviorsMessages" />
+
+ <it:treeNode>
+ #{node.data}
+
+ <f:ajax event="toggle"
listener="#{treeBean.behaviorToggleListener}"
render=":form:treeNodeBehaviorsMessages" />
+ </it:treeNode>
+ </it:tree>
+
+ Lazy loaded tree:
+ <it:tree id="lazyLoadedTree" var="node"
value="#{treeBean.lazyRootNodes}"
+ selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}">
+
+ <it:treeNode>
+ #{node.wrappedNode.data}
+ </it:treeNode>
+ </it:tree>
+
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages for="serverListenersTree" />
+ </a4j:outputPanel>
+
+ Server listeners test:
+ <it:tree id="serverListenersTree" var="node"
value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}"
+ selectionChangeListener="#{treeBean.processSelectionChange}"
+ toggleListener="#{treeBean.processToggle}">
+
+ <it:treeSelectionChangeListener
type="org.richfaces.demo.TreeBean$SelectionChangeHandler" />
+ <it:treeToggleListener type="org.richfaces.demo.TreeBean$ToggleHandler"
/>
+
+ <it:treeNode toggleListener="#{treeBean.processToggle}">
+ <it:treeToggleListener type="org.richfaces.demo.TreeBean$ToggleHandler"
/>
+
+ #{node.data}
+ </it:treeNode>
+ </it:tree>
+
+ Toggle node event:
+ <it:tree toggleNodeEvent="#{treeBean.toggleNodeEvent}"
var="node" value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}">
+ <it:treeNode>
+ #{node.data}
+ </it:treeNode>
+ </it:tree>
+
+ <a4j:log />
</h:form>
</h:body>
</html>
Modified: branches/RF-8742-1/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
===================================================================
---
branches/RF-8742-1/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-11-18
23:14:43 UTC (rev 20108)
@@ -26,7 +26,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:pn="http://richfaces.org/output">
+
xmlns:rich="http://richfaces.org/output">
<body>
<ui:composition template="/templates/template.xhtml">
@@ -39,11 +39,67 @@
<ui:define name="body_head">TOOLTIP JS Development</ui:define>
<ui:define name="body">
- <h:form id="f" style="border:blue solid thin;">
- <pn:tooltip id="tooltip">
- <!-- TODO -->
- </pn:tooltip>
- </h:form>
+ <h:panelGrid columns="2">
+ <rich:panel id="sample1" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>Here you can see <b>default client-side</b>
tool-tip</p>
+ <rich:tooltip id="tt1" styleClass="tooltip">
+ <span style="white-space: nowrap"> This tool-tip content
was
+ <strong>pre-rendered</strong> to the page.<br />
+ Also the tooltip following mouse by default </span>
+ </rich:tooltip>
+ </rich:panel>
+ <rich:panel id="sample2" styleClass="tooltip"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip will not <b>follow mouse</b>. Also this
tool-tip
+ has a <b>delay 1.5 sec</b>, so be patient!</p>
+ <rich:tooltip followMouse="false" showDelay="1500"
+ styleClass="tooltip-custom-body">
+ <span style="white-space: nowrap"> This tool-tip content
also
+ <strong>pre-rendered</strong> to the page.<br />
+ </span>
+ </rich:tooltip>
+ </rich:panel>
+ <h:form>
+ <rich:panel id="sample3" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip rendered on server <b>in separate
request</b>.
+ </p>
+ <rich:tooltip mode="ajax" styleClass="tooltip"
layout="block">
+ <f:facet name="defaultContent">
+ <strong>Wait...</strong>
+ </f:facet>
+ <span style="white-space: nowrap">This tool-tip
content was
+ <strong>rendered on server</strong> </span>
+ <h:panelGrid columns="2">
+ <h:outputText style="white-space:nowrap"
+ value="tooltips requested" />
+ </h:panelGrid>
+ </rich:tooltip>
+ </rich:panel>
+ </h:form>
+ <h:form>
+ <rich:panel id="sample4" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip will be <b>activated on mouse
click</b>.</p>
+ <rich:tooltip showEvent="click" mode="ajax"
styleClass="tooltip"
+ layout="block">
+ <f:facet name="defaultContent">
+ <strong>Wait...</strong>
+ </f:facet>
+ <span style="white-space: nowrap">This tool-tip
content was
+ <strong>rendered on server</strong><br />
+ </span>
+ <h:panelGrid columns="2">
+ <h:outputText style="white-space:nowrap"
+ value="tooltips requested:" />
+ <h:outputText
value="#{tooltipData.tooltipCounter}"
+ styleClass="tooltipData" />
+ </h:panelGrid>
+ </rich:tooltip>
+ </rich:panel>
+ </h:form>
+ </h:panelGrid>
</ui:define>
</ui:composition>
</body>
Modified:
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
===================================================================
---
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -36,7 +36,7 @@
import org.richfaces.demo.tree.model.CD;
import org.richfaces.demo.tree.model.Company;
import org.richfaces.demo.tree.model.Country;
-import org.richfaces.event.TreeSelectionEvent;
+import org.richfaces.event.TreeSelectionChangeEvent;
/**
* @author Ilya Shaikovsky
@@ -88,7 +88,7 @@
return company;
}
- private void selectionListener(TreeSelectionEvent event) {
+ private void selectionListener(TreeSelectionChangeEvent event) {
//TODO: implement when ready
}
Modified:
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
---
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -853,6 +853,10 @@
return clientId;
}
+ public String getBaseClientId(FacesContext context) {
+ return super.getClientId(context);
+ }
+
/**
* Save current state of data variable.
*
@@ -1489,7 +1493,7 @@
int separatorIndex = substring.indexOf(separatorChar);
if (separatorIndex < 0) {
- return substring;
+ return null;
} else {
return substring.substring(0, separatorIndex);
}
Modified:
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java
===================================================================
---
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -21,6 +21,7 @@
package org.richfaces.renderkit;
+import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -40,8 +41,8 @@
private Map<String, Object> options = new HashMap<String, Object>();
- public void appendScript(StringBuffer functionString) {
- functionString.append(ScriptUtils.toScript(options));
+ public void appendScript(Appendable target) throws IOException {
+ ScriptUtils.appendScript(target, options);
}
public boolean isEmpty() {
Modified:
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
---
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -299,7 +299,7 @@
}
if (isChained) {
- result.insert(0, "jsf.util.chain(this, event, ");
+ result.insert(0, "return jsf.util.chain(this, event, ");
result.append(")");
}
@@ -326,6 +326,8 @@
return false;
} else if (attributeValue instanceof Long && (Long) attributeValue ==
Long.MIN_VALUE) {
return false;
+ } else if (attributeValue instanceof Collection<?> || attributeValue
instanceof Map<?, ?>) {
+ return true;
}
return attributeValue.toString().length() > 0;
@@ -382,6 +384,8 @@
}
}
+ //TODO - create special method for event handlers that will return String?
+ //TODO - add check for 'disabled'?
public static Object getAttributeAndBehaviorsValue(FacesContext facesContext,
UIComponent component,
ComponentAttribute componentAttribute) {
if (facesContext == null) {
@@ -699,6 +703,51 @@
return path;
}
+ public static String getResourceURL(String url, FacesContext context) {
+ if (null == url) {
+ return null;
+ }
+
+ String value = url;
+
+ value = context.getApplication().getViewHandler().getResourceURL(context,
value);
+
+ return context.getExternalContext().encodeResourceURL(value);
+ }
+
+ public static Object getFirstNonEmptyAttribute(String attributeName, UIComponent
component) {
+ Object attributeValue = component.getAttributes().get(attributeName);
+
+ return !isEmpty(attributeValue) ? attributeValue : null;
+ }
+
+ public static Object getFirstNonEmptyAttribute(String attributeName, UIComponent
componentA, UIComponent componentB) {
+ Object attributeValue = componentA.getAttributes().get(attributeName);
+
+ if (!isEmpty(attributeValue)) {
+ return attributeValue;
+ }
+
+ attributeValue = componentB.getAttributes().get(attributeName);
+
+ if (!isEmpty(attributeValue)) {
+ return attributeValue;
+ }
+
+ return null;
+ }
+
+ public static Object getFirstNonEmptyAttribute(String attributeName, UIComponent...
components) {
+ for (UIComponent component : components) {
+ Object attributeValue = component.getAttributes().get(attributeName);
+ if (!isEmpty(attributeValue)) {
+ return attributeValue;
+ }
+ }
+
+ return null;
+ }
+
@SuppressWarnings("serial")
public static final class Attributes extends TreeSet<ComponentAttribute> {
Modified:
branches/RF-8742-1/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java
===================================================================
---
branches/RF-8742-1/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -199,10 +199,10 @@
ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
UIComponent component = (UIComponent) behaviorHolder;
- responseWriter.writeAttribute(eq("onkeypress"),
eq("jsf.util.chain(this, event,
'alert(keypress)','prompt(keypress)')"),
+ responseWriter.writeAttribute(eq("onkeypress"), eq("return
jsf.util.chain(this, event, 'alert(keypress)','prompt(keypress)')"),
EasyMock.<String>isNull());
responseWriter.writeAttribute(eq("onclick"),
- eq("jsf.util.chain(this, event,
'alert(click)','prompt(action1)','prompt(action2)')"),
EasyMock.<String>isNull());
+ eq("return jsf.util.chain(this, event,
'alert(click)','prompt(action1)','prompt(action2)')"),
EasyMock.<String>isNull());
responseWriter.writeAttribute(eq("onmousemove"),
eq("alert(mousemove)"), EasyMock.<String>isNull());
responseWriter.writeAttribute(eq("oncontextmenu"),
eq("prompt(contextmenu)"), EasyMock.<String>isNull());
@@ -249,7 +249,7 @@
componentAttributes.put("disabled", Boolean.FALSE);
UIComponent component = setupBehaviorsTestForDisabledComponent();
- responseWriter.writeAttribute(eq("onclick"),
eq("jsf.util.chain(this, event,
'alert(click)','prompt(action1)')"),
+ responseWriter.writeAttribute(eq("onclick"), eq("return
jsf.util.chain(this, event, 'alert(click)','prompt(action1)')"),
EasyMock.<String>isNull());
responseWriter.writeAttribute(eq("onmousemove"),
eq("alert(mousemove)"), EasyMock.<String>isNull());
Modified:
branches/RF-8742-1/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
===================================================================
---
branches/RF-8742-1/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,19 +23,20 @@
package org.richfaces.renderkit;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.renderkit.util.AjaxRendererUtils;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIParameter;
-import javax.faces.context.FacesContext;
-import java.util.Iterator;
-import java.util.Map;
-
/**
* @author shura
*
@@ -48,7 +49,7 @@
throw new FacesException("Value of 'name' attribute of
a4j:jsFunction component is null!");
}
- StringBuffer script = new StringBuffer(functionName).append("=");
+ StringBuilder script = new StringBuilder(functionName).append("=");
JSFunctionDefinition func = new JSFunctionDefinition();
// func.setName(component.getName());
@@ -94,7 +95,7 @@
// TODO - added in 4.0 - ?
func.addParameter(JSReference.EVENT);
func.addToBody(ajaxFunction.toScript());
- func.appendScript(script);
+ func.appendScriptToStringBuilder(script);
return script.toString();
}
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -22,16 +22,24 @@
package org.richfaces.component;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.UIViewRoot;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.convert.DateTimeConverter;
import javax.faces.event.AbortProcessingException;
@@ -43,22 +51,28 @@
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.context.ExtendedVisitContextMode;
+import org.richfaces.event.CurrentDateChangeEvent;
+import org.richfaces.event.CurrentDateChangeListener;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
+import org.richfaces.model.CalendarDataModel;
+import org.richfaces.model.CalendarDataModelItem;
+import org.richfaces.renderkit.MetaComponentRenderer;
import org.richfaces.utils.CalendarHelper;
-import org.richfaces.event.CurrentDateChangeEvent;
-import org.richfaces.event.CurrentDateChangeListener;
-
/**
* @author amarkhel
*
*/
@JsfComponent(type = AbstractCalendar.COMPONENT_TYPE, family =
AbstractCalendar.COMPONENT_FAMILY, generate =
"org.richfaces.component.UICalendar", renderer = @JsfRenderer(type =
"org.richfaces.CalendarRenderer"), tag = @Tag(name = "calendar"))
-public abstract class AbstractCalendar extends UIInput {
+public abstract class AbstractCalendar extends UIInput implements MetaComponentResolver,
MetaComponentEncoder {
+ public static final String DAYSDATA_META_COMPONENT_ID = "daysData";
+
public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
public static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
@@ -75,7 +89,12 @@
locale
};
+ public enum Modes {
+ CLIENT,
+ AJAX
+ }
+
@Attribute(defaultValue = "MMM d, yyyy")
public abstract String getDatePattern();
@@ -144,6 +163,9 @@
@Attribute(defaultValue = "3")
public abstract int getZindex();
+
+ @Attribute(defaultValue = "client")
+ public abstract String getMode();
@Attribute
public abstract String getStyle();
@@ -184,6 +206,7 @@
@Attribute
public abstract Object getCurrentDate();
+ @Attribute
public abstract void setCurrentDate(Object date);
@Attribute
@@ -194,6 +217,19 @@
@Attribute
public abstract Object getDefaultTime();
+
+ @Attribute(defaultValue =
"getDefaultPreloadBegin(getCurrentDateOrDefault())")
+ public abstract Object getPreloadDateRangeBegin();
+
+ public abstract void setPreloadDateRangeBegin(Object date);
+
+ @Attribute(defaultValue =
"getDefaultPreloadEnd(getCurrentDateOrDefault())")
+ public abstract Object getPreloadDateRangeEnd();
+
+ public abstract void setPreloadDateRangeEnd(Object date);
+
+ @Attribute
+ public abstract CalendarDataModel getDataModel();
@Attribute(events = @EventName("inputclick"))
public abstract String getOninputclick();
@@ -306,7 +342,46 @@
public CurrentDateChangeListener[] getCurrentDateChangeListeners() {
return (CurrentDateChangeListener[])
getFacesListeners(CurrentDateChangeListener.class);
}
+
+ protected Date getDefaultPreloadBegin(Date date) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Calendar calendar = Calendar.getInstance(getTimeZone(),
+ CalendarHelper.getAsLocale(facesContext, this, getLocale()));
+ calendar.setTime(date);
+ calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE));
+ return calendar.getTime();
+ }
+ protected Date getDefaultPreloadEnd(Date date) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Calendar calendar = Calendar.getInstance(getTimeZone(),
+ CalendarHelper.getAsLocale(facesContext, this, getLocale()));
+ calendar.setTime(date);
+ calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
+ /*
+ * //force recalculation calendar.getTimeInMillis();
+ * calendar.set(Calendar.DAY_OF_WEEK, getLastDayOfWeek(calendar));
+ */
+ return calendar.getTime();
+ }
+
+ public Date getCurrentDateOrDefault() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ Date date = CalendarHelper.getAsDate(facesContext, this, getCurrentDate());
+
+ if (date != null) {
+ return date;
+ } else {
+ Date value = CalendarHelper.getAsDate(facesContext, this, this.getValue());
+ if (value != null) {
+ return value;
+ } else {
+ return java.util.Calendar.getInstance(getTimeZone()).getTime();
+ }
+ }
+ }
+
public void broadcast(FacesEvent event) throws AbortProcessingException {
if (event instanceof CurrentDateChangeEvent) {
FacesContext facesContext = getFacesContext();
@@ -348,4 +423,110 @@
event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
}
}
+
+ public String resolveClientId(FacesContext facesContext, UIComponent
contextComponent, String metaComponentId) {
+ if (DAYSDATA_META_COMPONENT_ID.equals(metaComponentId)) {
+ return getClientId(facesContext) +
MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
+ }
+ return null;
+ }
+
+ public String substituteUnresolvedClientId(FacesContext facesContext, UIComponent
contextComponent,
+ String metaComponentId) {
+ return null;
+ }
+
+ @Override
+ public boolean visitTree(VisitContext context, VisitCallback callback) {
+ if (context instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) context;
+ if (extendedVisitContext.getVisitMode() == ExtendedVisitContextMode.RENDER)
{
+
+ VisitResult result =
extendedVisitContext.invokeMetaComponentVisitCallback(this, callback,
+ DAYSDATA_META_COMPONENT_ID);
+ if (result == VisitResult.COMPLETE) {
+ return true;
+ } else if (result == VisitResult.REJECT) {
+ return false;
+ }
+ }
+ }
+
+ return super.visitTree(context, callback);
+ }
+
+ public void encodeMetaComponent(FacesContext context, String metaComponentId) throws
IOException {
+ ((MetaComponentRenderer) getRenderer(context)).encodeMetaComponent(context, this,
metaComponentId);
+ }
+
+ public Object getPreload() {
+ Date[] preloadDateRange = getPreloadDateRange();
+ if (preloadDateRange != null && preloadDateRange.length != 0) {
+ CalendarDataModel calendarDataModel = (CalendarDataModel) getDataModel();
+ if (calendarDataModel != null) {
+ CalendarDataModelItem[] calendarDataModelItems = calendarDataModel
+ .getData(preloadDateRange);
+
+ HashMap<String, Object> args = new HashMap<String,
Object>();
+
+ args.put("startDate", formatStartDate(preloadDateRange[0]));
+ args.put("days", calendarDataModelItems);
+ return args;
+ }
+ }
+ return null;
+ }
+
+ public static Object formatStartDate(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ HashMap <String, Object> hashDate = new HashMap<String,Object>();
+ hashDate.put("month", calendar.get(Calendar.MONTH));
+ hashDate.put("year", calendar.get(Calendar.YEAR));
+ return hashDate;
+ }
+
+ public Date[] getPreloadDateRange() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ Date dateRangeBegin = null;
+ Date dateRangeEnd = null;
+
+ if (Modes.AJAX.toString().equalsIgnoreCase(getMode())) {
+ dateRangeBegin = CalendarHelper.getAsDate(facesContext, this,
+ getDefaultPreloadBegin((Date) getCurrentDate()));
+ dateRangeEnd = CalendarHelper.getAsDate(facesContext, this,
+ getDefaultPreloadEnd((Date) getCurrentDate()));
+ } else {
+ dateRangeBegin = CalendarHelper.getAsDate(facesContext, this,
getPreloadDateRangeBegin());
+ dateRangeEnd = CalendarHelper.getAsDate(facesContext, this,
getPreloadDateRangeEnd());
+ }
+
+ if (dateRangeBegin == null && dateRangeEnd == null) {
+ return null;
+ } else {
+ if (dateRangeBegin.after(dateRangeEnd)) {
+ // XXX add message
+ FacesMessage message = new FacesMessage(
+ "preloadDateRangeBegin is greater than
preloadDateRangeEnd");
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ facesContext.addMessage(getClientId(facesContext), message);
+ throw new IllegalArgumentException();
+ }
+
+ List<Date> dates = new ArrayList<Date>();
+
+ Calendar calendar = Calendar.getInstance(this.getTimeZone(),
CalendarHelper.getAsLocale(facesContext, this, this.getLocale()));
+ Calendar calendar2 = (Calendar) calendar.clone();
+ calendar.setTime(dateRangeBegin);
+ calendar2.setTime(dateRangeEnd);
+
+ do {
+ dates.add(calendar.getTime());
+ calendar.add(Calendar.DATE, 1);
+ } while (!calendar.after(calendar2));
+
+ return (Date[]) dates.toArray(new Date[dates.size()]);
+ }
+ }
}
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model (from rev 20107,
trunk/ui/input/ui/src/main/java/org/richfaces/model)
Deleted:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,40 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.util.Date;
-/**
- * @author Alexej Kushunin
- * created 19.06.2007
- *
- */
-public interface CalendarDataModel {
- /**
- * @return array of CalendarDataModelItems for selected dates.
- * This method will be called every time when components will need next
- * block of CalendarDataItems.
- * That may happens when calendar rendered, or when user navigate to
- * next(previous) month or in any other case when calendar renders.
- * This method will be called in Ajax mode when Calendar renders new page.
- * */
- CalendarDataModelItem[] getData(Date[] dateArray);
-
-}
Copied:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java
(from rev 20107,
trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java)
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java
(rev 0)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,40 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.util.Date;
+/**
+ * @author Alexej Kushunin
+ * created 19.06.2007
+ *
+ */
+public interface CalendarDataModel {
+ /**
+ * @return array of CalendarDataModelItems for selected dates.
+ * This method will be called every time when components will need next
+ * block of CalendarDataItems.
+ * That may happens when calendar rendered, or when user navigate to
+ * next(previous) month or in any other case when calendar renders.
+ * This method will be called in Ajax mode when Calendar renders new page.
+ * */
+ CalendarDataModelItem[] getData(Date[] dateArray);
+
+}
Deleted:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,47 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-
-
-/**
- * @author Alexej Kushunin
- * created 19.06.2007
- *
- */
-
-public interface CalendarDataModelItem {
- /**
- *@return true if date is �selectable� on calendar, default
- *implementation return true
- **/
- boolean isEnabled();
-
- /**
- * @return String that will be appended to style class for that date span.
- * For example it may be �relevant holyday� � that mean class will be like
�rich-cal-day relevant holyday�.
- * Default implementation return empty string.
- * */
- public String getStyleClass();
-}
-
-
-
Copied:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java
(from rev 20107,
trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java)
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java
(rev 0)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,47 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+
+
+/**
+ * @author Alexej Kushunin
+ * created 19.06.2007
+ *
+ */
+
+public interface CalendarDataModelItem {
+ /**
+ *@return true if date is �selectable� on calendar, default
+ *implementation return true
+ **/
+ boolean isEnabled();
+
+ /**
+ * @return String that will be appended to style class for that date span.
+ * For example it may be �relevant holyday� � that mean class will be like
�rich-cal-day relevant holyday�.
+ * Default implementation return empty string.
+ * */
+ public String getStyleClass();
+}
+
+
+
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -64,7 +64,7 @@
public void encodeItem(FacesContext facesContext, UIComponent component) throws
IOException {
ResponseWriter writer = facesContext.getResponseWriter();
encodeItemBegin(facesContext, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt rf-au-fnt
rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm rf-au-opt
rf-au-fnt rf-au-inp", null);
for (UIComponent child : component.getChildren()) {
child.encodeAll(facesContext);
}
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -22,7 +22,7 @@
ResponseWriter responseWriter = facesContext.getResponseWriter();
responseWriter.startElement(HtmlConstants.UL_ELEMENT, component);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE,
getContainerElementId(facesContext, component), null);
- responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
"rf-au-list-ul", null);
+ responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
"rf-au-lst-ul", null);
}
public void encodeItemsContainerEnd(FacesContext facesContext, UIComponent component)
throws IOException {
@@ -43,7 +43,7 @@
public void encodeItem(FacesContext facesContext, UIComponent component) throws
IOException {
ResponseWriter writer = facesContext.getResponseWriter();
encodeItemBegin(facesContext, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt rf-au-fnt
rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm rf-au-opt
rf-au-fnt rf-au-inp", null);
for (UIComponent child : component.getChildren()) {
child.encodeAll(facesContext);
}
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -212,7 +212,7 @@
} else {
if (item != null) {
strategy.encodeItemBegin(facesContext, comboBox);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt
rf-au-fnt rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm
rf-au-opt rf-au-fnt rf-au-inp", null);
// TODO nick - use converter
String value = null;
if (comboBox.getItemConverter() != null) {
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -25,6 +25,7 @@
ResponseWriter responseWriter = facesContext.getResponseWriter();
responseWriter.startElement(HtmlConstants.TABLE_ELEMENT, component);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE,
getContainerElementId(facesContext, component), null);
+ responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
"rf-au-tbl", null);
responseWriter.startElement(HtmlConstants.TBODY_ELEMENT, component);
}
@@ -37,6 +38,7 @@
public void encodeItemBegin(FacesContext facesContext, UIComponent component) throws
IOException {
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HtmlConstants.TR_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm",
null);
writer.startElement(HtmlConstants.TD_ELEM, component);
}
@@ -59,10 +61,11 @@
public void encodeItem(FacesContext facesContext, UIComponent component) throws
IOException {
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HtmlConstants.TR_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm",
null);
for (UIComponent child : component.getChildren()) {
if (child instanceof UIColumn) {
encodeItemChildBegin(facesContext, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt
rf-au-fnt rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-fnt
rf-au-inp", null);
child.encodeAll(facesContext);
encodeItemChildEnd(facesContext, component);
}
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -40,18 +40,20 @@
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.context.PartialViewContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
+import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSReference;
import org.richfaces.component.AbstractCalendar;
+import org.richfaces.component.MetaComponentResolver;
import org.richfaces.component.util.HtmlUtil;
import org.richfaces.component.util.MessageUtil;
import org.richfaces.component.util.SelectUtils;
-import org.richfaces.component.util.ViewUtil;
import org.richfaces.event.CurrentDateChangeEvent;
import org.richfaces.utils.CalendarHelper;
@@ -73,7 +75,7 @@
@ResourceDependency(library = "org.richfaces", name =
"calendar-utils.js"),
@ResourceDependency(library = "org.richfaces", name =
"calendar.js"),
@ResourceDependency(library = "org.richfaces", name =
"calendar.ecss") })
-public class CalendarRendererBase extends InputRendererBase {
+public class CalendarRendererBase extends InputRendererBase implements
MetaComponentRenderer {
public static final String CALENDAR_BUNDLE =
"org.richfaces.renderkit.calendar";
@@ -146,9 +148,8 @@
public static final String CALENDAR_DISABLE_ICON_RESOURCE_NAME =
"disabledCalendarIcon.png";
public static final String CURRENT_DATE_INPUT = "InputCurrentDate";
-
-
+ public static final String OPTION_MODE = "mode";
protected static final Map<String, ComponentAttribute>
CALENDAR_INPUT_HANDLER_ATTRIBUTES =
Collections.unmodifiableMap(ComponentAttribute.createMap(
@@ -200,7 +201,7 @@
private static final String MINUTES_VALUE = "minutes";
protected void doDecode(FacesContext context, UIComponent component) {
- if(!(component instanceof AbstractCalendar)) {
+ if (!(component instanceof AbstractCalendar)) {
return;
}
@@ -221,6 +222,15 @@
if (selectedDateString != null) {
calendar.setSubmittedValue(selectedDateString);
}
+
+ if (requestParameterMap.get(component.getClientId(context) + ".ajax")
!= null) {
+ PartialViewContext pvc = context.getPartialViewContext();
+ pvc.getRenderIds().add(
+ component.getClientId(context) +
MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR
+ + AbstractCalendar.DAYSDATA_META_COMPONENT_ID);
+
+ context.renderResponse();
+ }
}
public void renderInputHandlers(FacesContext facesContext, UIComponent component)
throws IOException {
@@ -256,7 +266,7 @@
@Override
public String getInputValue(FacesContext facesContext, UIComponent component) {
- if(!(component instanceof AbstractCalendar)) {
+ if (!(component instanceof AbstractCalendar)) {
return null;
}
@@ -290,12 +300,12 @@
public String getButtonIcon(FacesContext facesContext, UIComponent component) {
boolean disable = (Boolean)component.getAttributes().get("disabled");
String buttonIcon =
(String)component.getAttributes().get("buttonIcon");
- if(disable) {
+ if (disable) {
buttonIcon =
(String)component.getAttributes().get("buttonIconDisabled");
}
if(buttonIcon != null && buttonIcon.trim().length() != 0) {
- buttonIcon = ViewUtil.getResourceURL(buttonIcon, facesContext);
+ buttonIcon = RenderKitUtils.getResourceURL(buttonIcon, facesContext);
} else {
buttonIcon = disable ? CALENDAR_ICON_RESOURCE_NAME:
CALENDAR_ICON_RESOURCE_NAME;
buttonIcon = RenderKitUtils.getResourcePath(facesContext,
"org.richfaces.images",buttonIcon);
@@ -307,11 +317,11 @@
public Object getSelectedDate(FacesContext facesContext, UIComponent component)
throws IOException {
Object returnValue = null;
AbstractCalendar calendar = (AbstractCalendar)component;
- if(calendar.isValid()) {
+ if (calendar.isValid()) {
Date date;
Object value = calendar.getValue();
date = CalendarHelper.getAsDate(facesContext, calendar, value);
- if(date != null) {
+ if (date != null) {
returnValue = formatSelectedDate(calendar.getTimeZone(), date);
}
}
@@ -382,7 +392,6 @@
return ((dayStyleClass != null && dayStyleClass.trim().length() != 0)) ?
new JSReference(dayStyleClass) : null;
}
-
public Map<String, Object> getLabels(FacesContext facesContext,
AbstractCalendar calendar) {
ResourceBundle bundle1 = null;
ResourceBundle bundle2 = null;
@@ -409,11 +418,11 @@
protected Map<String, Object> getCollectedLabels(ResourceBundle [] bundles ,
String[] names) {
Map<String, Object> labels = new HashMap<String, Object>();
- if(bundles != null && names != null) {
+ if (bundles != null && names != null) {
for (String name: names) {
String label = null;
String bundleKey = "RICH_CALENDAR_" + name.toUpperCase() +
"_LABEL";
- for(ResourceBundle bundle: bundles) {
+ for (ResourceBundle bundle: bundles) {
if (bundle != null) {
try {
label = bundle.getString(bundleKey);
@@ -421,7 +430,7 @@
// Current key was not found, ignore this exception;
}
}
- if(label != null) {
+ if (label != null) {
break;
}
}
@@ -478,36 +487,35 @@
int monthMin = calendar.getActualMinimum(Calendar.MONTH);
String [] weekDayLabels =
RenderKitUtils.asArray(calendarComponent.getWeekDayLabels());
- if(weekDayLabels == null) {
+ if (weekDayLabels == null) {
weekDayLabels = dateFormat.getWeekdays();
weekDayLabels = shiftDates(minimum, maximum, weekDayLabels);
}
RenderKitUtils.addToScriptHash(map, WEEK_DAY_LABELS, weekDayLabels);
String [] weekDayLabelsShort =
RenderKitUtils.asArray(calendarComponent.getWeekDayLabelsShort());
- if(weekDayLabelsShort == null) {
+ if (weekDayLabelsShort == null) {
weekDayLabelsShort = dateFormat.getShortWeekdays();
weekDayLabelsShort = shiftDates(minimum, maximum, weekDayLabelsShort);
}
RenderKitUtils.addToScriptHash(map, WEEK_DAY_LABELS_SHORT, weekDayLabelsShort);
String [] monthLabels =
RenderKitUtils.asArray(calendarComponent.getMonthLabels());
- if(monthLabels == null) {
+ if (monthLabels == null) {
monthLabels = dateFormat.getMonths();
monthLabels = shiftDates(monthMin, monthMax, monthLabels);
}
RenderKitUtils.addToScriptHash(map, MONTH_LABELS, monthLabels);
-
String [] monthLabelsShort =
RenderKitUtils.asArray(calendarComponent.getMonthLabelsShort());
- if(monthLabelsShort == null) {
+ if (monthLabelsShort == null) {
monthLabelsShort = dateFormat.getShortMonths();
monthLabelsShort = shiftDates(monthMin, monthMax, monthLabelsShort);
}
RenderKitUtils.addToScriptHash(map, MONTH_LABELS_SHORT, monthLabelsShort);
int minDaysInFirstWeek = calendarComponent.getMinDaysInFirstWeek();
- if(minDaysInFirstWeek == Integer.MIN_VALUE) {
+ if (minDaysInFirstWeek == Integer.MIN_VALUE) {
minDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek();
}
@@ -516,7 +524,7 @@
}
int day = calendarComponent.getFirstWeekDay();
- if(day == Integer.MIN_VALUE) {
+ if (day == Integer.MIN_VALUE) {
day = calendar.getFirstDayOfWeek();
day = calendar.getFirstDayOfWeek() -
calendar.getActualMinimum(Calendar.DAY_OF_WEEK);
}
@@ -526,7 +534,6 @@
} else if (day != Integer.MIN_VALUE) {
facesContext.getExternalContext().log(day + " value of firstWeekDay
attribute is not a legal one for component: " + MessageUtil.getLabel(facesContext,
calendarComponent) + ". Default value was applied.");
}
-
return map;
}
@@ -538,7 +545,7 @@
scriptOptions.addOption(OPTION_READONLY);
scriptOptions.addOption(OPTION_RESET_TIME_ON_DATE_SELECT);
scriptOptions.addOption(OPTION_SHOW_APPLY_BUTTON);
- scriptOptions.addOption(OPTION_POPUP);
+ scriptOptions.addOption(OPTION_POPUP);
scriptOptions.addOption(OPTION_SHOW_INPUT);
scriptOptions.addOption(OPTION_SHOW_HEADER);
scriptOptions.addOption(OPTION_SHOW_FOOTER);
@@ -565,12 +572,13 @@
scriptOptions.addOption("styleClass");
scriptOptions.addOption("style", HtmlUtil.concatStyles("z-index:
" + calendar.getZindex(), calendar.getStyle()));
+ scriptOptions.addOption(OPTION_MODE, calendar.getMode());
return scriptOptions;
}
public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
- if(component instanceof AbstractCalendar) {
+ if (component instanceof AbstractCalendar) {
AbstractCalendar calendar = (AbstractCalendar)component;
JSFunction function = new
JSFunction("RichFaces.ui.Calendar.addLocale",
CalendarHelper.getAsLocale(facesContext, calendar).toString(),
getLocaleOptions(facesContext, calendar));
writer.write(function.toScript());
@@ -579,12 +587,18 @@
}
public void buildCalendarScript(ResponseWriter writer, FacesContext facesContext,
UIComponent component) throws IOException {
- if(component instanceof AbstractCalendar) {
+ 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).toString(), scriptOptions, "");
StringBuffer scriptBuffer = new StringBuffer();
- scriptBuffer.append(function.toScript()).append(".load();");
+ scriptBuffer.append(function.toScript()).append(".load(");
+ Object preload = calendar.getPreload();
+ if (null != preload){
+ scriptBuffer.append(RenderKitUtils.toScriptArgs(preload));
+ }
+
+ scriptBuffer.append(");");
writer.write(scriptBuffer.toString());
}
}
@@ -599,11 +613,11 @@
}
protected Converter setupConverter(FacesContext facesContext, Converter converter,
AbstractCalendar calendar) {
- if(converter == null || calendar == null) {
+ if (converter == null || calendar == null) {
return null;
}
- if(converter instanceof DateTimeConverter) {
+ if (converter instanceof DateTimeConverter) {
DateTimeConverter defaultConverter = (DateTimeConverter) converter;
defaultConverter.setPattern(calendar.getDatePattern());
defaultConverter.setLocale( CalendarHelper.getAsLocale(facesContext,
calendar));
@@ -611,5 +625,21 @@
}
return converter;
}
+
+ public void encodeMetaComponent(FacesContext context, UIComponent component, String
metaComponentId)
+ throws IOException {
+ if (AbstractCalendar.DAYSDATA_META_COMPONENT_ID.equals(metaComponentId)) {
+ Object preload = ((AbstractCalendar) component).getPreload();
+ if (preload != null) {
+ Map<String, Object> dataMap =
AjaxContext.getCurrentInstance(context).getResponseComponentDataMap();
+ dataMap.put(component.getClientId(context), preload);
+ }
+ } else {
+ throw new IllegalArgumentException(metaComponentId);
+ }
+ }
+ public void decodeMetaComponent(FacesContext context, UIComponent component, String
metaComponentId) {
+ throw new UnsupportedOperationException();
+ }
}
\ No newline at end of file
Modified:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/ClientSelectItem.java
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/ClientSelectItem.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/ClientSelectItem.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -22,6 +22,8 @@
package org.richfaces.renderkit;
+import java.io.IOException;
+
import org.ajax4jsf.javascript.ScriptString;
import org.ajax4jsf.javascript.ScriptUtils;
@@ -59,14 +61,23 @@
return convertedValue;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(this.toScript());
+ public void appendScript(Appendable target) throws IOException {
+ target.append(this.toScript());
}
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+
public String toScript() {
return "{ 'id' : " + ScriptUtils.toScript(clientId)
+ " , 'label' : " + ScriptUtils.toScript(label)
+ ", 'value' : " +
ScriptUtils.toScript(convertedValue)
+ "}";
}
+
}
Modified:
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,5 +1,4 @@
-
-.rf-au-inp.rf-au-fnt, .rf-au-opt.rf-au-fnt{
+.rf-au-fnt{
color: '#{richSkin.generalTextColor}';
font-size: '#{richSkin.generalSizeFont}';
font-family: '#{richSkin.generalFamilyFont}';
@@ -72,22 +71,28 @@
min-height: 20px;
}
-.rf-au-opt{
+.rf-au-itm{
+ cursor: default;
padding: 2px;
- white-space: nowrap;
- cursor: default;
- list-style-type: none;
}
-.rf-au-sel{
- padding: 1px;
- width: 100%;
+.rf-au-itm-sel{
background-color: '#{richSkin.headerBackgroundColor}';
border-width: 1px;
border-style: dotted;
border-color: '#{richSkin.generalTextColor}';
+ padding: 1px;
}
+.rf-au-opt{
+ white-space: nowrap;
+ list-style-type: none;
+}
+
+.rf-au-opt-sel{
+ width: 100%;
+}
+
.rf-au-shdw{
border: 0px solid red;
display: inline-block;
@@ -141,4 +146,9 @@
.rf-au-lst-ul{
margin: 0px;
padding: 0px;
+}
+
+.rf-au-tbl{
+ border-spacing: 0px;
+
}
\ No newline at end of file
Modified:
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-11-18
23:14:43 UTC (rev 20108)
@@ -115,8 +115,10 @@
var $super = rf.ui.Autocomplete.$super;
var defaultOptions = {
- selectedItemClass:'rf-au-sel',
- itemClass:'rf-au-opt',
+ itemClass:'rf-au-itm',
+ selectedItemClass:'rf-au-itm-sel',
+ subItemClass:'rf-au-opt',
+ selectedSubItemClass:'rf-au-opt-sel',
autofill:true,
minChars:1,
selectFirst:true,
@@ -244,7 +246,10 @@
if (this.items.length==0 || (!isOffset && this.index == index)) return;
if (this.index!=-1) {
- this.items.eq(this.index).removeClass(this.options.selectedItemClass);
+ var element = this.items.eq(this.index)
+ if
(element.removeClass(this.options.selectedItemClass).hasClass(this.options.subItemClass)){
+ element.removeClass(this.options.selectedSubItemClass);
+ }
}
if (index==undefined) {
@@ -268,7 +273,9 @@
this.index = index;
}
var item = this.items.eq(this.index);
- item.addClass(this.options.selectedItemClass);
+ if (item.addClass(this.options.selectedItemClass).hasClass(this.options.subItemClass))
{
+ item.addClass(this.options.selectedSubItemClass);
+ }
scrollToSelectedItem.call(this);
if (event &&
event.which != rf.KEYS.BACKSPACE &&
Modified:
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
===================================================================
---
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-11-18
23:14:43 UTC (rev 20108)
@@ -261,6 +261,7 @@
selectedDate: null,
currentDate: null,
defaultTime: {hours:12,minutes:0, seconds:0},
+ mode: "client",
hidePopupOnScroll: true
};
@@ -494,6 +495,9 @@
this.scrollElements = null;
//alert(new Date().getTime()-_d.getTime());
+
+ //define isAjaxMode variable
+ "ajax" == this.params.mode ? this.isAjaxMode = true : this.isAjaxMode =
false;
};
@@ -1118,10 +1122,12 @@
}
},
- indexData:function(daysData, isAjaxMode) {
- var dateYear = daysData.startDate.getFullYear();
- var dateMonth = daysData.startDate.getMonth();
+ indexData: function(daysData, isAjaxMode) {
+ var dateYear = daysData.startDate.year;
+ var dateMonth = daysData.startDate.month;
+ daysData.startDate = new Date(dateYear,dateMonth)
+
daysData.index = [];
daysData.index[dateYear+'-'+dateMonth] = 0;
if (isAjaxMode)
@@ -1402,12 +1408,31 @@
var formattedDate =
rf.calendarUtils.formatDate(this.getCurrentDate(),"MM/yyyy");
rf.getDomElement(this.id+'InputCurrentDate').value=formattedDate;
- if (this.submitFunction)
- this.submitFunction.call(this, formattedDate);
+ if (this.isAjaxMode && this.callAjax)
+ this.callAjax.call(this, formattedDate);
else
this.render();
},
+ callAjax: function(calendar, date) {
+ var _this = this;
+ var ajaxSuccess = function (event) {
+ if (event.componentData && event.componentData[_this.id])
+ {
+ var dataDays=event.componentData[_this.id]
+ _this.load(dataDays, true);
+ }
+ }
+ var ajaxError = function (event) {
+ // do nothing
+ }
+ var params = {};
+ params[this.id + ".ajax"] = "1";
+
+ rf.ajax(this.id, null, {parameters: params, error: ajaxError, complete:ajaxSuccess});
+
+ },
+
nextMonth: function() {
this.changeCurrentDateOffset(0,1);
},
Copied:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeEvent.java
(from rev 20107,
trunk/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeEvent.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeEvent.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeEvent.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,67 @@
+/*
+ * 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.event;
+
+import java.util.Collection;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TreeSelectionChangeEvent extends FacesEvent {
+
+ private static final long serialVersionUID = 6292604445872458007L;
+
+ private Collection<Object> oldSelection;
+
+ private Collection<Object> newSelection;
+
+ public TreeSelectionChangeEvent(UIComponent component, Collection<Object>
oldSelection, Collection<Object> newSelection) {
+ super(component);
+
+ this.oldSelection = oldSelection;
+ this.newSelection = newSelection;
+ }
+
+ @Override
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof TreeSelectionChangeListener;
+ }
+
+ @Override
+ public void processListener(FacesListener listener) {
+ ((TreeSelectionChangeListener) listener).processSelectionChange(this);
+ }
+
+ public Collection<Object> getOldSelection() {
+ return oldSelection;
+ }
+
+ public Collection<Object> getNewSelection() {
+ return newSelection;
+ }
+
+}
Copied:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeListener.java
(from rev 20107,
trunk/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeListener.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeListener.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeListener.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.event;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface TreeSelectionChangeListener extends FacesListener {
+
+ public void processSelectionChange(TreeSelectionChangeEvent event) throws
AbortProcessingException;
+
+}
Copied:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeSource.java
(from rev 20107,
trunk/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeSource.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeSource.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionChangeSource.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,34 @@
+/*
+ * 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.event;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface TreeSelectionChangeSource {
+
+ public void addTreeSelectionChangeListener(TreeSelectionChangeListener listener);
+
+ public void removeTreeSelectionChangeListener(TreeSelectionChangeListener listener);
+
+}
Deleted:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,67 +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.event;
-
-import java.util.Collection;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class TreeSelectionEvent extends FacesEvent {
-
- private static final long serialVersionUID = 6292604445872458007L;
-
- private Collection<Object> oldSelection;
-
- private Collection<Object> newSelection;
-
- public TreeSelectionEvent(UIComponent component, Collection<Object>
oldSelection, Collection<Object> newSelection) {
- super(component);
-
- this.oldSelection = oldSelection;
- this.newSelection = newSelection;
- }
-
- @Override
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof TreeSelectionListener;
- }
-
- @Override
- public void processListener(FacesListener listener) {
- ((TreeSelectionListener) listener).processSelection(this);
- }
-
- public Collection<Object> getOldSelection() {
- return oldSelection;
- }
-
- public Collection<Object> getNewSelection() {
- return newSelection;
- }
-
-}
Deleted:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionListener.java
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionListener.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionListener.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,34 +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.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface TreeSelectionListener extends FacesListener {
-
- public void processSelection(TreeSelectionEvent event);
-
-}
Modified:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeToggleListener.java
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeToggleListener.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeToggleListener.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -21,6 +21,7 @@
*/
package org.richfaces.event;
+import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesListener;
/**
@@ -29,6 +30,6 @@
*/
public interface TreeToggleListener extends FacesListener {
- public void processToggle(TreeToggleEvent event);
+ public void processToggle(TreeToggleEvent event) throws AbortProcessingException;
}
Copied:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeToggleSource.java
(from rev 20107,
trunk/ui/iteration/api/src/main/java/org/richfaces/event/TreeToggleSource.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeToggleSource.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/event/TreeToggleSource.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,34 @@
+/*
+ * 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.event;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface TreeToggleSource {
+
+ public void addTreeToggleListener(TreeToggleListener listener);
+
+ public void removeTreeToggleListener(TreeToggleListener listener);
+
+}
Modified:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -28,6 +28,8 @@
import javax.swing.tree.TreeNode;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Iterators;
/**
@@ -99,4 +101,12 @@
public List<TreeNode> getChildrenList() {
return children;
}
+
+ @Override
+ public String toString() {
+ ToStringHelper toStringHelper = Objects.toStringHelper(this);
+ toStringHelper.add("data", data);
+
+ return toStringHelper.toString();
+ }
}
Modified:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -21,8 +21,11 @@
*/
package org.richfaces.model;
-import java.util.Iterator;
+import javax.faces.context.FacesContext;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.Range;
+
/**
* @author Nick Belaevski
*
@@ -36,10 +39,16 @@
public boolean isDataAvailable();
+ public boolean isLeaf();
+
public E getData();
- public Iterator<Object> getChildrenRowKeysIterator(Object rowKey);
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument);
+
+ public void enterNode(DataVisitor visitor);
+ public void exitNode(DataVisitor visitor);
+
public Object getParentRowKey(Object rowKey);
public Object getWrappedData();
Copied:
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java
(from rev 20107,
trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,36 @@
+/*
+ * 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 org.ajax4jsf.model.DataVisitor;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface TreeDataVisitor extends DataVisitor {
+
+ public void enterNode();
+
+ public void exitNode();
+
+}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/config (from rev 20107,
trunk/ui/iteration/ui/src/main/config)
Deleted: branches/RF-8742-1/ui/iteration/ui/src/main/config/faces-config.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/config/faces-config.xml 2010-11-18 18:50:06 UTC (rev
20107)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/config/faces-config.xml 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
-
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
- version="2.0">
-
- <faces-config-extension>
- <cdk:faces-event>
-
<cdk:event-class>org.richfaces.event.TreeToggleEvent</cdk:event-class>
-
<cdk:listener-class>org.richfaces.event.TreeToggleListener</cdk:listener-class>
-
<cdk:source-class>org.richfaces.event.TreeToggleSource</cdk:source-class>
- <cdk:listener-method>processToggle</cdk:listener-method>
- <cdk:tag>
- <cdk:tag-name>treeToggleListener</cdk:tag-name>
- <cdk:tag-type>Facelets</cdk:tag-type>
-
<cdk:handler-class>org.richfaces.view.facelets.TreeToggleListenerHandler</cdk:handler-class>
- <cdk:generate>true</cdk:generate>
- </cdk:tag>
- </cdk:faces-event>
-
- <cdk:faces-event>
-
<cdk:event-class>org.richfaces.event.TreeSelectionChangeEvent</cdk:event-class>
-
<cdk:listener-class>org.richfaces.event.TreeSelectionChangeListener</cdk:listener-class>
-
<cdk:source-class>org.richfaces.event.TreeSelectionChangeSource</cdk:source-class>
-
<cdk:listener-method>processSelectionChange</cdk:listener-method>
- <cdk:tag>
- <cdk:tag-name>treeSelectionChangeListener</cdk:tag-name>
- <cdk:tag-type>Facelets</cdk:tag-type>
-
<cdk:handler-class>org.richfaces.view.facelets.TreeSelectionChangeListenerHandler</cdk:handler-class>
- <cdk:generate>true</cdk:generate>
- </cdk:tag>
- </cdk:faces-event>
- </faces-config-extension>
-
-</faces-config>
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/config/faces-config.xml (from rev
20107, trunk/ui/iteration/ui/src/main/config/faces-config.xml)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/config/faces-config.xml
(rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/config/faces-config.xml 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
+ version="2.0">
+
+ <faces-config-extension>
+ <cdk:faces-event>
+
<cdk:event-class>org.richfaces.event.TreeToggleEvent</cdk:event-class>
+
<cdk:listener-class>org.richfaces.event.TreeToggleListener</cdk:listener-class>
+
<cdk:source-class>org.richfaces.event.TreeToggleSource</cdk:source-class>
+ <cdk:listener-method>processToggle</cdk:listener-method>
+ <cdk:tag>
+ <cdk:tag-name>treeToggleListener</cdk:tag-name>
+ <cdk:tag-type>Facelets</cdk:tag-type>
+
<cdk:handler-class>org.richfaces.view.facelets.TreeToggleListenerHandler</cdk:handler-class>
+ <cdk:generate>true</cdk:generate>
+ </cdk:tag>
+ </cdk:faces-event>
+
+ <cdk:faces-event>
+
<cdk:event-class>org.richfaces.event.TreeSelectionChangeEvent</cdk:event-class>
+
<cdk:listener-class>org.richfaces.event.TreeSelectionChangeListener</cdk:listener-class>
+
<cdk:source-class>org.richfaces.event.TreeSelectionChangeSource</cdk:source-class>
+
<cdk:listener-method>processSelectionChange</cdk:listener-method>
+ <cdk:tag>
+ <cdk:tag-name>treeSelectionChangeListener</cdk:tag-name>
+ <cdk:tag-type>Facelets</cdk:tag-type>
+
<cdk:handler-class>org.richfaces.view.facelets.TreeSelectionChangeListenerHandler</cdk:handler-class>
+ <cdk:generate>true</cdk:generate>
+ </cdk:tag>
+ </cdk:faces-event>
+ </faces-config-extension>
+
+</faces-config>
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -26,35 +26,56 @@
import java.util.HashSet;
import java.util.Iterator;
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
import javax.el.ValueExpression;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
+import javax.faces.component.UpdateModelException;
+import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ExceptionQueuedEvent;
+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;
import org.ajax4jsf.model.Range;
+import org.richfaces.application.MessageFactory;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.appplication.FacesMessages;
import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.component.util.MessageUtil;
import org.richfaces.context.ExtendedVisitContext;
import org.richfaces.context.ExtendedVisitContextMode;
import org.richfaces.convert.SequenceRowKeyConverter;
-import org.richfaces.event.TreeSelectionEvent;
-import org.richfaces.event.TreeSelectionListener;
+import org.richfaces.event.TreeSelectionChangeEvent;
+import org.richfaces.event.TreeSelectionChangeListener;
+import org.richfaces.event.TreeSelectionChangeSource;
+import org.richfaces.event.TreeToggleEvent;
+import org.richfaces.event.TreeToggleListener;
+import org.richfaces.event.TreeToggleSource;
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;
+import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
@@ -65,19 +86,22 @@
@JsfComponent(
type = AbstractTree.COMPONENT_TYPE,
family = AbstractTree.COMPONENT_FAMILY,
- tag = @Tag(name = "tree"),
- renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer")
+ tag = @Tag(name = "tree", handler =
"org.richfaces.view.facelets.TreeHandler"),
+ renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer"),
+ attributes = {"events-props.xml", "core-props.xml",
"i18n-props.xml"}
)
-public abstract class AbstractTree extends UIDataAdaptor implements
MetaComponentResolver, MetaComponentEncoder {
+public abstract class AbstractTree extends UIDataAdaptor implements
MetaComponentResolver, MetaComponentEncoder, TreeSelectionChangeSource, TreeToggleSource
{
public static final String COMPONENT_TYPE = "org.richfaces.Tree";
public static final String COMPONENT_FAMILY = "org.richfaces.Tree";
public static final String SELECTION_META_COMPONENT_ID = "selection";
-
+
+ private static final String DEFAULT_TREE_NODE_CREATED = AbstractTree.class.getName()
+ ":DEFAULT_TREE_NODE_CREATED";
+
private static final class MatchingTreeNodePredicate implements
Predicate<UIComponent> {
-
+
private String type;
public MatchingTreeNodePredicate(String type) {
@@ -89,20 +113,16 @@
if (!(input instanceof AbstractTreeNode)) {
return false;
}
-
- if (!input.isRendered()) {
- return false;
- }
-
+
String nodeType = ((AbstractTreeNode) input).getType();
if (type == null && nodeType == null) {
return true;
}
-
+
return type != null && type.equals(nodeType);
}
};
-
+
private static final Converter ROW_KEY_CONVERTER = new SequenceRowKeyConverter();
/**
@@ -119,6 +139,12 @@
selection
}
+ @Attribute(generate = false, signature = @Signature(returnType = Void.class,
parameters = TreeSelectionChangeEvent.class))
+ private MethodExpression selectionChangeListener;
+
+ @Attribute(generate = false, signature = @Signature(returnType = Void.class,
parameters = TreeToggleListener.class))
+ private MethodExpression toggleListener;
+
public AbstractTree() {
setKeepSaved(true);
setRendererType("org.richfaces.TreeRenderer");
@@ -128,28 +154,53 @@
public abstract boolean isImmediate();
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
+ public abstract String getIconLeaf();
+ public abstract String getIconExpanded();
+
+ public abstract String getIconCollapsed();
+
+ public abstract String getNodeClass();
+
+ public abstract String getHandleClass();
+
+ public abstract String getIconClass();
+
+ public abstract String getLabelClass();
+
+ @Attribute(events = @EventName("nodetoggle"))
+ public abstract String getOnnodetoggle();
+
+ @Attribute(events = @EventName("beforenodetoggle"))
+ public abstract String getOnbeforenodetoggle();
+
+ @Attribute(events = @EventName("selectionchange"))
+ public abstract String getOnselectionchange();
+
+ @Attribute(events = @EventName("beforeselectionchange"))
+ public abstract String getOnbeforeselectionchange();
+
@Attribute(defaultValue = "SwitchType.DEFAULT")
public abstract SwitchType getToggleType();
@Attribute(defaultValue = "SwitchType.client")
public abstract SwitchType getSelectionType();
-
+
public abstract String getNodeType();
+
+ public abstract String getToggleNodeEvent();
- //TODO - move to template
- public abstract String getStyleClass();
-
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
public Collection<Object> getSelection() {
@SuppressWarnings("unchecked")
Collection<Object> selection = (Collection<Object>)
getStateHelper().eval(PropertyKeys.selection);
if (selection == null) {
selection = new HashSet<Object>();
-
+
ValueExpression ve = getValueExpression(PropertyKeys.selection.toString());
if (ve != null) {
ve.setValue(getFacesContext().getELContext(), selection);
@@ -157,14 +208,14 @@
getStateHelper().put(PropertyKeys.selection, selection);
}
}
-
+
return selection;
}
-
+
public void setSelection(Collection<Object> selection) {
getStateHelper().put(PropertyKeys.selection, selection);
}
-
+
@Override
protected ExtendedDataModel<?> createExtendedDataModel() {
ExtendedTreeDataModelImpl<?> model = new
ExtendedTreeDataModelImpl<TreeNode>(new SwingTreeNodeDataModelImpl());
@@ -187,21 +238,40 @@
return converter;
}
- public Iterator<Object> getChildrenRowKeysIterator(FacesContext faces, Object
rowKey) {
- TreeDataModel<?> dataModel = (TreeDataModel<?>)
getExtendedDataModel();
- return dataModel.getChildrenRowKeysIterator(rowKey);
- }
+ public AbstractTreeNode findTreeNodeComponent() {
+ FacesContext facesContext = getFacesContext();
- public AbstractTreeNode findTreeNodeComponent() {
- if (getChildCount() == 0) {
- return null;
+ String nodeType = getNodeType();
+ Iterator<UIComponent> matchingNodes =
Iterators.filter(getChildren().iterator(),
+ new MatchingTreeNodePredicate(nodeType));
+
+ boolean hasNodes = matchingNodes.hasNext();
+ if (hasNodes) {
+ Iterator<UIComponent> renderedTreeNodes =
Iterators.filter(matchingNodes, ComponentPredicates.isRendered());
+ if (renderedTreeNodes.hasNext()) {
+ return (AbstractTreeNode) renderedTreeNodes.next();
+ } else {
+ return null;
+ }
}
- Iterator<UIComponent> iterator = Iterators.filter(getChildren().iterator(),
- new MatchingTreeNodePredicate(getNodeType()));
-
- if (iterator.hasNext()) {
- return (AbstractTreeNode) iterator.next();
+ if (Strings.isNullOrEmpty(nodeType)) {
+ if (getAttributes().put(DEFAULT_TREE_NODE_CREATED, Boolean.TRUE) != null) {
+ return null;
+ }
+
+ Application application = facesContext.getApplication();
+ AbstractTreeNode treeNode = (AbstractTreeNode)
application.createComponent(AbstractTreeNode.COMPONENT_TYPE);
+ treeNode.setId("__defaultTreeNode");
+
+ getChildren().add(treeNode);
+
+ UIComponent text =
application.createComponent(HtmlOutputText.COMPONENT_TYPE);
+ text.setValueExpression("value",
application.getExpressionFactory().createValueExpression(facesContext.getELContext(),
+ "#{" + getVar() + "}", String.class));
+ treeNode.getChildren().add(text);
+
+ return treeNode;
}
return null;
@@ -211,30 +281,85 @@
public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
- if (event instanceof TreeSelectionEvent) {
- TreeSelectionEvent selectionEvent = (TreeSelectionEvent) event;
-
+ if (event instanceof TreeSelectionChangeEvent) {
+ TreeSelectionChangeEvent selectionEvent = (TreeSelectionChangeEvent) event;
+
final Collection<Object> newSelection =
selectionEvent.getNewSelection();
Collection<Object> selectionCollection = getSelection();
-
+
Iterables.removeIf(selectionCollection, new Predicate<Object>() {
public boolean apply(Object input) {
return !newSelection.contains(input);
};
});
-
+
if (!newSelection.isEmpty()) {
Iterables.addAll(selectionCollection, newSelection);
}
+ } else if (event instanceof TreeToggleEvent) {
+ TreeToggleEvent toggleEvent = (TreeToggleEvent) event;
+ AbstractTreeNode treeNodeComponent = findTreeNodeComponent();
+
+ boolean newExpandedValue = toggleEvent.isExpanded();
+
+ FacesContext context = getFacesContext();
+ ValueExpression expression =
getValueExpression(AbstractTreeNode.PropertyKeys.expanded.toString());
+ if (expression != null) {
+ ELContext elContext = context.getELContext();
+ Exception caught = null;
+ FacesMessage message = null;
+ try {
+ expression.setValue(elContext, newExpandedValue);
+ } catch (ELException e) {
+ caught = e;
+ String messageStr = e.getMessage();
+ Throwable result = e.getCause();
+ while (null != result &&
+ result.getClass().isAssignableFrom(ELException.class)) {
+ messageStr = result.getMessage();
+ result = result.getCause();
+ }
+ if (null == messageStr) {
+ MessageFactory messageFactory =
ServiceTracker.getService(MessageFactory.class);
+ message =
+ messageFactory.createMessage(context,
FacesMessages.UIINPUT_UPDATE,
+ MessageUtil.getLabel(context, this));
+ } else {
+ message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ messageStr,
+ messageStr);
+ }
+ } catch (Exception e) {
+ caught = e;
+ MessageFactory messageFactory =
ServiceTracker.getService(MessageFactory.class);
+ message =
+ messageFactory.createMessage(context,
FacesMessages.UIINPUT_UPDATE,
+ MessageUtil.getLabel(context, this));
+ }
+ if (caught != null) {
+ assert(message != null);
+ UpdateModelException toQueue = new UpdateModelException(message,
caught);
+ ExceptionQueuedEventContext eventContext =
+ new ExceptionQueuedEventContext(context,
+ toQueue,
+ this,
+ PhaseId.UPDATE_MODEL_VALUES);
+ context.getApplication().publishEvent(context,
+ ExceptionQueuedEvent.class,
+ eventContext);
+ }
+ } else {
+ treeNodeComponent.setExpanded(newExpandedValue);
+ }
}
}
-
+
@Override
protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback
callback) {
if (visitContext instanceof ExtendedVisitContext) {
ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext)
visitContext;
-
+
if (ExtendedVisitContextMode.RENDER == extendedVisitContext.getVisitMode())
{
VisitResult result =
extendedVisitContext.invokeMetaComponentVisitCallback(this, callback,
SELECTION_META_COMPONENT_ID);
if (result != VisitResult.ACCEPT) {
@@ -245,7 +370,7 @@
return super.visitFixedChildren(visitContext, callback);
}
-
+
void decodeMetaComponent(FacesContext context, String metaComponentId) {
((MetaComponentRenderer) getRenderer(context)).decodeMetaComponent(context, this,
metaComponentId);
}
@@ -253,15 +378,15 @@
public void encodeMetaComponent(FacesContext context, String metaComponentId) throws
IOException {
((MetaComponentRenderer) getRenderer(context)).encodeMetaComponent(context, this,
metaComponentId);
}
-
+
public String resolveClientId(FacesContext facesContext, UIComponent
contextComponent, String metaComponentId) {
if (SELECTION_META_COMPONENT_ID.equals(metaComponentId)) {
return getClientId(facesContext) +
MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
}
-
+
return null;
}
-
+
public String substituteUnresolvedClientId(FacesContext facesContext, UIComponent
contextComponent,
String metaComponentId) {
@@ -277,35 +402,58 @@
return Iterators.<UIComponent>emptyIterator();
}
}
-
+
@Override
public DataComponentState getComponentState() {
return new TreeComponentState();
}
- public void addSelectionListener(TreeSelectionListener listener) {
+ public void addTreeSelectionChangeListener(TreeSelectionChangeListener listener) {
addFacesListener(listener);
}
- public TreeSelectionListener[] getSelectionListeners() {
- return (TreeSelectionListener[]) getFacesListeners(TreeSelectionListener.class);
+ @Attribute(hidden = true)
+ public TreeSelectionChangeListener[] getTreeSelectionChangeListeners() {
+ return (TreeSelectionChangeListener[])
getFacesListeners(TreeSelectionChangeListener.class);
}
-
- public void removeSelectionListener(TreeSelectionListener listener) {
+
+ public void removeTreeSelectionChangeListener(TreeSelectionChangeListener listener)
{
removeFacesListener(listener);
}
+ public void addTreeToggleListener(TreeToggleListener listener) {
+ addFacesListener(listener);
+ }
+
@Attribute(hidden = true)
+ public TreeToggleListener[] getTreeToggleListeners() {
+ return (TreeToggleListener[]) getFacesListeners(TreeToggleListener.class);
+ }
+
+ public void removeTreeToggleListener(TreeToggleListener listener) {
+ removeFacesListener(listener);
+ }
+
+ @Attribute(hidden = true)
public boolean isExpanded() {
if (getRowKey() == null) {
return true;
}
-
+
AbstractTreeNode treeNode = findTreeNodeComponent();
if (treeNode == null) {
return false;
}
-
+
return treeNode.isExpanded();
}
+
+ @Attribute(hidden = true)
+ public boolean isLeaf() {
+ if (getRowKey() == null) {
+ return false;
+ }
+
+ return ((TreeDataModel<?>) getExtendedDataModel()).isLeaf();
+ }
}
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,36 +23,30 @@
import java.io.IOException;
-import javax.el.ELContext;
-import javax.el.ELException;
+import javax.el.MethodExpression;
import javax.el.ValueExpression;
-import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
-import javax.faces.component.UpdateModelException;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ExceptionQueuedEvent;
-import javax.faces.event.ExceptionQueuedEventContext;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
import org.ajax4jsf.component.IterationStateHolder;
-import org.richfaces.application.MessageFactory;
-import org.richfaces.application.ServiceTracker;
-import org.richfaces.appplication.FacesMessages;
import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.component.util.MessageUtil;
import org.richfaces.context.ExtendedVisitContext;
import org.richfaces.context.ExtendedVisitContextMode;
import org.richfaces.event.TreeToggleEvent;
import org.richfaces.event.TreeToggleListener;
+import org.richfaces.event.TreeToggleSource;
import org.richfaces.renderkit.MetaComponentRenderer;
/**
@@ -62,10 +56,11 @@
@JsfComponent(
type = AbstractTreeNode.COMPONENT_TYPE,
family = AbstractTreeNode.COMPONENT_FAMILY,
- tag = @Tag(name = "treeNode"),
- renderer = @JsfRenderer(type = "org.richfaces.TreeNodeRenderer")
+ tag = @Tag(name = "treeNode", handler =
"org.richfaces.view.facelets.TreeNodeHandler"),
+ renderer = @JsfRenderer(type = "org.richfaces.TreeNodeRenderer"),
+ attributes = {"events-props.xml", "core-props.xml",
"i18n-props.xml"}
)
-public abstract class AbstractTreeNode extends UIComponentBase implements
MetaComponentResolver, MetaComponentEncoder, IterationStateHolder {
+public abstract class AbstractTreeNode extends UIComponentBase implements
MetaComponentResolver, MetaComponentEncoder, IterationStateHolder, TreeToggleSource {
public static final String COMPONENT_TYPE = "org.richfaces.TreeNode";
@@ -73,10 +68,13 @@
public static final String SUBTREE_META_COMPONENT_ID = "subtree";
- private enum PropertyKeys {
+ enum PropertyKeys {
expanded
}
+ @Attribute(generate = false, signature = @Signature(returnType = Void.class,
parameters = TreeToggleEvent.class))
+ private MethodExpression toggleListener;
+
public AbstractTreeNode() {
setRendererType("org.richfaces.TreeNodeRenderer");
}
@@ -91,9 +89,24 @@
public abstract String getType();
- //TODO - move to template
- public abstract String getStyleClass();
+ public abstract String getIconLeaf();
+ public abstract String getIconExpanded();
+
+ public abstract String getIconCollapsed();
+
+ public abstract String getHandleClass();
+
+ public abstract String getIconClass();
+
+ public abstract String getLabelClass();
+
+ @Attribute(events = @EventName("toggle"))
+ public abstract String getOntoggle();
+
+ @Attribute(events = @EventName("beforetoggle"))
+ public abstract String getOnbeforetoggle();
+
protected Boolean getLocalExpandedValue(FacesContext facesContext) {
return (Boolean) getStateHelper().get(PropertyKeys.expanded);
}
@@ -152,69 +165,20 @@
if (event instanceof TreeToggleEvent) {
TreeToggleEvent toggleEvent = (TreeToggleEvent) event;
- boolean newExpandedValue = toggleEvent.isExpanded();
-
- FacesContext context = getFacesContext();
- ValueExpression expression =
getValueExpression(PropertyKeys.expanded.toString());
- if (expression != null) {
- ELContext elContext = context.getELContext();
- Exception caught = null;
- FacesMessage message = null;
- try {
- expression.setValue(elContext, newExpandedValue);
- } catch (ELException e) {
- caught = e;
- String messageStr = e.getMessage();
- Throwable result = e.getCause();
- while (null != result &&
- result.getClass().isAssignableFrom(ELException.class)) {
- messageStr = result.getMessage();
- result = result.getCause();
- }
- if (null == messageStr) {
- MessageFactory messageFactory =
ServiceTracker.getService(MessageFactory.class);
- message =
- messageFactory.createMessage(context,
FacesMessages.UIINPUT_UPDATE,
- MessageUtil.getLabel(context, this));
- } else {
- message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
- messageStr,
- messageStr);
- }
- } catch (Exception e) {
- caught = e;
- MessageFactory messageFactory =
ServiceTracker.getService(MessageFactory.class);
- message =
- messageFactory.createMessage(context,
FacesMessages.UIINPUT_UPDATE,
- MessageUtil.getLabel(context, this));
- }
- if (caught != null) {
- assert(message != null);
- UpdateModelException toQueue = new UpdateModelException(message,
caught);
- ExceptionQueuedEventContext eventContext =
- new ExceptionQueuedEventContext(context,
- toQueue,
- this,
- PhaseId.UPDATE_MODEL_VALUES);
- context.getApplication().publishEvent(context,
- ExceptionQueuedEvent.class,
- eventContext);
- }
- } else {
- setExpanded(newExpandedValue);
- }
+ new TreeToggleEvent(findTreeComponent(), toggleEvent.isExpanded()).queue();
}
}
- public void addToggleListener(TreeToggleListener listener) {
+ public void addTreeToggleListener(TreeToggleListener listener) {
addFacesListener(listener);
}
+ @Attribute(hidden = true)
public TreeToggleListener[] getTreeToggleListeners() {
return (TreeToggleListener[]) getFacesListeners(TreeToggleListener.class);
}
- public void removeToggleListener(TreeToggleListener listener) {
+ public void removeTreeToggleListener(TreeToggleListener listener) {
removeFacesListener(listener);
}
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/TreeRange.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/TreeRange.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/TreeRange.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -50,8 +50,7 @@
return true;
}
- tree.setRowKey(facesContext, rowKey);
- return tree.isExpanded();
+ return !tree.isLeaf() && tree.isExpanded();
}
}
Copied:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeSelectionChangeListener.java
(from rev 20107,
trunk/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeSelectionChangeListener.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeSelectionChangeListener.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeSelectionChangeListener.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -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.event;
+
+import javax.el.MethodExpression;
+import javax.faces.event.AbortProcessingException;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class MethodExpressionTreeSelectionChangeListener extends
MethodExpressionEventListener implements TreeSelectionChangeListener {
+
+ public MethodExpressionTreeSelectionChangeListener() {
+ super();
+ }
+
+ public MethodExpressionTreeSelectionChangeListener(MethodExpression
methodExprOneArg,
+ MethodExpression methodExprZeroArg) {
+ super(methodExprOneArg, methodExprZeroArg);
+ }
+
+ public MethodExpressionTreeSelectionChangeListener(MethodExpression
methodExpressionOneArg) {
+ super(methodExpressionOneArg);
+ }
+
+ public void processSelectionChange(TreeSelectionChangeEvent event) throws
AbortProcessingException {
+ processEvent(event);
+ }
+
+}
Copied:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeToggleListener.java
(from rev 20107,
trunk/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeToggleListener.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeToggleListener.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/event/MethodExpressionTreeToggleListener.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -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.event;
+
+import javax.el.MethodExpression;
+import javax.faces.event.AbortProcessingException;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class MethodExpressionTreeToggleListener extends MethodExpressionEventListener
implements TreeToggleListener {
+
+ public MethodExpressionTreeToggleListener() {
+ super();
+ }
+
+ public MethodExpressionTreeToggleListener(MethodExpression methodExprOneArg,
MethodExpression methodExprZeroArg) {
+ super(methodExprOneArg, methodExprZeroArg);
+ }
+
+ public MethodExpressionTreeToggleListener(MethodExpression methodExpressionOneArg) {
+ super(methodExpressionOneArg);
+ }
+
+ public void processToggle(TreeToggleEvent event) throws AbortProcessingException {
+ processEvent(event);
+ }
+
+}
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -21,15 +21,11 @@
*/
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
@@ -52,10 +48,6 @@
return wrappedModel.getData();
}
- public Iterator<Object> getChildrenRowKeysIterator(Object rowKey) {
- return wrappedModel.getChildrenRowKeysIterator(rowKey);
- }
-
public Object getParentRowKey(Object rowKey) {
throw new UnsupportedOperationException();
}
@@ -70,27 +62,11 @@
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);
- }
+ wrappedModel.enterNode(visitor);
+ wrappedModel.walk(context, visitor, range, argument);
+ wrappedModel.exitNode(visitor);
}
@Override
@@ -127,5 +103,31 @@
wrappedModel.setWrappedData(data);
}
+ /* (non-Javadoc)
+ * @see org.richfaces.model.TreeDataModel#isLeaf()
+ */
+ public boolean isLeaf() {
+ // TODO Auto-generated method stub
+ return wrappedModel.isLeaf();
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.model.TreeDataModel#enterNode(org.ajax4jsf.model.DataVisitor)
+ */
+ public void enterNode(DataVisitor visitor) {
+ // TODO Auto-generated method stub
+
+ wrappedModel.enterNode(visitor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.model.TreeDataModel#exitNode(org.ajax4jsf.model.DataVisitor)
+ */
+ public void exitNode(DataVisitor visitor) {
+ // TODO Auto-generated method stub
+
+ wrappedModel.exitNode(visitor);
+ }
+
+
}
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -49,6 +49,24 @@
return new SequenceRowKey<T>(ObjectArrays.concat(simpleKeys, segment));
}
+ public T getLastKeySegment() {
+ if (simpleKeys.length == 0) {
+ return null;
+ }
+
+ return simpleKeys[simpleKeys.length - 1];
+ }
+
+ public SequenceRowKey<T> getParent() {
+ if (simpleKeys.length == 0) {
+ return null;
+ }
+
+ T[] parentSimpleKeys = ObjectArrays.newArray(simpleKeys, simpleKeys.length - 1);
+ System.arraycopy(simpleKeys, 0, parentSimpleKeys, 0, parentSimpleKeys.length);
+ return new SequenceRowKey<T>(parentSimpleKeys);
+ }
+
@Override
public int hashCode() {
final int prime = 31;
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKeyIterator.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKeyIterator.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKeyIterator.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -23,25 +23,29 @@
import java.util.Iterator;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
/**
* @author Nick Belaevski
*
*/
-public class SequenceRowKeyIterator<T> implements Iterator<Object> {
+public abstract class SequenceRowKeyIterator<K, T> implements
Iterator<Object> {
- private int counter = 0;
+ private SequenceRowKey<K> baseKey;
- private SequenceRowKey<Integer> baseKey;
-
private Iterator<T> itr;
private T element;
- private SequenceRowKey<Integer> elementKey;
+ private SequenceRowKey<K> elementKey;
+
+ private T baseElement;
- public SequenceRowKeyIterator(SequenceRowKey<Integer> baseKey,
Iterator<T> itr) {
+ public SequenceRowKeyIterator(SequenceRowKey<K> baseKey, T baseElement,
Iterator<T> itr) {
super();
this.baseKey = baseKey;
+ this.baseElement = baseElement;
this.itr = itr;
}
@@ -49,10 +53,17 @@
return itr.hasNext();
}
+ protected abstract K nextKey();
+
public Object next() {
element = itr.next();
- elementKey = baseKey.append(counter++);
+ if (baseKey != null) {
+ elementKey = baseKey.append(nextKey());
+ } else {
+ elementKey = new SequenceRowKey<K>(nextKey());
+ }
+
return elementKey;
}
@@ -60,7 +71,15 @@
return element;
}
- public SequenceRowKey<Integer> getElementKey() {
+ public SequenceRowKey<K> getBaseKey() {
+ return baseKey;
+ }
+
+ public T getBaseElement() {
+ return baseElement;
+ }
+
+ public SequenceRowKey<K> getElementKey() {
return elementKey;
}
@@ -68,4 +87,12 @@
throw new UnsupportedOperationException();
}
+ @Override
+ public String toString() {
+ ToStringHelper helper = Objects.toStringHelper(this);
+
+ helper.add("element", element).add("elementKey",
elementKey);
+
+ return helper.toString();
+ }
}
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -36,13 +36,46 @@
* @author Nick Belaevski
*
*/
-public class SwingTreeNodeDataModelImpl implements TreeDataModel<TreeNode> {
+public class SwingTreeNodeDataModelImpl extends TreeSequenceKeyModel<Integer,
TreeNode> {
/**
* @author Nick Belaevski
*
*/
+ private static final class SwingTreeNodeRowKeyIterator extends
SequenceRowKeyIterator<Integer, TreeNode> {
+
+ private int counter = 0;
+
+ /**
+ * @param baseKey
+ * @param baseElement
+ * @param itr
+ */
+ private SwingTreeNodeRowKeyIterator(SequenceRowKey<Integer> baseKey,
TreeNode baseElement,
+ Iterator<TreeNode> itr) {
+ super(baseKey, baseElement, itr);
+ }
+
+ @Override
+ protected Integer nextKey() {
+ return counter++;
+ }
+ }
+
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
private final class FakeRootNode implements TreeNode {
+
+ private Collection<TreeNode> wrappedData;
+
+ public FakeRootNode(Collection<TreeNode> wrappedData) {
+ super();
+ this.wrappedData = wrappedData;
+ }
+
public boolean isLeaf() {
return !wrappedData.isEmpty();
}
@@ -86,21 +119,13 @@
return Iterators.asEnumeration(wrappedData.iterator());
}
+
+ public Collection<TreeNode> getWrappedData() {
+ return wrappedData;
+ }
}
- 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);
-
+ private Iterator<TreeNode> safeGetChildren(SequenceRowKey<Integer> key,
TreeNode treeNode) {
if (treeNode == null) {
return Iterators.emptyIterator();
}
@@ -108,72 +133,48 @@
return Iterators.forEnumeration((Enumeration<TreeNode>)
treeNode.children());
}
- private TreeNode findNode(SequenceRowKey<Integer> compositeKey) {
- if (compositeKey == null) {
- return null;
+
+ public Object getParentRowKey(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLeaf() {
+ if (!isDataAvailable()) {
+ throw new IllegalStateException();
}
- TreeNode result = fakeRootNode;
+ TreeNode treeNode = getData();
- for (Integer simpleKey : compositeKey.getSimpleKeys()) {
- int idx = simpleKey.intValue();
-
- if (idx < result.getChildCount()) {
- result = result.getChildAt(idx);
- } else {
- result = null;
- break;
- }
- }
-
- return result;
+ return !treeNode.getAllowsChildren() || treeNode.isLeaf();
}
-
- public void setRowKey(Object key) {
- this.selectedRowKey = (SequenceRowKey<Integer>) key;
- this.selectedNode = findNode(selectedRowKey);
- }
- public Object getRowKey() {
- return selectedRowKey;
+ public void setWrappedData(Object data) {
+ setRootNode(new FakeRootNode((Collection<TreeNode>) data));
}
-
- private SequenceRowKey<Integer> castKeyAndWrapNull(Object rowKey) {
- if (rowKey == null) {
- return EMPTY_SEQUENCE_ROW_KEY;
+
+ public Collection<TreeNode> getWrappedData() {
+ FakeRootNode rootNode = (FakeRootNode) getRootNode();
+ if (rootNode == null) {
+ return null;
}
-
- return (SequenceRowKey<Integer>) rowKey;
+ return rootNode.getWrappedData();
}
-
- 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();
+ @Override
+ protected TreeNode findChild(TreeNode parent, Integer simpleKey) {
+ int idx = simpleKey.intValue();
+ if (idx >= 0 && idx < parent.getChildCount()) {
+ return parent.getChildAt(idx);
}
- return selectedNode;
+ return null;
}
- public Object getParentRowKey(Object rowKey) {
- throw new UnsupportedOperationException();
- }
- public boolean isDataAvailable() {
- return selectedNode != null;
+ @Override
+ protected SequenceRowKeyIterator<Integer, TreeNode>
createChildrenIterator(SequenceRowKey<Integer> baseKey,
+ TreeNode value) {
+
+ return new SwingTreeNodeRowKeyIterator(baseKey, value, safeGetChildren(baseKey,
value));
}
-
- public Object getWrappedData() {
- return wrappedData;
- }
-
- public void setWrappedData(Object wrappedData) {
- this.wrappedData = (Collection<TreeNode>) wrappedData;
- }
}
Copied:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java
(from rev 20107,
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,168 @@
+/*
+ * 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 java.util.LinkedList;
+import java.util.ListIterator;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.Range;
+import org.richfaces.component.TreeRange;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class TreeSequenceKeyModel<K, V> implements TreeDataModel<V>
{
+
+ private V rootNode;
+
+ private V currentData;
+
+ private SequenceRowKey<K> currentRowKey;
+
+ private LinkedList<SequenceRowKeyIterator<K, V>> keysStack = new
LinkedList<SequenceRowKeyIterator<K, V>>();
+
+ public SequenceRowKey<K> getRowKey() {
+ return currentRowKey;
+ }
+
+ public void setRowKey(Object rowKey) {
+ this.currentRowKey = (SequenceRowKey<K>) rowKey;
+ this.currentData = findData(currentRowKey);
+ }
+
+ public boolean isDataAvailable() {
+ return currentRowKey == null || currentData != null;
+ }
+
+ public abstract boolean isLeaf();
+
+ public V getData() {
+ if (!isDataAvailable()) {
+ throw new IllegalArgumentException();
+ }
+
+ return currentData;
+ }
+
+ protected boolean isRootNodeKey(SequenceRowKey<K> key) {
+ return key == null || key.getLastKeySegment() == null;
+ }
+
+ protected V findData(SequenceRowKey<K> key) {
+ if (key == null) {
+ return rootNode;
+ }
+
+ if (!keysStack.isEmpty()) {
+ ListIterator<SequenceRowKeyIterator<K, V>> listIterator =
keysStack.listIterator(keysStack.size());
+
+ while (listIterator.hasPrevious()) {
+ SequenceRowKeyIterator<K, V> previous = listIterator.previous();
+
+ V baseNode = null;
+
+ SequenceRowKey<K> baseKey = previous.getBaseKey();
+ if (isRootNodeKey(baseKey) && isRootNodeKey(key.getParent())) {
+ baseNode = rootNode;
+ } else if (baseKey.equals(key.getParent())) {
+ baseNode = previous.getBaseElement();
+ }
+
+ if (baseNode == null) {
+ continue;
+ }
+
+ return findChild(baseNode, key.getLastKeySegment());
+ }
+ }
+
+ V result = rootNode;
+
+ for (K simpleKey : key.getSimpleKeys()) {
+ result = findChild(result, simpleKey);
+
+ if (result == null) {
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ protected abstract V findChild(V parent, K simpleKey);
+
+ protected abstract SequenceRowKeyIterator<K, V>
createChildrenIterator(SequenceRowKey<K> baseKey, V value);
+
+ public void enterNode(DataVisitor visitor) {
+ SequenceRowKey<K> sequenceKey = getRowKey();
+ V data = findData(sequenceKey);
+
+ keysStack.addLast(createChildrenIterator(sequenceKey, data));
+
+ if (visitor instanceof TreeDataVisitor) {
+ ((TreeDataVisitor) visitor).enterNode();
+ }
+ }
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) {
+ if (getRowKey() != null) {
+ visitor.process(context, getRowKey(), argument);
+ }
+
+ TreeRange treeRange = (TreeRange) range;
+
+ if (treeRange.shouldIterateChildren(getRowKey())) {
+ enterNode(visitor);
+ Iterator<Object> keysIterator = keysStack.getLast();
+ while (keysIterator.hasNext()) {
+ Object key = (Object) keysIterator.next();
+ setRowKey(key);
+ walk(context, visitor, range, argument);
+ }
+ exitNode(visitor);
+ }
+ }
+
+ public void exitNode(DataVisitor visitor) {
+ if (visitor instanceof TreeDataVisitor) {
+ ((TreeDataVisitor) visitor).exitNode();
+ }
+
+ keysStack.removeLast();
+ }
+
+ public abstract Object getParentRowKey(Object rowKey);
+
+ protected V getRootNode() {
+ return rootNode;
+ }
+
+ protected void setRootNode(V rootNode) {
+ this.rootNode = rootNode;
+ }
+
+}
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -321,9 +321,9 @@
function.addParameter(options);
- StringBuffer buffer = new StringBuffer();
- function.appendScript(buffer);
- definition.addToBody(buffer);
+ StringBuilder sb = new StringBuilder();
+ function.appendScriptToStringBuilder(sb);
+ definition.addToBody(sb);
return definition;
}
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -22,113 +22,139 @@
package org.richfaces.renderkit;
import java.io.IOException;
-import java.util.Iterator;
import java.util.LinkedList;
+import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.model.DataVisitResult;
import org.richfaces.component.AbstractTree;
import org.richfaces.component.AbstractTreeNode;
-import org.richfaces.component.TreeRange;
import org.richfaces.component.util.HtmlUtil;
-import org.richfaces.renderkit.TreeRendererBase.NodeState;
+import org.richfaces.model.TreeDataVisitor;
import org.richfaces.renderkit.TreeRendererBase.QueuedData;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.UnmodifiableIterator;
+abstract class TreeEncoderBase implements TreeDataVisitor {
-abstract class TreeEncoderBase {
+ static final String TREE_NODE_STATE_ATTRIBUTE = "__treeNodeState";
- private static final String TREE_NODE_HANDLE_CLASS_ATTRIBUTE =
"__treeNodeHandleClass";
-
- private static final String TREE_NODE_ICON_CLASS_ATTRIBUTE =
"__treeNodeIconClass";
-
protected final FacesContext context;
-
+
protected final ResponseWriter responseWriter;
-
+
protected final AbstractTree tree;
- private TreeRange treeRange;
-
- private LinkedList<QueuedData> queuedData = new
LinkedList<QueuedData>();
-
+ private LinkedList<QueuedData> queuedDataList = new
LinkedList<QueuedData>();
+
+ private QueuedData queuedData;
+
public TreeEncoderBase(FacesContext context, AbstractTree tree) {
super();
this.context = context;
this.responseWriter = context.getResponseWriter();
this.tree = tree;
-
- this.treeRange = (TreeRange) tree.getComponentState().getRange();
}
- protected void encodeTree(Iterator<Object> childrenIterator) throws IOException
{
- Predicate<Object> renderedTreeNodeKeyPredicate = new
Predicate<Object>() {
- public boolean apply(Object input) {
- tree.setRowKey(input);
-
- if (!tree.isRowAvailable()) {
- return false;
+ protected void encodeTree() throws IOException {
+ tree.walk(context, this, null);
+ }
+
+ protected void flushNode() throws IOException {
+ if (!queuedData.isEncoded()) {
+ tree.setRowKey(context, queuedData.getRowKey());
+
+ TreeNodeState state;
+ if (tree.isLeaf()) {
+ state = TreeNodeState.leaf;
+ } else {
+ if (queuedData.isVisited()) {
+ state = TreeNodeState.leaf;
+ } else {
+ state = TreeNodeState.collapsed;
}
-
- return tree.findTreeNodeComponent() != null;
}
- };
+
+ writeTreeNodeStartElement(state);
+ }
+
+ writeTreeNodeEndElement();
+ }
+
+ protected void flushParentNode() throws IOException {
+ if (queuedDataList.isEmpty()) {
+ return;
+ }
- UnmodifiableIterator<Object> filteredIterator =
Iterators.filter(childrenIterator, renderedTreeNodeKeyPredicate);
- while (filteredIterator.hasNext()) {
- Object rowKey = filteredIterator.next();
+ QueuedData data = queuedDataList.getLast();
+ if (!data.isEncoded()) {
+ data.setEncoded(true);
+ tree.setRowKey(context, data.getRowKey());
- encodeTreeNode(rowKey, !filteredIterator.hasNext());
+ writeTreeNodeStartElement(tree.isExpanded() ? TreeNodeState.expanded :
TreeNodeState.collapsed);
}
}
- protected void encodeTreeNode(Object rowKey, boolean isLastNode) throws IOException
{
- if (!queuedData.isEmpty()) {
- QueuedData data = queuedData.getLast();
- if (!data.isEncoded()) {
- tree.setRowKey(context, data.getRowKey());
-
- writeTreeNodeStartElement(data.isExpanded() ? NodeState.expanded :
NodeState.collapsed, data.isLastNode());
-
- data.setEncoded(true);
+ public void enterNode() {
+ if (queuedData != null) {
+ queuedData.makeVisited();
+ queuedDataList.add(queuedData);
+ queuedData = null;
+ }
+ }
+
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument)
{
+ try {
+ if (queuedData != null) {
+ flushNode();
+ queuedData = null;
+ } else {
+ flushParentNode();
}
+ } catch (IOException e) {
+ throw new FacesException(e.getMessage(), e);
}
-
- tree.setRowKey(context, rowKey);
- boolean expanded = tree.isExpanded();
- queuedData.add(new QueuedData(rowKey, isLastNode, expanded));
-
- boolean iterateChildren = treeRange.shouldIterateChildren(rowKey);
-
- if (iterateChildren) {
- encodeTree(tree.getChildrenRowKeysIterator(context, rowKey));
+ if (rowKey != null) {
+ tree.setRowKey(context, rowKey);
+
+ if (tree.isRowAvailable() && tree.findTreeNodeComponent() != null) {
+ queuedData = new QueuedData(rowKey);
+ }
}
- QueuedData data = queuedData.removeLast();
- if (!data.isEncoded()) {
- NodeState nodeState = iterateChildren ? NodeState.leaf :
NodeState.collapsed;
- writeTreeNodeStartElement(nodeState, data.isLastNode());
+ return DataVisitResult.CONTINUE;
+ }
+
+ public void exitNode() {
+ try {
+ if (queuedData != null) {
+ flushNode();
+ queuedData = null;
+ }
+
+ if (!queuedDataList.isEmpty()) {
+ queuedData = queuedDataList.removeLast();
+ }
+ } catch (IOException e) {
+ throw new FacesException(e.getMessage(), e);
}
-
- writeTreeNodeEndElement();
}
-
- protected void writeTreeNodeStartElement(NodeState nodeState, boolean isLast) throws
IOException {
+
+ protected void writeTreeNodeStartElement(TreeNodeState nodeState) throws IOException
{
AbstractTreeNode treeNodeComponent = tree.findTreeNodeComponent();
- context.getAttributes().put(TREE_NODE_HANDLE_CLASS_ATTRIBUTE,
nodeState.getHandleClass());
- context.getAttributes().put(TREE_NODE_ICON_CLASS_ATTRIBUTE,
nodeState.getIconClass());
-
+ context.getAttributes().put(TREE_NODE_STATE_ATTRIBUTE, nodeState);
+
responseWriter.startElement(HtmlConstants.DIV_ELEM, tree);
responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses("rf-tr-nd", isLast ?
"rf-tr-nd-last" : null, nodeState.getNodeClass()),
+ HtmlUtil.concatClasses("rf-tr-nd", nodeState.getNodeClass()),
null);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE,
treeNodeComponent.getClientId(context), null);
-
+
+ emitClientToggleEvent(treeNodeComponent, nodeState);
treeNodeComponent.encodeAll(context);
}
@@ -137,5 +163,16 @@
}
public abstract void encode() throws IOException;
-
+
+ private void emitClientToggleEvent(AbstractTreeNode treeNode, TreeNodeState
nodeState) {
+ if
(treeNode.getClientId(context).equals(context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_ATTRIBUTE)))
{
+ TreeNodeState submittedState = ((Boolean)
(context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_STATE_ATTRIBUTE)))
+ ? TreeNodeState.expanded : TreeNodeState.collapsed;
+
+ if (submittedState == nodeState || nodeState == TreeNodeState.leaf) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ajaxContext.appendOncomplete(new
JSFunction("RichFaces.ui.TreeNode.emitToggleEvent",
treeNode.getClientId(context)));
+ }
+ }
+ }
}
\ No newline at end of file
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -38,7 +38,8 @@
public void encode() throws java.io.IOException {
Object initialRowKey = tree.getRowKey();
try {
- encodeTree(tree.getChildrenRowKeysIterator(context, null));
+ tree.setRowKey(context, null);
+ encodeTree();
} finally {
try {
tree.setRowKey(context, initialRowKey);
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -22,6 +22,7 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Collections;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialResponseWriter;
@@ -58,23 +59,30 @@
PartialResponseWriter prw =
context.getPartialViewContext().getPartialResponseWriter();
prw.startUpdate(elementId);
+ Object clientEventHandlers = null;
Object initialRowKey = tree.getRowKey();
try {
+ TreeRenderingContext.create(context, tree);
+ tree.setRowKey(context, rowKey);
+
+ encodeTree();
- encodeTreeNode(rowKey, true);
-
prw.endUpdate();
+ clientEventHandlers = TreeRenderingContext.get(context).getHandlers();
} finally {
try {
tree.setRowKey(context, initialRowKey);
} catch (Exception e) {
TreeRendererBase.LOGGER.error(e.getMessage(), e);
}
+
+ TreeRenderingContext.delete(context);
}
prw.startEval();
- JSFunction function = new
JSFunction("RichFaces.ui.TreeNode.initNodeByAjax", elementId);
+ JSFunction function = new
JSFunction("RichFaces.ui.TreeNode.initNodeByAjax", elementId,
+ Collections.singletonMap("clientEventHandlers",
clientEventHandlers));
prw.write(function.toScript());
prw.endEval();
}
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -21,23 +21,34 @@
*/
package org.richfaces.renderkit;
+import static org.richfaces.renderkit.RenderKitUtils.getFirstNonEmptyAttribute;
+
import java.io.IOException;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
+import javax.faces.context.ResponseWriter;
+import org.richfaces.component.AbstractTree;
import org.richfaces.component.AbstractTreeNode;
import org.richfaces.component.MetaComponentResolver;
+import org.richfaces.component.SwitchType;
import org.richfaces.event.TreeToggleEvent;
+import com.google.common.base.Strings;
+
/**
* @author Nick Belaevski
*
*/
public class TreeNodeRendererBase extends RendererBase implements MetaComponentRenderer
{
+ static final String AJAX_TOGGLED_NODE_ATTRIBUTE =
TreeNodeRendererBase.class.getName() + ":AJAX_TOGGLED_NODE_ATTRIBUTE";
+
+ static final String AJAX_TOGGLED_NODE_STATE_ATTRIBUTE =
TreeNodeRendererBase.class.getName() + ":AJAX_TOGGLED_NODE_STATE_ATTRIBUTE";
+
private static final String NEW_NODE_TOGGLE_STATE =
"__NEW_NODE_TOGGLE_STATE";
private static final String TRIGGER_NODE_AJAX_UPDATE =
"__TRIGGER_NODE_AJAX_UPDATE";
@@ -60,6 +71,9 @@
PartialViewContext pvc = context.getPartialViewContext();
if (pvc.isAjaxRequest() && map.get(component.getClientId(context) +
TRIGGER_NODE_AJAX_UPDATE) != null) {
pvc.getRenderIds().add(treeNode.getClientId(context) +
MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR +
AbstractTreeNode.SUBTREE_META_COMPONENT_ID);
+
+ context.getAttributes().put(AJAX_TOGGLED_NODE_ATTRIBUTE,
component.getClientId(context));
+ context.getAttributes().put(AJAX_TOGGLED_NODE_STATE_ATTRIBUTE,
expanded);
}
}
}
@@ -77,6 +91,79 @@
} else {
throw new IllegalArgumentException(metaComponentId);
}
+ }
+
+ protected TreeNodeState getNodeState(FacesContext context) {
+ return (TreeNodeState)
context.getAttributes().get(TreeEncoderBase.TREE_NODE_STATE_ATTRIBUTE);
+ }
+
+ protected UIComponent getTreeComponent(UIComponent treeNodeComponent) {
+ return ((AbstractTreeNode) treeNodeComponent).findTreeComponent();
+ }
+ protected void encodeDefaultIcon(FacesContext context, UIComponent component, String
styleClass) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer.startElement(HtmlConstants.SPAN_ELEM, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, styleClass, null);
+ writer.endElement(HtmlConstants.SPAN_ELEM);
}
+
+ protected void encodeCustomIcon(FacesContext context, UIComponent component, String
styleClass, String iconSource) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer.startElement(HtmlConstants.IMG_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, styleClass, null);
+ writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
+ writer.writeURIAttribute(HtmlConstants.SRC_ATTRIBUTE,
RenderKitUtils.getResourceURL(iconSource, context), null);
+ writer.endElement(HtmlConstants.IMG_ELEMENT);
+ }
+
+ protected void encodeIcon(FacesContext context, UIComponent component) throws
IOException {
+ TreeNodeState nodeState = getNodeState(context);
+
+ AbstractTreeNode treeNode = (AbstractTreeNode) component;
+
+ AbstractTree tree = treeNode.findTreeComponent();
+
+ if (nodeState.isLeaf()) {
+ String iconLeaf = (String) getFirstNonEmptyAttribute("iconLeaf",
treeNode, tree);
+ encodeIconForNodeState(context, tree, treeNode, nodeState, iconLeaf);
+ } else {
+ String iconExpanded = (String)
getFirstNonEmptyAttribute("iconExpanded", treeNode, tree);
+ String iconCollapsed = (String)
getFirstNonEmptyAttribute("iconCollapsed", treeNode, tree);
+
+ if (Strings.isNullOrEmpty(iconCollapsed) &&
Strings.isNullOrEmpty(iconExpanded)) {
+ encodeIconForNodeState(context, tree, treeNode, nodeState, null);
+ } else {
+ SwitchType toggleType = treeNode.findTreeComponent().getToggleType();
+
+ if (toggleType == SwitchType.client || nodeState ==
TreeNodeState.collapsed) {
+ encodeIconForNodeState(context, tree, treeNode,
TreeNodeState.collapsed, iconCollapsed);
+ }
+
+ if (toggleType == SwitchType.client || nodeState ==
TreeNodeState.expanded) {
+ encodeIconForNodeState(context, tree, treeNode,
TreeNodeState.expanded, iconExpanded);
+ }
+ }
+ }
+ }
+
+ protected void encodeIconForNodeState(FacesContext context, AbstractTree tree,
AbstractTreeNode treeNode, TreeNodeState nodeState, String customIcon) throws IOException
{
+ if (Strings.isNullOrEmpty(customIcon)) {
+ encodeDefaultIcon(context, treeNode, concatClasses(nodeState.getIconClass(),
treeNode.getAttributes().get("iconClass"),
+ tree.getAttributes().get("iconClass")));
+ } else {
+ encodeCustomIcon(context, treeNode,
concatClasses(nodeState.getCustomIconClass(),
treeNode.getAttributes().get("iconClass"),
+ tree.getAttributes().get("iconClass")), customIcon);
+ }
+ }
+
+ protected void addClientEventHandlers(FacesContext facesContext, UIComponent
component) {
+ AbstractTreeNode treeNode = (AbstractTreeNode) component;
+
+ //TODO check toggle/selection types
+ TreeRenderingContext renderingContext = TreeRenderingContext.get(facesContext);
+ renderingContext.addHandlers(treeNode);
+ }
}
Copied:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeState.java
(from rev 20107,
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeState.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeState.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeState.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+import org.richfaces.component.util.HtmlUtil;
+
+public enum TreeNodeState {
+ expanded("rf-tr-nd-exp", "rf-trn-hnd-exp",
"rf-trn-ico-exp") {
+ @Override
+ public boolean isLeaf() {
+ return false;
+ }
+ },
+ collapsed("rf-tr-nd-colps", "rf-trn-hnd-colps",
"rf-trn-ico-colps") {
+ @Override
+ public boolean isLeaf() {
+ return false;
+ }
+ },
+ leaf("rf-tr-nd-lf", "rf-trn-hnd-lf", "rf-trn-ico-lf")
{
+ @Override
+ public boolean isLeaf() {
+ return true;
+ }
+ };
+
+ private String nodeClass;
+
+ private String handleClass;
+
+ private String iconClass;
+
+ private String customIconClass;
+
+ private TreeNodeState(String nodeClass, String defaultHandleClass, String iconClass)
{
+ this.nodeClass = nodeClass;
+ this.handleClass = HtmlUtil.concatClasses(defaultHandleClass,
"rf-trn-hnd");
+ this.iconClass = HtmlUtil.concatClasses(iconClass, "rf-trn-ico");
+ this.customIconClass = HtmlUtil.concatClasses(this.iconClass,
"rf-trn-ico-cst");
+ }
+
+ public abstract boolean isLeaf();
+
+ public String getNodeClass() {
+ return nodeClass;
+ }
+
+ public String getHandleClass() {
+ return handleClass;
+ }
+
+ public String getIconClass() {
+ return iconClass;
+ }
+
+ public String getCustomIconClass() {
+ return customIconClass;
+ }
+}
\ No newline at end of file
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -45,7 +45,7 @@
import org.richfaces.component.AbstractTreeNode;
import org.richfaces.component.MetaComponentResolver;
import org.richfaces.component.SwitchType;
-import org.richfaces.event.TreeSelectionEvent;
+import org.richfaces.event.TreeSelectionChangeEvent;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -84,51 +84,16 @@
}
}
- enum NodeState {
- expanded("rf-tr-nd-exp", "rf-trn-hnd-exp",
"rf-trn-ico-nd"),
- collapsed("rf-tr-nd-colps", "rf-trn-hnd-colps",
"rf-trn-ico-nd"),
- leaf("rf-tr-nd-lf", "rf-trn-hnd-lf",
"rf-trn-ico-lf");
-
- private String nodeClass;
-
- private String handleClass;
-
- private String iconClass;
-
- private NodeState(String nodeClass, String handleClass, String iconClass) {
- this.nodeClass = nodeClass;
- this.handleClass = handleClass;
- this.iconClass = iconClass;
- }
-
- public String getNodeClass() {
- return nodeClass;
- }
-
- public String getHandleClass() {
- return handleClass;
- }
-
- public String getIconClass() {
- return iconClass;
- }
-
- }
-
static final class QueuedData {
private Object rowKey;
- private boolean lastNode;
-
- private boolean expanded;
-
private boolean encoded;
- public QueuedData(Object rowKey, boolean lastNode, boolean expanded) {
+ private boolean visited;
+
+ public QueuedData(Object rowKey) {
this.rowKey = rowKey;
- this.lastNode = lastNode;
- this.expanded = expanded;
}
public void setEncoded(boolean encoded) {
@@ -143,12 +108,12 @@
return rowKey;
}
- public boolean isLastNode() {
- return lastNode;
+ public boolean isVisited() {
+ return visited;
}
-
- public boolean isExpanded() {
- return expanded;
+
+ public void makeVisited() {
+ visited = true;
}
}
@@ -247,7 +212,7 @@
writer.startEval();
JSFunction function = new JSFunction("RichFaces.$",
component.getClientId(context));
- writer.write(function.toScript() + ".__updateSelection();");
+ writer.write(function.toScript() +
".__updateSelectionFromInput();");
writer.endEval();
} else {
@@ -293,7 +258,7 @@
}
if (newSelection != null) {
- new TreeSelectionEvent(component, Sets.newHashSet(selection),
newSelection).queue();
+ new TreeSelectionChangeEvent(component, Sets.newHashSet(selection),
newSelection).queue();
}
PartialViewContext pvc = context.getPartialViewContext();
@@ -302,4 +267,17 @@
+ AbstractTree.SELECTION_META_COMPONENT_ID);
}
}
+
+ protected void createTreeRenderingContext(FacesContext context, UIComponent
component) {
+ TreeRenderingContext.create(context, (AbstractTree) component);
+ }
+
+ protected Object getClientEventHandlers(FacesContext facesContext) {
+ TreeRenderingContext treeRenderingContext =
TreeRenderingContext.get(facesContext);
+ return treeRenderingContext.getHandlers();
+ }
+
+ protected void deleteTreeRenderingContext(FacesContext context) {
+ TreeRenderingContext.delete(context);
+ }
}
Copied:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java
(from rev 20107,
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,208 @@
+/*
+ * 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;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.ScriptStringBase;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.richfaces.component.AbstractTree;
+import org.richfaces.component.AbstractTreeNode;
+import org.richfaces.component.SwitchType;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class TreeRenderingContext {
+
+ private static final String ATTRIBUTE_NAME = TreeRenderingContext.class.getName() +
":ATTRIBUTE_NAME";
+
+ private static final ComponentAttribute ONTOGGLE_ATTRIBUTE = new
ComponentAttribute("ontoggle").setEventNames("toggle");
+
+ private static final ComponentAttribute ONNODETOGGLE_ATTRIBUTE = new
ComponentAttribute("onnodetoggle").setEventNames("nodetoggle");
+
+ private static final ComponentAttribute ONBEFORETOGGLE_ATTRIBUTE = new
ComponentAttribute("onbeforetoggle").setEventNames("beforetoggle");
+
+ private static final ComponentAttribute ONBEFORENODETOGGLE_ATTRIBUTE = new
ComponentAttribute("onbeforenodetoggle").setEventNames("beforenodetoggle");
+
+ public static final class Handlers extends ScriptStringBase {
+
+ private String toggleHandler;
+
+ private String nodeToggleHandler;
+
+ private String beforeToggleHandler;
+
+ private String beforeNodeToggleHandler;
+
+ protected Object chain(String firstHandler, String secondHandler) {
+ if (isNullOrEmpty(firstHandler) && isNullOrEmpty(secondHandler)) {
+ return null;
+ }
+
+ if (isNullOrEmpty(firstHandler)) {
+ return secondHandler;
+ }
+
+ if (isNullOrEmpty(secondHandler)) {
+ return firstHandler;
+ }
+
+ return new JSFunction("return jsf.util.chain", JSReference.THIS,
JSReference.EVENT, firstHandler, secondHandler).toScript();
+ }
+
+ public void setToggleHandler(String toggleHandler) {
+ this.toggleHandler = toggleHandler;
+ }
+
+ public String getToggleHandler() {
+ return toggleHandler;
+ }
+
+ public void setNodeToggleHandler(String nodeToggleHandler) {
+ this.nodeToggleHandler = nodeToggleHandler;
+ }
+
+ public String getNodeToggleHandler() {
+ return nodeToggleHandler;
+ }
+
+ public void setBeforeToggleHandler(String beforeToggleHandler) {
+ this.beforeToggleHandler = beforeToggleHandler;
+ }
+
+ public String getBeforeToggleHandler() {
+ return beforeToggleHandler;
+ }
+
+ public void setBeforeNodeToggleHandler(String beforeNodeToggleHandler) {
+ this.beforeNodeToggleHandler = beforeNodeToggleHandler;
+ }
+
+ public String getBeforeNodeToggleHandler() {
+ return beforeNodeToggleHandler;
+ }
+
+ public void appendScript(Appendable target) throws IOException {
+ Object chainedToggleHandler = chain(toggleHandler, nodeToggleHandler);
+ Object chainedBeforeToggleHandler = chain(beforeToggleHandler,
beforeNodeToggleHandler);
+
+ if (chainedToggleHandler != null || chainedBeforeToggleHandler != null) {
+ Map<String,Object> map = new HashMap<String, Object>(2);
+
+ if (chainedToggleHandler != null) {
+ map.put("th", chainedToggleHandler);
+ }
+
+ if (chainedBeforeToggleHandler != null) {
+ map.put("bth", chainedBeforeToggleHandler);
+ }
+
+ ScriptUtils.appendScript(target, map);
+ } else {
+ ScriptUtils.appendScript(target, null);
+ }
+ }
+ }
+
+ private FacesContext context;
+
+ private AbstractTree tree;
+
+ private String baseClientId;
+
+ private Map<String, Handlers> handlersMap = new HashMap<String,
Handlers>();
+
+ private Handlers handlers;
+
+ private TreeRenderingContext(FacesContext context, AbstractTree tree) {
+ super();
+ this.context = context;
+ this.tree = tree;
+ this.baseClientId = tree.getBaseClientId(context);
+ }
+
+ public static TreeRenderingContext create(FacesContext context, AbstractTree tree) {
+ TreeRenderingContext renderingContext = new TreeRenderingContext(context, tree);
+ context.getAttributes().put(ATTRIBUTE_NAME, renderingContext);
+ return renderingContext;
+ }
+
+ public static TreeRenderingContext get(FacesContext context) {
+ return (TreeRenderingContext) context.getAttributes().get(ATTRIBUTE_NAME);
+ }
+
+ public static void delete(FacesContext context) {
+ context.getAttributes().remove(ATTRIBUTE_NAME);
+ }
+
+ private Handlers getOrCreateHandlers(String relativeClientId) {
+ if (handlers == null) {
+ handlers = new Handlers();
+ handlersMap.put(relativeClientId, handlers);
+ }
+ return handlers;
+ }
+
+ public void addHandlers(AbstractTreeNode treeNode) {
+ handlers = null;
+
+ String clientId = treeNode.getClientId(context);
+
+ String relativeClientId = clientId.substring(baseClientId.length());
+
+ if (tree.getToggleType() != SwitchType.server) {
+ String toggleHandler = (String)
RenderKitUtils.getAttributeAndBehaviorsValue(context, treeNode, ONTOGGLE_ATTRIBUTE);
+ if (!isNullOrEmpty(toggleHandler)) {
+ getOrCreateHandlers(relativeClientId).setToggleHandler(toggleHandler);
+ }
+
+ String beforeToggleHandler = (String)
RenderKitUtils.getAttributeAndBehaviorsValue(context, treeNode,
ONBEFORETOGGLE_ATTRIBUTE);
+ if (!isNullOrEmpty(beforeToggleHandler)) {
+
getOrCreateHandlers(relativeClientId).setBeforeToggleHandler(beforeToggleHandler);
+ }
+
+ String nodeToggleHandler = (String)
RenderKitUtils.getAttributeAndBehaviorsValue(context, tree, ONNODETOGGLE_ATTRIBUTE);
+ if (!isNullOrEmpty(nodeToggleHandler)) {
+
getOrCreateHandlers(relativeClientId).setNodeToggleHandler(nodeToggleHandler);
+ }
+
+ String beforeNodeToggleHandler = (String)
RenderKitUtils.getAttributeAndBehaviorsValue(context, tree,
ONBEFORENODETOGGLE_ATTRIBUTE);
+ if (!isNullOrEmpty(beforeNodeToggleHandler)) {
+
getOrCreateHandlers(relativeClientId).setBeforeNodeToggleHandler(beforeNodeToggleHandler);
+ }
+ }
+ }
+
+ public Object getHandlers() {
+ return handlersMap;
+ }
+}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view (from rev
20107, trunk/ui/iteration/ui/src/main/java/org/richfaces/view)
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets (from
rev 20107, trunk/ui/iteration/ui/src/main/java/org/richfaces/view/facelets)
Deleted:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeHandler.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeHandler.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeHandler.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,66 +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.view.facelets;
-
-import javax.faces.view.facelets.ComponentConfig;
-import javax.faces.view.facelets.ComponentHandler;
-import javax.faces.view.facelets.MetaRule;
-import javax.faces.view.facelets.MetaRuleset;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.MetadataTarget;
-import javax.faces.view.facelets.TagAttribute;
-
-import org.richfaces.component.AbstractTree;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class TreeHandler extends ComponentHandler {
-
- private static final MetaRule RULE = new MetaRule() {
-
- @Override
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
- if (meta.isTargetInstanceOf(AbstractTree.class)) {
- if ("selectionChangeListener".equals(name)) {
- return new TreeSelectionChangeListenerExpressionMetadata(attribute);
- } else if ("toggleListener".equals(name)) {
- return new TreeToggleListenerExpressionMetadata(attribute);
- }
-
- }
- return null;
- }
- };
-
- public TreeHandler(ComponentConfig config) {
- super(config);
- }
-
- @Override
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset metaRuleset = super.createMetaRuleset(type);
- metaRuleset.addRule(RULE);
- return metaRuleset;
- }
-}
Copied:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeHandler.java
(from rev 20107,
trunk/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeHandler.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeHandler.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeHandler.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,66 @@
+/*
+ * 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.view.facelets;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.component.AbstractTree;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TreeHandler extends ComponentHandler {
+
+ private static final MetaRule RULE = new MetaRule() {
+
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
+ if (meta.isTargetInstanceOf(AbstractTree.class)) {
+ if ("selectionChangeListener".equals(name)) {
+ return new TreeSelectionChangeListenerExpressionMetadata(attribute);
+ } else if ("toggleListener".equals(name)) {
+ return new TreeToggleListenerExpressionMetadata(attribute);
+ }
+
+ }
+ return null;
+ }
+ };
+
+ public TreeHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRuleset = super.createMetaRuleset(type);
+ metaRuleset.addRule(RULE);
+ return metaRuleset;
+ }
+}
Deleted:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeNodeHandler.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeNodeHandler.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeNodeHandler.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,63 +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.view.facelets;
-
-import javax.faces.view.facelets.ComponentConfig;
-import javax.faces.view.facelets.ComponentHandler;
-import javax.faces.view.facelets.MetaRule;
-import javax.faces.view.facelets.MetaRuleset;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.MetadataTarget;
-import javax.faces.view.facelets.TagAttribute;
-
-import org.richfaces.component.AbstractTreeNode;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class TreeNodeHandler extends ComponentHandler {
-
- private static final MetaRule RULE = new MetaRule() {
-
- @Override
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
- if (meta.isTargetInstanceOf(AbstractTreeNode.class)) {
- if ("toggleListener".equals(name)) {
- return new TreeToggleListenerExpressionMetadata(attribute);
- }
- }
- return null;
- }
- };
-
- public TreeNodeHandler(ComponentConfig config) {
- super(config);
- }
-
- @Override
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset metaRuleset = super.createMetaRuleset(type);
- metaRuleset.addRule(RULE);
- return metaRuleset;
- }
-}
Copied:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeNodeHandler.java
(from rev 20107,
trunk/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeNodeHandler.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeNodeHandler.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeNodeHandler.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,63 @@
+/*
+ * 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.view.facelets;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.component.AbstractTreeNode;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TreeNodeHandler extends ComponentHandler {
+
+ private static final MetaRule RULE = new MetaRule() {
+
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
+ if (meta.isTargetInstanceOf(AbstractTreeNode.class)) {
+ if ("toggleListener".equals(name)) {
+ return new TreeToggleListenerExpressionMetadata(attribute);
+ }
+ }
+ return null;
+ }
+ };
+
+ public TreeNodeHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRuleset = super.createMetaRuleset(type);
+ metaRuleset.addRule(RULE);
+ return metaRuleset;
+ }
+}
Deleted:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeSelectionChangeListenerExpressionMetadata.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeSelectionChangeListenerExpressionMetadata.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeSelectionChangeListenerExpressionMetadata.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,31 +0,0 @@
-package org.richfaces.view.facelets;
-
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.TagAttribute;
-
-import org.richfaces.event.MethodExpressionTreeSelectionChangeListener;
-import org.richfaces.event.TreeSelectionChangeEvent;
-import org.richfaces.event.TreeSelectionChangeSource;
-
-/**
- * @author Nick Belaevski
- *
- */
-final class TreeSelectionChangeListenerExpressionMetadata extends Metadata {
-
- private static final Class<?>[] SIGNATURE = new Class[] {
TreeSelectionChangeEvent.class };
-
- private final TagAttribute attr;
-
- TreeSelectionChangeListenerExpressionMetadata(TagAttribute attr) {
- this.attr = attr;
- }
-
- @Override
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((TreeSelectionChangeSource) instance).addTreeSelectionChangeListener(new
MethodExpressionTreeSelectionChangeListener(
- this.attr.getMethodExpression(ctx, null, SIGNATURE)));
- }
-
-}
\ No newline at end of file
Copied:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeSelectionChangeListenerExpressionMetadata.java
(from rev 20107,
trunk/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeSelectionChangeListenerExpressionMetadata.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeSelectionChangeListenerExpressionMetadata.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeSelectionChangeListenerExpressionMetadata.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,31 @@
+package org.richfaces.view.facelets;
+
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.event.MethodExpressionTreeSelectionChangeListener;
+import org.richfaces.event.TreeSelectionChangeEvent;
+import org.richfaces.event.TreeSelectionChangeSource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+final class TreeSelectionChangeListenerExpressionMetadata extends Metadata {
+
+ private static final Class<?>[] SIGNATURE = new Class[] {
TreeSelectionChangeEvent.class };
+
+ private final TagAttribute attr;
+
+ TreeSelectionChangeListenerExpressionMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((TreeSelectionChangeSource) instance).addTreeSelectionChangeListener(new
MethodExpressionTreeSelectionChangeListener(
+ this.attr.getMethodExpression(ctx, null, SIGNATURE)));
+ }
+
+}
\ No newline at end of file
Deleted:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeToggleListenerExpressionMetadata.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeToggleListenerExpressionMetadata.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeToggleListenerExpressionMetadata.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,31 +0,0 @@
-package org.richfaces.view.facelets;
-
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.TagAttribute;
-
-import org.richfaces.event.MethodExpressionTreeToggleListener;
-import org.richfaces.event.TreeToggleEvent;
-import org.richfaces.event.TreeToggleSource;
-
-/**
- * @author Nick Belaevski
- *
- */
-final class TreeToggleListenerExpressionMetadata extends Metadata {
-
- private static final Class<?>[] SIGNATURE = new Class[] { TreeToggleEvent.class
};
-
- private final TagAttribute attr;
-
- TreeToggleListenerExpressionMetadata(TagAttribute attr) {
- this.attr = attr;
- }
-
- @Override
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((TreeToggleSource) instance).addTreeToggleListener(new
MethodExpressionTreeToggleListener(this.attr
- .getMethodExpression(ctx, null, SIGNATURE)));
- }
-
-}
\ No newline at end of file
Copied:
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeToggleListenerExpressionMetadata.java
(from rev 20107,
trunk/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeToggleListenerExpressionMetadata.java)
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeToggleListenerExpressionMetadata.java
(rev 0)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/view/facelets/TreeToggleListenerExpressionMetadata.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,31 @@
+package org.richfaces.view.facelets;
+
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.TagAttribute;
+
+import org.richfaces.event.MethodExpressionTreeToggleListener;
+import org.richfaces.event.TreeToggleEvent;
+import org.richfaces.event.TreeToggleSource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+final class TreeToggleListenerExpressionMetadata extends Metadata {
+
+ private static final Class<?>[] SIGNATURE = new Class[] { TreeToggleEvent.class
};
+
+ private final TagAttribute attr;
+
+ TreeToggleListenerExpressionMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((TreeToggleSource) instance).addTreeToggleListener(new
MethodExpressionTreeToggleListener(this.attr
+ .getMethodExpression(ctx, null, SIGNATURE)));
+ }
+
+}
\ No newline at end of file
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-11-18
23:14:43 UTC (rev 20108)
@@ -58,7 +58,7 @@
background: "url(#{resource['org.richfaces.images:minus.png']}) no-repeat
center";
}
-.rf-trn-ico-nd {
+.rf-trn-ico-exp, .rf-trn-ico-colps {
background: "url(#{resource['org.richfaces.images:node_icon.gif']})
no-repeat center";
}
@@ -66,6 +66,15 @@
background: "url(#{resource['org.richfaces.images:leaf_icon.gif']})
no-repeat center";
}
+.rf-trn-ico-cst {
+ background-image: none;
+ background-position: 0% 0%;
+}
+
+.rf-tr-nd-exp > .rf-trn > .rf-trn-cnt > .rf-trn-ico-colps, .rf-tr-nd-colps >
.rf-trn > .rf-trn-cnt > .rf-trn-ico-exp {
+ display: none;
+}
+
.rf-tr-nd.rf-tr-nd-colps .rf-tr-nd {
display: none;
}
Modified:
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
---
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18
23:14:43 UTC (rev 20108)
@@ -31,21 +31,37 @@
var TREE_HANDLE_CLASSES = ["rf-trn-hnd-colps", "rf-trn-hnd-exp"];
+ var TREE_ICON_CLASSES = ["rf-trn-ico-colps", "rf-trn-ico-exp"];
+
richfaces.ui = richfaces.ui || {};
richfaces.ui.TreeNode = richfaces.BaseComponent.extendClass({
name: "TreeNode",
- init: function (id) {
+ init: function (id, commonOptions) {
this.__rootElt = $(this.attachToDom(id));
this.__children = new Array();
- this.__initializeChildren();
+ this.__initializeChildren(commonOptions);
+
+ var handlers = (commonOptions.clientEventHandlers ||
{})[this.getId().substring(commonOptions.treeId.length)] || {};
+
+ if (handlers.bth) {
+ richfaces.Event.bind(this.__rootElt, "beforetoggle", new
Function("event", handlers.bth));
+ }
+
+ if (handlers.th) {
+ richfaces.Event.bind(this.__rootElt, "toggle", new
Function("event", handlers.th));
+ }
+
+ this.__addLastNodeClass();
},
destroy: function() {
+ richfaces.BaseComponent.prototype.destroy.call(this);
+
if (this.parent) {
this.parent.removeChild(this);
this.parent = null;
@@ -58,13 +74,19 @@
this.__rootElt = null;
},
- __initializeChildren: function() {
+ __initializeChildren: function(commonOptions) {
var _this = this;
this.__rootElt.children(".rf-tr-nd").each(function() {
- _this.addChild(new richfaces.ui.TreeNode(this));
+ _this.addChild(new richfaces.ui.TreeNode(this, commonOptions));
});
},
+ __addLastNodeClass: function() {
+ if (this.__rootElt.next("div").length == 0) {
+ this.__rootElt.addClass("rf-tr-nd-last");
+ }
+ },
+
__getHandle: function() {
return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd:first");
},
@@ -73,6 +95,10 @@
return this.__rootElt.find(" > .rf-trn:first > .rf-trn-cnt:first");
},
+ __getIcons: function() {
+ return this.__getContent().find(" > .rf-trn-ico");
+ },
+
getParent: function() {
return this.__parent;
},
@@ -116,15 +142,15 @@
},
isExpanded: function() {
- return !this.isLeaf() &&
this.__getHandle().hasClass("rf-trn-hnd-exp");
+ return !this.isLeaf() && this.__rootElt.hasClass("rf-tr-nd-exp");
},
isCollapsed: function() {
- return !this.isLeaf() &&
this.__getHandle().hasClass("rf-trn-hnd-colps");
+ return !this.isLeaf() && this.__rootElt.hasClass("rf-tr-nd-colps");
},
isLeaf: function() {
- return this.__getHandle().hasClass("rf-trn-hnd-lf");
+ return this.__rootElt.hasClass("rf-tr-nd-lf");
},
toggle: function() {
@@ -149,16 +175,36 @@
},
+ __fireBeforeToggleEvent: function() {
+ return richfaces.Event.callHandler(this.__rootElt, "beforetoggle");
+ },
+
+ __fireToggleEvent: function() {
+ richfaces.Event.callHandler(this.__rootElt, "toggle");
+ },
+
__changeToggleState: function(newState) {
if (!this.isLeaf()) {
if (newState ^ this.isExpanded()) {
+
+ if (this.__fireBeforeToggleEvent() === false) {
+ return;
+ }
+
var tree = this.getTree();
switch (tree.getToggleType()) {
case 'client':
this.__rootElt.addClass(TREE_CLASSES[newState ? 1 :
0]).removeClass(TREE_CLASSES[!newState ? 1 : 0]);
this.__getHandle().addClass(TREE_HANDLE_CLASSES[newState ? 1 :
0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
+
+ var icons = this.__getIcons();
+ if (icons.length == 1) {
+ icons.addClass(TREE_ICON_CLASSES[newState ? 1 :
0]).removeClass(TREE_ICON_CLASSES[!newState ? 1 : 0]);
+ }
+
this.__updateClientToggleStateInput(newState);
+ this.__fireToggleEvent();
break;
case 'ajax':
@@ -204,23 +250,32 @@
});
- richfaces.ui.TreeNode.initNodeByAjax = function(nodeId) {
+ richfaces.ui.TreeNode.initNodeByAjax = function(nodeId, commonOptions) {
var node = $(document.getElementById(nodeId));
- if (node.nextAll(".rf-tr-nd:first").length != 0) {
- node.removeClass("rf-tr-nd-last");
- }
+ var opts = commonOptions || {};
var parent = node.parent(".rf-tr-nd, .rf-tr");
var idx = node.prevAll(".rf-tr-nd").length;
var parentNode = richfaces.$(parent[0]);
- var newChild = new richfaces.ui.TreeNode(node[0]);
+ opts.treeId = parentNode.getTree().getId();
+
+ var newChild = new richfaces.ui.TreeNode(node[0], opts);
parentNode.addChild(newChild, idx);
- parentNode.getTree().__updateSelection();
+ parentNode.getTree().__updateSelectionFromInput();
};
+ richfaces.ui.TreeNode.emitToggleEvent = function(nodeId) {
+ var node = document.getElementById(nodeId);
+ if (!node) {
+ return;
+ }
+
+ richfaces.$(node).__fireToggleEvent();
+ };
+
var findTree = function(elt) {
return richfaces.$($(elt).closest(".rf-tr"));
};
@@ -240,8 +295,12 @@
init: function (id, options) {
this.__treeRootElt = $(richfaces.getDomElement(id));
- this.$super.init.call(this, this.__treeRootElt);
+ var commonOptions = {};
+ commonOptions.clientEventHandlers = options.clientEventHandlers || {};
+ commonOptions.treeId = id;
+ this.$super.init.call(this, this.__treeRootElt, commonOptions);
+
this.__toggleType = options.toggleType || 'ajax';
this.__selectionType = options.selectionType || 'client';
@@ -249,27 +308,52 @@
this.__ajaxSubmitFunction = new Function("event", "source",
"params", options.ajaxSubmitFunction);
}
+ if (options.onbeforeselectionchange) {
+ richfaces.Event.bind(this.__treeRootElt, "beforeselectionchange", new
Function("event", options.onbeforeselectionchange));
+ }
+
+ if (options.onselectionchange) {
+ richfaces.Event.bind(this.__treeRootElt, "selectionchange", new
Function("event", options.onselectionchange));
+ }
+
+ this.__toggleNodeEvent = options.toggleNodeEvent;
+ if (this.__toggleNodeEvent) {
+ this.__treeRootElt.delegate(".rf-trn", this.__toggleNodeEvent, this,
this.__nodeToggleActivated);
+ }
+ if (!this.__toggleNodeEvent || this.__toggleNodeEvent != 'click') {
+ this.__treeRootElt.delegate(".rf-trn-hnd", "click", this,
this.__nodeToggleActivated);
+ }
+
+ this.__treeRootElt.delegate(".rf-trn-cnt", "mousedown", this,
this.__nodeSelectionActivated);
+
this.__selectionInput = $(" > .rf-tr-sel-inp", this.__treeRootElt);
+ this.__selection = new richfaces.ui.TreeNodeSet(this.__selectionInput.val());
- this.__treeRootElt.delegate(".rf-trn-hnd", "click", this,
this.__itemHandleClicked);
- this.__treeRootElt.delegate(".rf-trn-cnt", "mousedown", this,
this.__itemContentClicked);
-
- this.__updateSelection();
+ $(document).ready($.proxy(this.__updateSelectionFromInput, this));
},
+ __addLastNodeClass: function() {
+ //stub function overriding parent class method
+ },
+
destroy: function() {
- this.$super.destroy.call(this);
+ richfaces.ui.TreeNode.prototype.destroy.call(this);
- this.__treeRootElt.undelegate(".rf-trn-hnd", "click",
this.__itemHandleClicked);
- this.__treeRootElt.undelegate(".rf-trn-cnt", "mousedown",
this.__itemContentClicked);
+ if (this.__toggleNodeEvent) {
+ this.__treeRootElt.undelegate(".rf-trn", this.__toggleNodeEvent, this,
this.__nodeToggleActivated);
+ }
+ if (!this.__toggleNodeEvent || this.__toggleNodeEvent != 'click') {
+ this.__treeRootElt.undelegate(".rf-trn-hnd", "click", this,
this.__nodeToggleActivated);
+ }
+
+ this.__treeRootElt.undelegate(".rf-trn-cnt", "mousedown",
this.__nodeSelectionActivated);
this.__treeRootElt = null;
- this.__itemContentClickedHandler = null;
this.__selectionInput = null;
this.__ajaxSubmitFunction = null;
},
- __itemHandleClicked: function(event) {
+ __nodeToggleActivated: function(event) {
var theTree = event.data;
if (isEventForAnotherTree(theTree, this)) {
return;
@@ -279,7 +363,7 @@
treeNode.toggle();
},
- __itemContentClicked: function(event) {
+ __nodeSelectionActivated: function(event) {
var theTree = event.data;
if (isEventForAnotherTree(theTree, this)) {
return;
@@ -319,60 +403,119 @@
return this;
},
- __bindFocusHandler: function(elt) {
- elt.mousedown(this.__itemContentClickedHandler);
- },
-
__isSelected: function(node) {
- return this.__selectedNodeId == node.getId();
+ return this.__selection.contains(node);
},
- __handleSelectionChange: function() {
+ __handleSelectionChange: function(newSelection) {
+ var eventData = {
+ oldSelection: this.__selection.getNodes(),
+ newSelection: newSelection.getNodes()
+ };
+
+ if (richfaces.Event.callHandler(this.__treeRootElt, "beforeselectionchange",
eventData) === false) {
+ return;
+ }
+
+ this.__selectionInput.val(newSelection.toString());
+
if (this.getSelectionType() == 'client') {
- this.__updateSelection();
+ this.__updateSelection(newSelection);
} else {
this.__ajaxSubmitFunction(null, this.getId());
}
},
__toggleSelection: function(node) {
- if (this.__isSelected(node)) {
- this.__selectionInput.val("");
- } else {
- this.__selectionInput.val(node.getId());
- }
-
- this.__handleSelectionChange();
+ var newSelection = this.__selection.cloneAndToggle(node);
+ this.__handleSelectionChange(newSelection);
},
__addToSelection: function(node) {
- this.__selectionInput.val(node.getId());
+ var newSelection = this.__selection.cloneAndAdd(node);
+ this.__handleSelectionChange(newSelection);
+ },
+
+ __updateSelectionFromInput: function() {
+ this.__updateSelection(new richfaces.ui.TreeNodeSet(this.__selectionInput.val()));
+ },
+
+ __updateSelection: function(newSelection) {
+
+ var oldSelection = this.__selection;
- this.__handleSelectionChange();
+ oldSelection.each(function() {this.__setSelected(false)});
+ newSelection.each(function() {this.__setSelected(true)});
+
+ if (oldSelection.getNodeString() != newSelection.getNodeString()) {
+ richfaces.Event.callHandler(this.__treeRootElt, "selectionchange", {
+ oldSelection: oldSelection.getNodes(),
+ newSelection: newSelection.getNodes()
+ });
+ }
+
+ this.__selection = newSelection;
+ }
+ });
+
+ richfaces.ui.TreeNodeSet = function() {
+ this.init.apply(this, arguments);
+ };
+
+ //TODO - that's a single-node set, implement multi-node support!
+ $.extend(richfaces.ui.TreeNodeSet.prototype, {
+
+ init: function(nodeId) {
+ this.__nodeId = nodeId;
},
- __resetSelection: function() {
- this.__selectedNodeId = null;
- this.__selectionInput.val("");
+ contains: function(node) {
+ if (node.getId) {
+ return this.__nodeId == node.getId();
+ } else {
+ return this.__nodeId == node;
+ }
},
- __updateSelection: function() {
- var oldSelection = this.__selectedNodeId;
- if (oldSelection) {
- var oldSelectionNode = richfaces.$(oldSelection);
- if (oldSelectionNode) {
- oldSelectionNode.__setSelected(false);
+ getNodeString: function() {
+ return this.__nodeId;
+ },
+
+ toString: function() {
+ return this.getNodeString();
+ },
+
+ getNodes: function() {
+ if (this.__nodeId) {
+ var node = richfaces.$(this.__nodeId);
+ if (node) {
+ return [node];
+ } else {
+ return null;
}
}
- var nodeId = this.__selectionInput.val();
+ return [];
+ },
+
+ cloneAndAdd: function(node) {
+ return new richfaces.ui.TreeNodeSet(node.getId());
+ },
+
+ cloneAndToggle: function(node) {
+ var nodeId;
+ if (this.contains(node)) {
+ nodeId = "";
+ } else {
+ nodeId = node.getId();
+ }
- var newSelectionNode = richfaces.$(nodeId);
- if (newSelectionNode) {
- newSelectionNode.__setSelected(true);
- }
- this.__selectedNodeId = nodeId;
+ return new richfaces.ui.TreeNodeSet(nodeId);
+ },
+
+ each: function(callback) {
+ $.each(this.getNodes() || [], callback);
}
});
-
+
}(jQuery, RichFaces));
\ No newline at end of file
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/templates/tree.template.xml
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/templates/tree.template.xml 2010-11-18
18:50:06 UTC (rev 20107)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/templates/tree.template.xml 2010-11-18
23:14:43 UTC (rev 20108)
@@ -13,19 +13,30 @@
<cdk:resource-dependency name="ajax.reslib"
library="org.richfaces" />
<cdk:resource-dependency name="base-component.reslib"
library="org.richfaces" />
+ <cdk:resource-dependency name="richfaces-event.js" />
<cdk:resource-dependency name="tree.js"
library="org.richfaces" />
<cdk:resource-dependency name="tree.ecss"
library="org.richfaces" />
+ <cdk:import-attributes src="urn:attributes:events-props.xml"/>
+ <cdk:import-attributes src="urn:attributes:core-props.xml"/>
+ <cdk:import-attributes src="urn:attributes:i18n-props.xml"/>
+
<cdk:import package="org.richfaces.component"
names="SwitchType" />
</cc:interface>
<cc:implementation>
<div id="#{clientId}" class="#{concatClasses('rf-tr',
component.attributes['styleClass'])}"
cdk:passThroughWithExclusions="">
+
+ <cdk:call expression="createTreeRenderingContext(facesContext,
component)" />
+
<cdk:body>
<cdk:call expression="encodeTree(facesContext, component)"
/>
</cdk:body>
+ <cdk:object name="clientEventHandlers"
value="#{getClientEventHandlers(facesContext)}" />
+ <cdk:call expression="deleteTreeRenderingContext(facesContext)"
/>
+
<cdk:call expression="encodeSelectionStateInput(facesContext,
component)" />
<script type="text/javascript">
@@ -33,6 +44,8 @@
<cdk:scriptOption attributes="toggleType"
defaultValue="SwitchType.DEFAULT" />
<cdk:scriptOption name="selectionType"
value="#{getSelectionMode(facesContext, component)}"
defaultValue="SwitchType.client" />
<cdk:scriptOption name="ajaxSubmitFunction"
value="#{getAjaxSubmitFunction(facesContext, component)}" />
+ <cdk:scriptOption attributes="onselectionchange
onbeforeselectionchange toggleNodeEvent" />
+ <cdk:scriptOption variables="clientEventHandlers" />
</cdk:scriptObject>
new RichFaces.ui.Tree(#{toScriptArgs(clientId, options)});
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/templates/treeNode.template.xml
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-11-18
18:50:06 UTC (rev 20107)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-11-18
23:14:43 UTC (rev 20108)
@@ -13,14 +13,24 @@
</cdk:component-family>
<cdk:renderer-type>org.richfaces.TreeNodeRenderer
</cdk:renderer-type>
+
+ <cdk:import-attributes src="urn:attributes:events-props.xml"/>
+ <cdk:import-attributes src="urn:attributes:core-props.xml"/>
+ <cdk:import-attributes src="urn:attributes:i18n-props.xml"/>
</cc:interface>
<cc:implementation>
- <div class="#{concatClasses('rf-trn',
component.attributes['styleClass'])}">
- <span class="rf-trn-hnd
#{facesContext.attributes['__treeNodeHandleClass']}" />
+ <cdk:object name="nodeState"
value="#{getNodeState(facesContext)}"
type="org.richfaces.renderkit.TreeNodeState" />
+ <cdk:object name="tree"
value="#{getTreeComponent(component)}" type="UIComponent" />
+
+ <cdk:call expression="addClientEventHandlers(facesContext,
component)" />
+
+ <div class="#{concatClasses('rf-trn',
component.attributes['styleClass'],
tree.attributes['nodeClass'])}">
+ <span class="#{concatClasses(nodeState.handleClass,
component.attributes['handleClass'],
tree.attributes['handleClass'])}"></span>
+
<span class="rf-trn-cnt">
- <span class="rf-trn-ico
#{facesContext.attributes['__treeNodeIconClass']}" />
- <span class="rf-trn-lbl">
+ <cdk:call expression="encodeIcon(facesContext, component)"
/>
+ <span class="#{concatClasses('rf-trn-lbl',
component.attributes['labelClass'],
tree.attributes['labelClass'])}">
<cdk:body />
</span>
</span>
Deleted:
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java
===================================================================
---
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,49 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.faces.component.UIComponentBase;
-
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.cdk.annotations.TagType;
-
-/**
- * JSF component class
- *
- */
-@JsfComponent(tag = @Tag(type = TagType.Facelets),
- renderer = @JsfRenderer(type = "org.richfaces.PanelRenderer")
- )
-public class UIPanel extends UIComponentBase {
- private static final String COMPONENT_FAMILY = "org.richfaces.Panel";
-
- public boolean getRendersChildren() {
- return true;
- }
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-}
Copied: branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java
(from rev 20107, trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java)
===================================================================
--- branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java
(rev 0)
+++
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -0,0 +1,49 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
+
+/**
+ * JSF component class
+ *
+ */
+@JsfComponent(tag = @Tag(type = TagType.Facelets),
+ renderer = @JsfRenderer(type = "org.richfaces.PanelRenderer")
+ )
+public class UIPanel extends UIComponentBase {
+ private static final String COMPONENT_FAMILY = "org.richfaces.Panel";
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+}
Modified:
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
===================================================================
---
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -206,7 +206,7 @@
addToScriptHash(options, "onbeforeshow",
buildEventFunction(attributes.get("onbeforeshow")));
addToScriptHash(options, "onbeforehide",
buildEventFunction(attributes.get("onbeforehide")));
- result.append(ScriptUtils.toScript(options));
+ ScriptUtils.appendScript(result, options);
result.append(");");
return result.toString();
}
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -18,7 +18,7 @@
}
- protected void finishValidation(StringBuffer body) {
+ protected void finishValidation(StringBuilder body) {
// AJAX callback
body.append("if(!").append(DISABLE_AJAX).append("){\n");
body.append(ajaxScript).append(EOL).append("}\n");
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -36,35 +36,35 @@
@Override
protected Object buildBody() {
- StringBuffer body = new StringBuffer();
+ StringBuilder body = new StringBuilder();
// Get component value by clientId.
body.append("var
").append(ClientValidatorRenderer.VALUE_VAR).append("=");
- GET_VALUE_FUNCTION.appendScript(body);
+ GET_VALUE_FUNCTION.appendScriptToStringBuilder(body);
body.append(EOL);
// Try client-side validation
body.append("try {\n");
// convert value
body.append("var
").append(ClientValidatorRenderer.CONVERTED_VALUE_VAR).append("=");
- converter.appendScript(body);
+ converter.appendScriptToStringBuilder(body);
body.append(EOL);
// call validators
for (LibraryScriptString validatorScript : validators) {
- validatorScript.appendScript(body);
+ validatorScript.appendScriptToStringBuilder(body);
body.append(EOL);
}
finishValidation(body);
body.append("return true;\n");
// Catch errors
body.append("} catch(e) {\n");
- SEND_ERROR_FUNCTION.appendScript(body);body.append(EOL);
+ SEND_ERROR_FUNCTION.appendScriptToStringBuilder(body);body.append(EOL);
body.append("return false;\n}");
return body;
}
- protected void finishValidation(StringBuffer body) {
+ protected void finishValidation(StringBuilder body) {
// clear messages after successful validation
body.append("if(!").append(DISABLE_AJAX).append("){\n");
- CLEAR_ERROR_FUNCTION.appendScript(body);
+ CLEAR_ERROR_FUNCTION.appendScriptToStringBuilder(body);
body.append(EOL).append("}\n");
}
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,5 +1,7 @@
package org.richfaces.renderkit.html;
+import java.io.IOException;
+
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSLiteral;
@@ -29,13 +31,13 @@
super(CLIENT_ID,ELEMENT,EVENT,DISABLE_AJAX);
}
- public void appendScript(StringBuffer functionString) {
+ public void appendScript(Appendable target) throws IOException {
if(!bodyProcessed){
// pending RF-9565
addToBody(buildBody());
bodyProcessed = true;
}
- super.appendScript(functionString);
+ super.appendScript(target);
}
protected abstract Object buildBody();
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -3,6 +3,7 @@
*/
package org.richfaces.component;
+import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
@@ -36,10 +37,18 @@
return TEST_SCRIPT;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(TEST_SCRIPT);
+ public void appendScript(Appendable target) throws IOException {
+ target.append(TEST_SCRIPT);
}
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+
public Collection<LibraryResource> getResources() {
return Collections.singleton(TEST_RESOURCE);
}
@@ -51,6 +60,7 @@
public String createCallScript(String clientId,String sourceId) {
return FOO+"("+clientId+")";
}
+
};
private String value=FOO_VALUE;
Modified:
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
===================================================================
---
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-18
18:50:06 UTC (rev 20107)
+++
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-18
23:14:43 UTC (rev 20108)
@@ -1,8 +1,10 @@
package org.richfaces.component;
-import org.richfaces.javascript.LibraryResource;
-import org.richfaces.javascript.LibraryScriptString;
+import java.io.IOException;
+import org.richfaces.validator.LibraryResource;
+import org.richfaces.validator.LibraryScriptString;
+
final class Script implements LibraryScriptString {
private final String name;
@@ -14,11 +16,18 @@
return name;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(name);
-
+ public void appendScript(Appendable target) throws IOException {
+ target.append(name);
}
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+
public LibraryResource getResource() {
return UIValidatorScriptCollectionTest.FOO_RESOURCE;
}