JBoss Rich Faces SVN: r19797 - trunk/ui/input/ui/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-10-31 11:21:51 -0400 (Sun, 31 Oct 2010)
New Revision: 19797
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
Log:
https://jira.jboss.org/browse/RF-9596
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-10-31 14:54:14 UTC (rev 19796)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-10-31 15:21:51 UTC (rev 19797)
@@ -69,7 +69,7 @@
@ResourceDependency(library = "org.richfaces", name = "json-dom.js"),
@ResourceDependency(library = "org.richfaces", name = "jquery.effects.core.js"),
@ResourceDependency(library = "org.richfaces", name = "jquery.effects.highlight.js"),
- @ResourceDependency(library = "org.richfaces", name = "JQuerySpinBtn.js.js"),
+ @ResourceDependency(library = "org.richfaces", name = "JQuerySpinBtn.js"),
@ResourceDependency(library = "org.richfaces", name = "calendar-utils.js"),
@ResourceDependency(library = "org.richfaces", name = "calendar.js"),
@ResourceDependency(library = "org.richfaces", name = "calendar.ecss") })
14 years, 2 months
JBoss Rich Faces SVN: r19796 - in sandbox/trunk/ui/tree-actual/ui/src/main: resources/META-INF/resources/org.richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-31 10:54:14 -0400 (Sun, 31 Oct 2010)
New Revision: 19796
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml
sandbox/trunk/ui/tree-actual/ui/src/main/templates/treeNode.template.xml
Log:
https://jira.jboss.org/browse/RF-9315
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-10-31 14:01:38 UTC (rev 19795)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-10-31 14:54:14 UTC (rev 19796)
@@ -29,6 +29,7 @@
import javax.faces.context.ResponseWriter;
import org.richfaces.component.AbstractTree;
+import org.richfaces.component.SwitchType;
import org.richfaces.component.util.HtmlUtil;
import org.richfaces.renderkit.TreeRendererBase.NodeState;
import org.richfaces.renderkit.TreeRendererBase.QueuedData;
@@ -49,6 +50,8 @@
protected final AbstractTree tree;
+ private boolean traverseCollapsedNode;
+
private LinkedList<QueuedData> queuedData = new LinkedList<QueuedData>();
public TreeEncoderBase(FacesContext context, AbstractTree tree) {
@@ -56,6 +59,8 @@
this.context = context;
this.responseWriter = context.getResponseWriter();
this.tree = tree;
+
+ this.traverseCollapsedNode = SwitchType.client.equals(tree.getToggleMode());
}
protected void encodeTree(Iterator<Object> childrenIterator) throws IOException {
@@ -85,18 +90,19 @@
if (!data.isEncoded()) {
tree.setRowKey(context, data.getRowKey());
- writeTreeNodeStartElement(NodeState.expanded, data.isLastNode());
+ writeTreeNodeStartElement(data.isExpanded() ? NodeState.expanded : NodeState.collapsed, data.isLastNode());
data.setEncoded(true);
}
}
-
- queuedData.add(new QueuedData(rowKey, isLastNode));
tree.setRowKey(context, rowKey);
- boolean iterateChildren = tree.isExpanded();
+ boolean expanded = tree.isExpanded();
+ queuedData.add(new QueuedData(rowKey, isLastNode, expanded));
+ boolean iterateChildren = traverseCollapsedNode || expanded;
+
if (iterateChildren) {
encodeTree(tree.getChildrenIterator(context, rowKey));
}
@@ -116,7 +122,7 @@
responseWriter.startElement(HtmlConstants.DIV_ELEM, tree);
responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses("tree_node", isLast ? "tree_node_last" : null),
+ HtmlUtil.concatClasses("rf-tr-nd", isLast ? "rf-tr-nd-last" : null, nodeState.getNodeClass()),
null);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE, tree.getClientId(context), null);
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-10-31 14:01:38 UTC (rev 19795)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-10-31 14:54:14 UTC (rev 19796)
@@ -63,24 +63,34 @@
private static final String NEW_STATE_PARAM = "org.richfaces.Tree.NEW_STATE";
enum NodeState {
- expanded("tree_handle_expanded", "tree_icon_node"),
- collapsed("tree_handle_collapsed", "tree_icon_node"),
- leaf("tree_handle_leaf", "tree_icon_leaf");
+ 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 handleClass, 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 {
@@ -89,11 +99,14 @@
private boolean lastNode;
+ private boolean expanded;
+
private boolean encoded;
- public QueuedData(Object rowKey, boolean lastNode) {
+ public QueuedData(Object rowKey, boolean lastNode, boolean expanded) {
this.rowKey = rowKey;
this.lastNode = lastNode;
+ this.expanded = expanded;
}
public void setEncoded(boolean encoded) {
@@ -111,6 +124,10 @@
public boolean isLastNode() {
return lastNode;
}
+
+ public boolean isExpanded() {
+ return expanded;
+ }
}
public void encodeTree(FacesContext context, UIComponent component) throws IOException {
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-10-31 14:01:38 UTC (rev 19795)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-10-31 14:54:14 UTC (rev 19796)
@@ -1,4 +1,4 @@
-.tree_item {
+.rf-trn {
background: "url(#{resource['org.richfaces.images:last.gif']}) no-repeat center left";
cursor: default;
font-size: '#{richSkin.generalSizeFont}';
@@ -10,34 +10,34 @@
white-space: nowrap;
}
-.tree_item_label {
+.rf-trn-lbl {
padding: 0px 4px 0px 2px;
vertical-align: middle;
cursor: pointer;
display: inline-block;
}
-.tree_selarea {
+.rf-trn-cnt {
display: inline-block;
}
-.tree_selected {
+.rf-tr-nd-sel {
background: '#{richSkin.additionalBackgroundColor}';
}
-.tree_node {
+.rf-tr-nd {
background: "url(#{resource['org.richfaces.images:line.gif']}) repeat-y";
}
-.tree_node_last {
+.rf-tr-nd-last {
background: none;
}
-.tree_node .tree_node {
+.rf-tr-nd .rf-tr-nd {
margin-left: 16px;
}
-.tree_icon, .tree_handle {
+.rf-trn-ico, .rf-trn-hnd {
vertical-align: middle;
margin: 0px;
cursor: pointer;
@@ -46,26 +46,26 @@
display: inline-block;
}
-.tree_handle_leaf {
+.rf-trn-hnd-lf {
cursor: default;
}
-.tree_handle_collapsed {
+.rf-trn-hnd-colps {
background: "url(#{resource['org.richfaces.images:plus.gif']}) no-repeat center";
}
-.tree_handle_expanded {
+.rf-trn-hnd-exp {
background: "url(#{resource['org.richfaces.images:minus.gif']}) no-repeat center";
}
-.tree_icon_node {
+.rf-trn-ico-nd {
background: "url(#{resource['org.richfaces.images:node_icon.gif']}) no-repeat center";
}
-.tree_icon_leaf {
+.rf-trn-ico-lf {
background: "url(#{resource['org.richfaces.images:leaf_icon.gif']}) no-repeat center";
}
-.tree_node.tree_collapse .tree_node {
+.rf-tr-nd.rf-tr-nd-colps .rf-tr-nd {
display: none;
}
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-10-31 14:01:38 UTC (rev 19795)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-10-31 14:54:14 UTC (rev 19796)
@@ -23,7 +23,7 @@
var __initializeChildNodes = function(elt) {
var _this = this;
- $(elt).children(".tree_node").each(function() {
+ $(elt).children(".rf-tr-nd").each(function() {
_this.addChild(new richfaces.ui.TreeNode(this));
});
}
@@ -34,9 +34,9 @@
var TOGGLE_NEW_STATE_PARAM = "org.richfaces.Tree.NEW_STATE";
- var TREE_HANDLE_CLASSES = ["tree_collapse", "tree_expand"];
+ var TREE_CLASSES = ["rf-tr-nd-colps", "rf-tr-nd-exp"];
- var TREE_CLASSES = ["tree_handle_collapsed", "tree_handle_expanded"];
+ var TREE_HANDLE_CLASSES = ["rf-trn-hnd-colps", "rf-trn-hnd-exp"];
richfaces.ui = richfaces.ui || {};
@@ -51,7 +51,7 @@
this.elt = $(this.attachToDom());
- this.handler = this.elt.find(" > .tree_item:first > .tree_handle:first");
+ this.handler = this.elt.find(" > .rf-trn:first > .rf-trn-hnd:first");
this.handler.click($.proxy(this.toggle, this));
__initializeChildNodes.call(this, this.elt[0]);
@@ -100,15 +100,15 @@
},
isExpanded: function() {
- return !this.isLeaf() && !this.isCollapsed();
+ return !this.isLeaf() && this.handler.hasClass("rf-trn-hnd-exp");
},
isCollapsed: function() {
- return !this.isLeaf() && this.handler.hasClass("tree_handle_collapsed");
+ return !this.isLeaf() && this.handler.hasClass("rf-trn-hnd-colps");
},
isLeaf: function() {
- return this.handler.hasClass("tree_handle_leaf");
+ return this.handler.hasClass("rf-trn-hnd-lf");
},
toggle: function() {
@@ -129,8 +129,8 @@
switch (tree.getToggleMode()) {
case 'client':
- this.elt.addClass(TREE_HANDLE_CLASSES[newState ? 1 : 0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
- this.handler.addClass(TREE_CLASSES[newState ? 1 : 0]).removeClass(TREE_CLASSES[!newState ? 1 : 0]);
+ this.elt.addClass(TREE_CLASSES[newState ? 1 : 0]).removeClass(TREE_CLASSES[!newState ? 1 : 0]);
+ this.handler.addClass(TREE_HANDLE_CLASSES[newState ? 1 : 0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
break;
case 'ajax':
@@ -177,13 +177,13 @@
richfaces.ui.TreeNode.initNodeByAjax = function(nodeId) {
var node = $(document.getElementById(nodeId));
- if (node.nextAll(".tree_node:first").length != 0) {
- node.removeClass("tree_node_last");
+ if (node.nextAll(".rf-tr-nd:first").length != 0) {
+ node.removeClass("rf-tr-nd-last");
}
- var parent = node.parent(".tree_node, .rf-tree");
+ var parent = node.parent(".rf-tr-nd, .rf-tr");
- var idx = node.prevAll(".tree_node").length;
+ var idx = node.prevAll(".rf-tr-nd").length;
var parentNode = richfaces.$(parent[0]);
parentNode.addChild(new richfaces.ui.TreeNode(node[0]), idx);
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml 2010-10-31 14:01:38 UTC (rev 19795)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml 2010-10-31 14:54:14 UTC (rev 19796)
@@ -19,7 +19,7 @@
</cc:interface>
<cc:implementation>
- <div id="#{clientId}" class="#{concatClasses('rf-tree', component.attributes['styleClass'])}"
+ <div id="#{clientId}" class="#{concatClasses('rf-tr', component.attributes['styleClass'])}"
cdk:passThroughWithExclusions="">
<cdk:body>
<cdk:call expression="encodeTree(facesContext, component)" />
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/templates/treeNode.template.xml
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/templates/treeNode.template.xml 2010-10-31 14:01:38 UTC (rev 19795)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/templates/treeNode.template.xml 2010-10-31 14:54:14 UTC (rev 19796)
@@ -16,11 +16,11 @@
</cc:interface>
<cc:implementation>
- <div class="tree_item">
- <div class="tree_handle #{facesContext.attributes['__treeNodeHandleClass']}"></div>
- <div class="tree_selarea">
- <div class="tree_icon #{facesContext.attributes['__treeNodeIconClass']}"></div>
- <span class="tree_item_label">
+ <div class="rf-trn">
+ <div class="rf-trn-hnd #{facesContext.attributes['__treeNodeHandleClass']}"></div>
+ <div class="rf-trn-cnt">
+ <div class="rf-trn-ico #{facesContext.attributes['__treeNodeIconClass']}"></div>
+ <span class="rf-trn-lbl">
<cdk:body />
</span>
</div>
14 years, 2 months
JBoss Rich Faces SVN: r19795 - in sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF: richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-31 10:01:38 -0400 (Sun, 31 Oct 2010)
New Revision: 19795
Added:
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/richfaces/
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
Log:
https://jira.jboss.org/browse/RF-9315
Added: sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties (rev 0)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-10-31 14:01:38 UTC (rev 19795)
@@ -0,0 +1,6 @@
+org.richfaces.images\:last.gif=org.richfaces\:last.gif
+org.richfaces.images\:line.gif=org.richfaces\:line.gif
+org.richfaces.images\:plus.gif=org.richfaces\:plus.gif
+org.richfaces.images\:minus.gif=org.richfaces\:minus.gif
+org.richfaces.images\:node_icon.gif=org.richfaces\:node_icon.gif
+org.richfaces.images\:leaf_icon.gif=org.richfaces\:leaf_icon.gif
14 years, 2 months
JBoss Rich Faces SVN: r19794 - in sandbox/trunk/ui/tree-actual/ui/src/main: java/org/richfaces/model and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-31 09:44:08 -0400 (Sun, 31 Oct 2010)
New Revision: 19794
Added:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java
Removed:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeDecoderHelper.java
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
Log:
https://jira.jboss.org/browse/RF-9315
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-10-31 13:42:28 UTC (rev 19793)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-10-31 13:44:08 UTC (rev 19794)
@@ -21,6 +21,7 @@
*/
package org.richfaces.component;
+import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
@@ -30,6 +31,8 @@
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UpdateModelException;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.event.AbortProcessingException;
@@ -48,9 +51,11 @@
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.component.util.MessageUtil;
+import org.richfaces.context.ExtendedVisitContext;
import org.richfaces.convert.SequenceRowKeyConverter;
import org.richfaces.event.TreeToggleEvent;
import org.richfaces.model.TreeDataModelImpl;
+import org.richfaces.renderkit.MetaComponentRenderer;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterators;
@@ -65,12 +70,14 @@
tag = @Tag(name = "tree"),
renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer")
)
-public abstract class AbstractTree extends UIDataAdaptor {
+public abstract class AbstractTree extends UIDataAdaptor implements MetaComponentProcessor, MetaComponentResolver, MetaComponentEncoder {
public static final String COMPONENT_TYPE = "org.richfaces.Tree";
public static final String COMPONENT_FAMILY = "org.richfaces.Tree";
+ public static final String NODE_META_COMPONENT_ID = "node";
+
private static final Predicate<UIComponent> RENDERED_UITREE_NODE = new Predicate<UIComponent>() {
public boolean apply(UIComponent input) {
return (input instanceof AbstractTreeNode) && input.isRendered();
@@ -83,8 +90,6 @@
expanded
}
- private transient UIComponent decoderHelper = null;
-
public AbstractTree() {
setRendererType("org.richfaces.TreeRenderer");
}
@@ -237,21 +242,32 @@
}
@Override
- public void decode(FacesContext context) {
- try {
- decoderHelper = new TreeDecoderHelper(this);
- super.decode(context);
- } finally {
- decoderHelper = null;
+ protected VisitResult visitDataChildrenMetaComponents(ExtendedVisitContext extendedVisitContext,
+ VisitCallback callback) {
+
+ VisitResult result = extendedVisitContext.invokeMetaComponentVisitCallback(this, callback, NODE_META_COMPONENT_ID);
+ if (result != VisitResult.ACCEPT) {
+ return result;
}
+
+ return super.visitDataChildrenMetaComponents(extendedVisitContext, callback);
}
- @Override
- protected Iterator<UIComponent> dataChildren() {
- if (decoderHelper != null) {
- return Iterators.concat(super.dataChildren(), Iterators.<UIComponent>singletonIterator(decoderHelper));
- } else {
- return super.dataChildren();
+ public void processMetaComponent(FacesContext context, String metaComponentId) {
+ if (context.getCurrentPhaseId() == PhaseId.APPLY_REQUEST_VALUES) {
+ ((MetaComponentRenderer) getRenderer(context)).decodeMetaComponent(context, this, metaComponentId);
}
}
+
+ 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 (NODE_META_COMPONENT_ID.equals(metaComponentId)) {
+ return getClientId(facesContext) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
+ }
+
+ return null;
+ }
}
Deleted: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeDecoderHelper.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeDecoderHelper.java 2010-10-31 13:42:28 UTC (rev 19793)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeDecoderHelper.java 2010-10-31 13:44:08 UTC (rev 19794)
@@ -1,64 +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.component;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-
-/**
- * @author Nick Belaevski
- *
- */
-public final class TreeDecoderHelper extends UIComponentBase {
-
- public static final String HELPER_ID = "__treeDecoderHelper";
-
- private AbstractTree tree;
-
- public TreeDecoderHelper(AbstractTree tree) {
- super();
- this.tree = tree;
- setId(HELPER_ID);
- setTransient(true);
- }
-
- @Override
- public boolean isInView() {
- return tree.isInView();
- }
-
- @Override
- public boolean isRendered() {
- return tree.isRendered();
- }
-
- @Override
- public String getFamily() {
- return null;
- }
-
- @Override
- public UIComponent getParent() {
- return tree;
- }
-
-}
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-10-31 13:42:28 UTC (rev 19793)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-10-31 13:44:08 UTC (rev 19794)
@@ -28,6 +28,7 @@
import javax.faces.context.FacesContext;
import javax.swing.tree.TreeNode;
+import org.ajax4jsf.model.DataVisitResult;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.Range;
@@ -170,10 +171,11 @@
while (keysIterator.hasNext()) {
Object object = (Object) keysIterator.next();
- visitor.process(context, object, argument);
-
- Iterator<Object> childrenIterator = getChildrenIterator(context, object);
- walk(context, visitor, range, argument, childrenIterator);
+ DataVisitResult visitResult = visitor.process(context, object, argument);
+ if (visitResult == DataVisitResult.CONTINUE) {
+ Iterator<Object> childrenIterator = getChildrenIterator(context, object);
+ walk(context, visitor, range, argument, childrenIterator);
+ }
}
}
Added: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java (rev 0)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-10-31 13:44:08 UTC (rev 19794)
@@ -0,0 +1,132 @@
+/*
+ * 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 java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.richfaces.component.AbstractTree;
+import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.TreeRendererBase.NodeState;
+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 {
+
+ 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 LinkedList<QueuedData> queuedData = new LinkedList<QueuedData>();
+
+ public TreeEncoderBase(FacesContext context, AbstractTree tree) {
+ super();
+ this.context = context;
+ this.responseWriter = context.getResponseWriter();
+ this.tree = tree;
+ }
+
+ 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;
+ }
+
+ return tree.getTreeNodeComponent() != null;
+ }
+ };
+
+ UnmodifiableIterator<Object> filteredIterator = Iterators.filter(childrenIterator, renderedTreeNodeKeyPredicate);
+ while (filteredIterator.hasNext()) {
+ Object rowKey = filteredIterator.next();
+
+ encodeTreeNode(rowKey, !filteredIterator.hasNext());
+ }
+ }
+
+ 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(NodeState.expanded, data.isLastNode());
+
+ data.setEncoded(true);
+ }
+ }
+
+ queuedData.add(new QueuedData(rowKey, isLastNode));
+
+ tree.setRowKey(context, rowKey);
+
+ boolean iterateChildren = tree.isExpanded();
+
+ if (iterateChildren) {
+ encodeTree(tree.getChildrenIterator(context, rowKey));
+ }
+
+ QueuedData data = queuedData.removeLast();
+ if (!data.isEncoded()) {
+ NodeState nodeState = iterateChildren ? NodeState.leaf : NodeState.collapsed;
+ writeTreeNodeStartElement(nodeState, data.isLastNode());
+ }
+
+ writeTreeNodeEndElement();
+ }
+
+ protected void writeTreeNodeStartElement(NodeState nodeState, boolean isLast) throws IOException {
+ context.getAttributes().put(TREE_NODE_HANDLE_CLASS_ATTRIBUTE, nodeState.getHandleClass());
+ context.getAttributes().put(TREE_NODE_ICON_CLASS_ATTRIBUTE, nodeState.getIconClass());
+
+ responseWriter.startElement(HtmlConstants.DIV_ELEM, tree);
+ responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
+ HtmlUtil.concatClasses("tree_node", isLast ? "tree_node_last" : null),
+ null);
+ responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE, tree.getClientId(context), null);
+
+ tree.getTreeNodeComponent().encodeAll(context);
+ }
+
+ protected void writeTreeNodeEndElement() throws IOException {
+ responseWriter.endElement(HtmlConstants.DIV_ELEM);
+ }
+
+ public abstract void encode() throws IOException;
+
+}
\ No newline at end of file
Added: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java (rev 0)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java 2010-10-31 13:44:08 UTC (rev 19794)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.AbstractTree;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+class TreeEncoderFull extends TreeEncoderBase {
+
+ public TreeEncoderFull(FacesContext context, AbstractTree tree) {
+ super(context, tree);
+ }
+
+ public void encode() throws java.io.IOException {
+ Object initialRowKey = tree.getRowKey();
+ try {
+ encodeTree(tree.getChildrenIterator(context, null));
+ } finally {
+ try {
+ tree.setRowKey(context, initialRowKey);
+ } catch (Exception e) {
+ TreeRendererBase.LOGGER.error(e.getMessage(), e);
+ }
+ }
+ }
+}
Added: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java (rev 0)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java 2010-10-31 13:44:08 UTC (rev 19794)
@@ -0,0 +1,75 @@
+/*
+ * 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 java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.PartialResponseWriter;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.component.AbstractTree;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+class TreeEncoderPartial extends TreeEncoderBase {
+
+ private Object rowKey;
+
+ public TreeEncoderPartial(FacesContext context, AbstractTree tree) {
+ super(context, tree);
+
+ this.rowKey = tree.getRowKey();
+
+ if (this.rowKey == null) {
+ throw new NullPointerException("rowKey");
+ }
+ }
+
+ @Override
+ public void encode() throws IOException {
+ PartialResponseWriter prw = context.getPartialViewContext().getPartialResponseWriter();
+ prw.startUpdate(tree.getClientId(context));
+
+ Object initialRowKey = tree.getRowKey();
+ try {
+
+ encodeTreeNode(rowKey, true);
+
+ prw.endUpdate();
+
+ } finally {
+ try {
+ tree.setRowKey(context, initialRowKey);
+ } catch (Exception e) {
+ TreeRendererBase.LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ prw.startEval();
+ JSFunction function = new JSFunction("RichFaces.ui.TreeNode.initNodeByAjax", tree.getClientId(context));
+ prw.write(function.toScript());
+ prw.endEval();
+ }
+}
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-10-31 13:42:28 UTC (rev 19793)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-10-31 13:44:08 UTC (rev 19794)
@@ -21,64 +21,69 @@
*/
package org.richfaces.renderkit;
+import static org.richfaces.component.AbstractTree.NODE_META_COMPONENT_ID;
import static org.richfaces.renderkit.util.AjaxRendererUtils.AJAX_FUNCTION_NAME;
import static org.richfaces.renderkit.util.AjaxRendererUtils.buildAjaxFunction;
import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
import java.io.IOException;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.LinkedList;
import java.util.Map;
import javax.faces.component.UIComponent;
-import javax.faces.component.UINamingContainer;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitHint;
-import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
+import javax.faces.context.PartialViewContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSReference;
import org.richfaces.component.AbstractTree;
import org.richfaces.component.AbstractTreeNode;
+import org.richfaces.component.MetaComponentResolver;
import org.richfaces.component.SwitchType;
-import org.richfaces.component.TreeDecoderHelper;
-import org.richfaces.component.util.HtmlUtil;
import org.richfaces.event.TreeToggleEvent;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.UnmodifiableIterator;
/**
* @author Nick Belaevski
*
*/
-public abstract class TreeRendererBase extends RendererBase {
+public abstract class TreeRendererBase extends RendererBase implements MetaComponentRenderer {
- private static final Logger LOGGER = RichfacesLogger.RENDERKIT.getLogger();
+ static final Logger LOGGER = RichfacesLogger.RENDERKIT.getLogger();
- private static final String TOGGLE_DATA = "toggleData";
+ private static final JSReference TOGGLE_PARAMS = new JSReference("toggleParams");
+ private static final JSReference TOGGLE_SOURCE = new JSReference("toggleSource");
+
private static final String TREE_TOGGLE_ID_PARAM = "org.richfaces.Tree.TREE_TOGGLE_ID";
private static final String NODE_TOGGLE_ID_PARAM = "org.richfaces.Tree.NODE_TOGGLE_ID";
private static final String NEW_STATE_PARAM = "org.richfaces.Tree.NEW_STATE";
- private static final JSReference JS_TREE_ID = new JSReference(TOGGLE_DATA + ".treeId");
-
- private static final JSReference JS_NODE_ID = new JSReference(TOGGLE_DATA + ".nodeId");
+ enum NodeState {
+ expanded("tree_handle_expanded", "tree_icon_node"),
+ collapsed("tree_handle_collapsed", "tree_icon_node"),
+ leaf("tree_handle_leaf", "tree_icon_leaf");
+
+ private String handleClass;
+
+ private String iconClass;
- private static final JSReference JS_NEW_STATE = new JSReference(TOGGLE_DATA + ".treeId");
-
- private static final class QueuedData {
+ private NodeState(String handleClass, String iconClass) {
+ this.handleClass = handleClass;
+ this.iconClass = iconClass;
+ }
+ public String getHandleClass() {
+ return handleClass;
+ }
+ public String getIconClass() {
+ return iconClass;
+ }
+ }
+
+ static final class QueuedData {
private Object rowKey;
@@ -108,109 +113,10 @@
}
}
- private class TreeEncoder {
-
- private static final String TREE_NODE_HANDLE_CLASS_ATTRIBUTE = "__treeNodeHandleClass";
-
- private static final String TREE_NODE_ICON_CLASS_ATTRIBUTE = "__treeNodeIconClass";
-
- private FacesContext context;
-
- private ResponseWriter responseWriter;
-
- private AbstractTree tree;
-
- private LinkedList<QueuedData> queuedData = new LinkedList<QueuedData>();
-
- public TreeEncoder(FacesContext context, AbstractTree tree) {
- super();
- this.context = context;
- this.responseWriter = context.getResponseWriter();
- this.tree = tree;
- }
-
- 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;
- }
-
- return tree.getTreeNodeComponent() != null;
- }
- };
-
- UnmodifiableIterator<Object> filteredIterator = Iterators.filter(childrenIterator, renderedTreeNodeKeyPredicate);
- while (filteredIterator.hasNext()) {
- Object rowKey = filteredIterator.next();
-
- encodeTreeNode(rowKey, !filteredIterator.hasNext());
- }
- }
-
- 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.isLastNode(), false);
-
- data.setEncoded(true);
- }
- }
-
- queuedData.add(new QueuedData(rowKey, isLastNode));
-
- tree.setRowKey(context, rowKey);
-
- encodeTree(tree.getChildrenIterator(context, rowKey));
-
- QueuedData data = queuedData.removeLast();
- if (!data.isEncoded()) {
- writeTreeNodeStartElement(data.isLastNode(), true);
- }
-
- writeTreeNodeEndElement();
- }
-
- protected void writeTreeNodeStartElement(boolean isLast, boolean isLeaf) throws IOException {
- context.getAttributes().put(TREE_NODE_HANDLE_CLASS_ATTRIBUTE, isLeaf ? "tree_handle_leaf" : "tree_handle_expanded");
- context.getAttributes().put(TREE_NODE_ICON_CLASS_ATTRIBUTE, isLeaf ? "tree_icon_leaf" : "tree_icon_node");
-
- responseWriter.startElement(HtmlConstants.DIV_ELEM, tree);
- responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses("tree_node", isLast ? "tree_node_last" : null),
- null);
- responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE, tree.getClientId(context), null);
-
- tree.getTreeNodeComponent().encodeAll(context);
- }
-
- protected void writeTreeNodeEndElement() throws IOException {
- responseWriter.endElement(HtmlConstants.DIV_ELEM);
- }
-
- public void encode() throws IOException {
- Object initialRowKey = tree.getRowKey();
- try {
- encodeTree(tree.getChildrenIterator(context, null));
- } finally {
- try {
- tree.setRowKey(context, initialRowKey);
- } catch (Exception e) {
- LOGGER.error(e.getMessage(), e);
- }
- }
- }
- }
-
public void encodeTree(FacesContext context, UIComponent component) throws IOException {
AbstractTree tree = (AbstractTree) component;
- new TreeEncoder(context, tree).encode();
+ new TreeEncoderFull(context, tree).encode();
}
protected String getAjaxToggler(FacesContext context, UIComponent component) {
@@ -223,9 +129,8 @@
JSFunction ajaxFunction = buildAjaxFunction(context, component, AJAX_FUNCTION_NAME);
AjaxEventOptions eventOptions = buildEventOptions(context, component);
- eventOptions.setParameter(TREE_TOGGLE_ID_PARAM, JS_TREE_ID);
- eventOptions.setParameter(NODE_TOGGLE_ID_PARAM, JS_NODE_ID);
- eventOptions.setParameter(NEW_STATE_PARAM, JS_NEW_STATE);
+ eventOptions.setAjaxComponent(TOGGLE_SOURCE);
+ eventOptions.setClientParameters(TOGGLE_PARAMS);
if (!eventOptions.isEmpty()) {
ajaxFunction.addParameter(eventOptions);
@@ -238,35 +143,44 @@
protected void doDecode(FacesContext context, UIComponent component) {
super.doDecode(context, component);
- final Map<String, String> map = context.getExternalContext().getRequestParameterMap();
- String toggleId = map.get(TREE_TOGGLE_ID_PARAM);
- if (component.getClientId(context).equals(toggleId)) {
-
- String nodeId = map.get(NODE_TOGGLE_ID_PARAM) + UINamingContainer.getSeparatorChar(context)
- + TreeDecoderHelper.HELPER_ID;
-
- VisitContext visitContext = createVisitContext(context, nodeId);
- component.visitTree(visitContext, new VisitCallback() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.renderkit.MetaComponentRenderer#encodeMetaComponent(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
+ */
+ public void encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId)
+ throws IOException {
+
+ if (NODE_META_COMPONENT_ID.equals(metaComponentId)) {
+ AbstractTree tree = (AbstractTree) component;
+ new TreeEncoderPartial(context, tree).encode();
+ } else {
+ throw new IllegalArgumentException(metaComponentId);
+ }
+
+ // TODO Auto-generated method stub
+
+ }
+
+ public void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) {
+ if (NODE_META_COMPONENT_ID.equals(metaComponentId)) {
+ final Map<String, String> map = context.getExternalContext().getRequestParameterMap();
+ String toggleId = map.get(NODE_TOGGLE_ID_PARAM);
+ if (component.getClientId(context).equals(toggleId)) {
- public VisitResult visit(VisitContext context, UIComponent target) {
- AbstractTree tree = (AbstractTree) target.getParent();
- AbstractTreeNode treeNode = tree.getTreeNodeComponent();
- if (treeNode != null) {
- boolean expanded = Boolean.valueOf(map.get(NEW_STATE_PARAM));
- if (tree.isExpanded() ^ expanded) {
- new TreeToggleEvent(treeNode, expanded);
- }
- }
-
- return VisitResult.COMPLETE;
+ AbstractTree tree = (AbstractTree) component;
+ AbstractTreeNode treeNode = tree.getTreeNodeComponent();
+ boolean expanded = Boolean.valueOf(map.get(NEW_STATE_PARAM));
+ if (tree.isExpanded() ^ expanded) {
+ new TreeToggleEvent(treeNode, expanded).queue();
}
- });
-
+
+ PartialViewContext pvc = context.getPartialViewContext();
+ if (pvc.isAjaxRequest()) {
+ pvc.getRenderIds().add(tree.getClientId(context) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + "node");
+ }
+ }
}
}
-
- private VisitContext createVisitContext(FacesContext context, String nodeId) {
- return VisitContext.createVisitContext(context, Collections.singleton(nodeId),
- EnumSet.<VisitHint>of(VisitHint.SKIP_UNRENDERED));
- }
+
}
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-10-31 13:42:28 UTC (rev 19793)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-10-31 13:44:08 UTC (rev 19794)
@@ -28,6 +28,12 @@
});
}
+ var TOGGLE_TREE_ID_PARAM = "org.richfaces.Tree.TREE_TOGGLE_ID";
+
+ var TOGGLE_NODE_ID_PARAM = "org.richfaces.Tree.NODE_TOGGLE_ID";
+
+ var TOGGLE_NEW_STATE_PARAM = "org.richfaces.Tree.NEW_STATE";
+
var TREE_HANDLE_CLASSES = ["tree_collapse", "tree_expand"];
var TREE_CLASSES = ["tree_handle_collapsed", "tree_handle_expanded"];
@@ -98,7 +104,7 @@
},
isCollapsed: function() {
- return !this.isLeaf() && this.elt.hasClass("tree_collapse");
+ return !this.isLeaf() && this.handler.hasClass("tree_handle_collapsed");
},
isLeaf: function() {
@@ -128,13 +134,8 @@
break;
case 'ajax':
- var toggleData = {
- nodeId: richfaces.getDomElement(this.id).id,
- newState: newState
- };
-
//TODO - event?
- tree.toggleByAjax(null, toggleData);
+ tree.toggleByAjax(null, richfaces.getDomElement(this.id).id, newState);
break;
case 'server':
@@ -173,6 +174,21 @@
}
});
+ richfaces.ui.TreeNode.initNodeByAjax = function(nodeId) {
+ var node = $(document.getElementById(nodeId));
+
+ if (node.nextAll(".tree_node:first").length != 0) {
+ node.removeClass("tree_node_last");
+ }
+
+ var parent = node.parent(".tree_node, .rf-tree");
+
+ var idx = node.prevAll(".tree_node").length;
+
+ var parentNode = richfaces.$(parent[0]);
+ parentNode.addChild(new richfaces.ui.TreeNode(node[0]), idx);
+ };
+
richfaces.ui.Tree = richfaces.ui.TreeNode.extendClass({
name: "Tree",
@@ -184,7 +200,7 @@
this.__selectionMode = options.selectionMode || 'ajax';
if (options.ajaxToggler) {
- this.__ajaxToggler = new Function("event", "toggleData", options.ajaxToggler);
+ this.__ajaxToggler = new Function("event", "toggleSource", "toggleParams", options.ajaxToggler);
}
},
@@ -194,9 +210,13 @@
this.__ajaxToggler = null;
},
- toggleByAjax: function(event, toggleData) {
- toggleData.treeId = this.id;
- this.__ajaxToggler(event, toggleData);
+ toggleByAjax: function(event, toggleSource, newNodeState) {
+ var clientParams = {};
+ clientParams[TOGGLE_NEW_STATE_PARAM] = newNodeState;
+ clientParams[TOGGLE_NODE_ID_PARAM] = toggleSource;
+ clientParams[TOGGLE_TREE_ID_PARAM] = this.id;
+
+ this.__ajaxToggler(event, toggleSource + '@node', clientParams);
},
getToggleMode: function() {
14 years, 2 months
JBoss Rich Faces SVN: r19793 - in trunk: core/api/src/main/java/org/richfaces/renderkit and 14 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-31 09:42:28 -0400 (Sun, 31 Oct 2010)
New Revision: 19793
Added:
trunk/core/api/src/main/java/org/richfaces/component/MetaComponentProcessor.java
trunk/core/impl/src/main/java/org/richfaces/context/BaseExtendedVisitContext.java
trunk/core/impl/src/main/java/org/richfaces/context/ExecuteExtendedVisitContext.java
trunk/core/impl/src/main/java/org/richfaces/context/PartialViewExecuteVisitCallback.java
trunk/core/impl/src/main/java/org/richfaces/context/RenderExtendedVisitContext.java
Removed:
trunk/core/impl/src/main/java/org/richfaces/context/ExtendedPartialVisitContext.java
Modified:
trunk/core/api/src/main/java/org/richfaces/renderkit/MetaComponentRenderer.java
trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java
trunk/core/impl/src/main/java/org/richfaces/context/ComponentMatcherNode.java
trunk/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
trunk/core/impl/src/main/java/org/richfaces/renderkit/util/CoreRendererUtils.java
trunk/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java
trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js
trunk/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java
trunk/core/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java
trunk/core/impl/src/test/resources/javascript/4_0_0.html
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeNodeParser.java
trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
trunk/ui/common/ui/src/main/java/org/richfaces/component/util/HtmlUtil.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
Log:
https://jira.jboss.org/browse/RF-9315
Added: trunk/core/api/src/main/java/org/richfaces/component/MetaComponentProcessor.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/component/MetaComponentProcessor.java (rev 0)
+++ trunk/core/api/src/main/java/org/richfaces/component/MetaComponentProcessor.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -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.component;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface MetaComponentProcessor {
+
+ public void processMetaComponent(FacesContext context, String metaComponentId);
+
+}
Modified: trunk/core/api/src/main/java/org/richfaces/renderkit/MetaComponentRenderer.java
===================================================================
--- trunk/core/api/src/main/java/org/richfaces/renderkit/MetaComponentRenderer.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/api/src/main/java/org/richfaces/renderkit/MetaComponentRenderer.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -35,4 +35,6 @@
public void encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId)
throws IOException;
+ public void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId);
+
}
Copied: trunk/core/impl/src/main/java/org/richfaces/context/BaseExtendedVisitContext.java (from rev 19768, trunk/core/impl/src/main/java/org/richfaces/context/ExtendedPartialVisitContext.java)
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/BaseExtendedVisitContext.java (rev 0)
+++ trunk/core/impl/src/main/java/org/richfaces/context/BaseExtendedVisitContext.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -0,0 +1,507 @@
+/*
+ * 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.context;
+
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitHint;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.MetaComponentResolver;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class BaseExtendedVisitContext extends ExtendedVisitContext {
+
+ static final String ANY_WILDCARD = "*";
+
+ private static final int SHORT_ID_IN_CLIENTID_SEGMENTS_NUMBER = 2;
+
+ private final class CollectionProxy extends AbstractCollection<String> {
+
+ private CollectionProxy() {
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return directNodesMap.isEmpty();
+ }
+
+ @Override
+ public int size() {
+ return directNodesMap.size();
+ }
+
+ @Override
+ public Iterator<String> iterator() {
+ return new IteratorProxy(directNodesMap.keySet().iterator());
+ }
+
+ @Override
+ public boolean add(String o) {
+ return addNode(o);
+ }
+ }
+ // Little proxy collection implementation. We proxy the id
+ // collection so that we can detect modifications and update
+ // our internal state when ids to visit are added or removed.
+
+ // Little proxy iterator implementation used by CollectionProxy
+ // so that we can catch removes.
+ private final class IteratorProxy implements Iterator<String> {
+
+ private Iterator<String> wrapped;
+
+ private String current = null;
+
+ private IteratorProxy(Iterator<String> wrapped) {
+ this.wrapped = wrapped;
+ }
+
+ public boolean hasNext() {
+ return wrapped.hasNext();
+ }
+
+ public String next() {
+ current = wrapped.next();
+
+ return current;
+ }
+
+ public void remove() {
+ if (current != null) {
+ ComponentMatcherNode node = directNodesMap.get(current);
+ removeNode(node);
+
+ current = null;
+ }
+
+ wrapped.remove();
+ }
+ }
+
+ private interface NodeOperationCommand {
+
+ public ComponentMatcherNode getNextNode(ComponentMatcherNode currentNode, String nodeId, boolean isPattern);
+
+ public boolean processLastNode(ComponentMatcherNode lastNode, String fullId);
+ }
+
+ private NodeOperationCommand addNodeOperation = new NodeOperationCommand() {
+
+ public boolean processLastNode(ComponentMatcherNode lastNode, String fullId) {
+ if (!directNodesMap.containsKey(fullId)) {
+ directNodesMap.put(fullId, lastNode);
+ lastNode.markAdded();
+
+ ComponentMatcherNode n = lastNode;
+ int addedSegmentsCount = 0;
+ while (n != null && addedSegmentsCount < SHORT_ID_IN_CLIENTID_SEGMENTS_NUMBER) {
+ if (!n.isPatternNode() && !n.isMetaComponentNode()) {
+ String shortId = n.getSource();
+ if (shortId != null) {
+ addedSegmentsCount++;
+ //TODO filter meta component ids
+ shortIds.add(shortId);
+ }
+ }
+
+ n = n.getParentNode();
+ }
+
+ if (!lastNode.hasPatternNodeInChain()) {
+ lastNode.addSubtreeId(fullId);
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public ComponentMatcherNode getNextNode(ComponentMatcherNode currentNode, String nodeId, boolean isPattern) {
+ return currentNode.getOrCreateChild(nodeId, isPattern);
+ }
+ };
+
+ private NodeOperationCommand removeNodeOperation = new NodeOperationCommand() {
+
+ public boolean processLastNode(ComponentMatcherNode lastNode, String fullId) {
+ ComponentMatcherNode node = directNodesMap.remove(fullId);
+ if (node != null) {
+ if (!node.hasPatternNodeInChain()) {
+ node.removeSubtreeId(fullId);
+ }
+
+ removeNode(node);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public ComponentMatcherNode getNextNode(ComponentMatcherNode currentNode, String nodeId, boolean isPattern) {
+ return currentNode.getChild(nodeId, isPattern);
+ }
+ };
+
+ private IdParser idParser;
+
+ // The client ids to visit
+ private Collection<String> clientIds;
+
+ private Collection<String> shortIds;
+
+ // Our visit hints
+ private Set<VisitHint> hints;
+
+ private ComponentMatcherNode rootNode;
+
+ private Map<String, ComponentMatcherNode> directNodesMap;
+
+ /**
+ * Creates a PartialVisitorContext instance with the specified hints.
+ *
+ * @param facesContext
+ * the FacesContext for the current request
+ * @param clientIds
+ * the client ids of the components to visit
+ * @param hints
+ * a the VisitHints for this visit
+ * @throws NullPointerException
+ * if {@code facesContext} is {@code null}
+ */
+ public BaseExtendedVisitContext(FacesContext facesContext, Collection<String> clientIds, Set<VisitHint> hints,
+ ExtendedVisitContextMode contextMode) {
+
+ super(facesContext, contextMode);
+
+ // Initialize our various collections
+ initializeCollections(clientIds);
+
+ // Copy and store hints - ensure unmodifiable and non-empty
+ EnumSet<VisitHint> hintsEnumSet = ((hints == null) || (hints.isEmpty())) ? EnumSet.noneOf(VisitHint.class)
+ : EnumSet.copyOf(hints);
+
+ this.hints = Collections.unmodifiableSet(hintsEnumSet);
+ }
+
+ private IdParser setupIdParser(String id) {
+ if (idParser == null) {
+ idParser = new IdParser(UINamingContainer.getSeparatorChar(getFacesContext()),
+ MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR);
+ }
+
+ idParser.setId(id);
+
+ return idParser;
+ }
+
+ private ComponentMatcherNode findMatchingNode(String clientId) {
+ ComponentMatcherNode node = rootNode;
+
+ IdParser idParser = setupIdParser(clientId);
+
+ while (node != null && idParser.findNext()) {
+ String componentId = idParser.getComponentId();
+ String metadataComponentId = idParser.getMetadataComponentId();
+
+ if (metadataComponentId != null) {
+ node = node.getChild(componentId, false);
+ if (node != null) {
+ node = node.getChild(metadataComponentId, false);
+ }
+ } else {
+ node = node.getMatchedChild(componentId);
+ }
+ }
+
+ return node;
+ }
+
+ private ComponentMatcherNode findAddedNode(String clientId) {
+ ComponentMatcherNode node = findMatchingNode(clientId);
+
+ if (node != null && !node.isAdded()) {
+ node = null;
+ }
+
+ return node;
+ }
+
+ private void removeNode(ComponentMatcherNode nodeToRemove) {
+ nodeToRemove.markRemoved();
+
+ ComponentMatcherNode node = nodeToRemove;
+ while (node != null && !node.hasDirectChildren()) {
+ ComponentMatcherNode parentNode = node.getParentNode();
+ if (parentNode != null) {
+ parentNode.removeChild(node);
+ node = parentNode;
+ } else {
+ break;
+ }
+ }
+ }
+
+ private boolean invokeNodeOperation(NodeOperationCommand command, ComponentMatcherNode currentNode,
+ IdTreeNode idTreeNode, StringBuilder sb) {
+
+ String componentId = idTreeNode.getComponentId();
+ String metadataComponentId = idTreeNode.getMetadataComponentId();
+
+ ComponentMatcherNode nextNode;
+
+ if (metadataComponentId != null) {
+ nextNode = command.getNextNode(currentNode, componentId, false);
+ if (nextNode != null) {
+ nextNode = command.getNextNode(nextNode, metadataComponentId, false);
+ nextNode.setMetaComponentNode(true);
+ }
+ } else {
+ boolean isPattern = ANY_WILDCARD.equals(componentId);
+ nextNode = command.getNextNode(currentNode, componentId, isPattern);
+ }
+
+ boolean result = false;
+
+ if (nextNode != null) {
+ final int bufferLength = sb.length();
+ if (bufferLength != 0) {
+ //TODO replace with constant
+ sb.append(':');
+ }
+ sb.append(componentId);
+ if (metadataComponentId != null) {
+ sb.append(metadataComponentId);
+ }
+
+ List<IdTreeNode> idTreeChildNodes = idTreeNode.getChildNodes();
+ if (idTreeChildNodes != null) {
+ final int newBufferLength = sb.length();
+
+ for (IdTreeNode idTreeChildNode : idTreeChildNodes) {
+ result |= invokeNodeOperation(command, nextNode, idTreeChildNode, sb);
+
+ sb.setLength(newBufferLength);
+ }
+ } else {
+ result |= command.processLastNode(nextNode, sb.toString());
+ }
+
+ sb.setLength(bufferLength);
+ }
+
+ return result;
+ }
+
+ private boolean invokeRootNodeOperation(NodeOperationCommand command, IdTreeNode idTreeNode) {
+ boolean result = false;
+
+ List<IdTreeNode> idTreeChildNodes = idTreeNode.getChildNodes();
+ if (idTreeChildNodes != null) {
+ StringBuilder sb = new StringBuilder();
+
+ for (IdTreeNode idTreeChildNode : idTreeChildNodes) {
+ result |= invokeNodeOperation(command, rootNode, idTreeChildNode, sb);
+ }
+ }
+
+ return result;
+ }
+
+ private boolean addNode(String patternId) {
+ IdTreeNode idTreeNode = new IdTreeNode();
+ idTreeNode.appendNodesFromParser(setupIdParser(patternId));
+
+ return invokeRootNodeOperation(addNodeOperation, idTreeNode);
+ }
+
+ private boolean removeNode(String patternId) {
+ IdTreeNode idTreeNode = new IdTreeNode();
+ idTreeNode.appendNodesFromParser(setupIdParser(patternId));
+
+ return invokeRootNodeOperation(removeNodeOperation, idTreeNode);
+ }
+
+ /**
+ * @see VisitContext#getHints VisitContext.getHints
+ */
+ @Override
+ public Set<VisitHint> getHints() {
+ return hints;
+ }
+
+ /**
+ * @see VisitContext#getIdsToVisit VisitContext.getIdsToVisit()
+ */
+ @Override
+ public Collection<String> getIdsToVisit() {
+
+ // We just return our clientIds collection. This is
+ // the modifiable (but proxied) collection of all of
+ // the client ids to visit.
+ return clientIds;
+ }
+
+ protected boolean hasImplicitSubtreeIdsToVisit(UIComponent component) {
+ return false;
+ }
+
+ /**
+ * @see VisitContext#getSubtreeIdsToVisit VisitContext.getSubtreeIdsToVisit()
+ */
+ @Override
+ public Collection<String> getSubtreeIdsToVisit(UIComponent component) {
+
+ // Make sure component is a NamingContainer
+ if (!(component instanceof NamingContainer)) {
+ throw new IllegalArgumentException("Component is not a NamingContainer: " + component);
+ }
+
+ if (hasImplicitSubtreeIdsToVisit(component)) {
+ return VisitContext.ALL_IDS;
+ }
+
+ String clientId = buildExtendedClientId(component);
+
+ ComponentMatcherNode node = findMatchingNode(clientId);
+
+ Collection<String> result = null;
+
+
+ if (node != null) {
+ if (node.hasKidPatternNodes()) {
+ result = VisitContext.ALL_IDS;
+ } else {
+ Collection<String> subtreeIds = node.getSubtreeIds();
+ if (subtreeIds != null) {
+ result = Collections.unmodifiableCollection(subtreeIds);
+ } else {
+ //TODO nick - this code addresses the case of parent pattern nodes, and can be optimized
+ if (node.hasDirectIdChildren()) {
+ result = VisitContext.ALL_IDS;
+ } else {
+ result = Collections.emptySet();
+ }
+ }
+ }
+ } else {
+ result = Collections.emptySet();
+ }
+
+ return result;
+ }
+
+ protected void addDirectSubtreeIdsToVisitForImplicitComponents(UIComponent component, Set<String> result) {
+ }
+
+ public Collection<String>getDirectSubtreeIdsToVisit(UIComponent component) {
+ // Make sure component is a NamingContainer
+ if (!(component instanceof NamingContainer)) {
+ throw new IllegalArgumentException("Component is not a NamingContainer: " + component);
+ }
+
+ String clientId = component.getClientId(getFacesContext());
+ ComponentMatcherNode node = findMatchingNode(clientId);
+
+ if (node != null && node.hasDirectPatternChildren()) {
+ return VisitContext.ALL_IDS;
+ }
+
+ Set<String> result = new HashSet<String>();
+ if (node != null && node.hasDirectIdChildren()) {
+ result.addAll(node.getIdChildren().keySet());
+ }
+
+ addDirectSubtreeIdsToVisitForImplicitComponents(component, result);
+
+ if (result != null && !result.isEmpty()) {
+ return Collections.unmodifiableCollection(result);
+ } else {
+ return Collections.emptySet();
+ }
+ }
+
+ protected VisitResult invokeVisitCallbackForImplicitComponent(UIComponent component, VisitCallback callback) {
+ return VisitResult.ACCEPT;
+ }
+
+ protected boolean shouldCompleteOnEmptyIds() {
+ return true;
+ }
+
+ /**
+ * @see VisitContext#invokeVisitCallback VisitContext.invokeVisitCallback()
+ */
+ @Override
+ public VisitResult invokeVisitCallback(UIComponent component, VisitCallback callback) {
+ if (shortIds.contains(component.getId())) {
+ String clientId = buildExtendedClientId(component);
+ ComponentMatcherNode node = findAddedNode(clientId);
+ if (node != null) {
+ VisitResult visitResult = callback.visit(this, component);
+
+ removeNode(clientId);
+
+ if (clientIds.isEmpty() && shouldCompleteOnEmptyIds()) {
+ return VisitResult.COMPLETE;
+ } else {
+ return visitResult;
+ }
+ }
+ }
+
+ return invokeVisitCallbackForImplicitComponent(component, callback);
+ }
+
+ // Called to initialize our various collections.
+ private void initializeCollections(Collection<String> clientIds) {
+ this.rootNode = new ComponentMatcherNode();
+ this.directNodesMap = new HashMap<String, ComponentMatcherNode>();
+ this.shortIds = new HashSet<String>();
+ this.clientIds = new CollectionProxy();
+ this.clientIds.addAll(clientIds);
+ }
+
+ public VisitContext createNamingContainerVisitContext(UIComponent component, Collection<String> directIds) {
+ return new NamingContainerVisitContext(getFacesContext(), getVisitMode(), component, directIds);
+ }
+}
Modified: trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -168,7 +168,7 @@
continue;
}
- if (ExtendedPartialVisitContext.ANY_WILDCARD.equals(componentId)) {
+ if (BaseExtendedVisitContext.ANY_WILDCARD.equals(componentId)) {
continue;
}
Modified: trunk/core/impl/src/main/java/org/richfaces/context/ComponentMatcherNode.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/ComponentMatcherNode.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/main/java/org/richfaces/context/ComponentMatcherNode.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -34,6 +34,8 @@
private boolean patternNode;
+ private boolean metaComponentNode = false;
+
private String source;
private boolean hasParentPatternNode;
@@ -332,4 +334,12 @@
public void setPatternNode(boolean patternNode) {
this.patternNode = patternNode;
}
+
+ public void setMetaComponentNode(boolean metaComponentNode) {
+ this.metaComponentNode = metaComponentNode;
+ }
+
+ public boolean isMetaComponentNode() {
+ return metaComponentNode;
+ }
}
Added: trunk/core/impl/src/main/java/org/richfaces/context/ExecuteExtendedVisitContext.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/ExecuteExtendedVisitContext.java (rev 0)
+++ trunk/core/impl/src/main/java/org/richfaces/context/ExecuteExtendedVisitContext.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -0,0 +1,47 @@
+/*
+ * 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.context;
+
+import java.util.Collection;
+import java.util.Set;
+
+import javax.faces.component.visit.VisitHint;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ExecuteExtendedVisitContext extends BaseExtendedVisitContext {
+
+ /**
+ * @param facesContext
+ * @param clientIds
+ * @param hints
+ */
+ public ExecuteExtendedVisitContext(FacesContext facesContext, Collection<String> clientIds, Set<VisitHint> hints) {
+
+ super(facesContext, clientIds, hints, ExtendedVisitContextMode.EXECUTE);
+ }
+
+
+}
Deleted: trunk/core/impl/src/main/java/org/richfaces/context/ExtendedPartialVisitContext.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/ExtendedPartialVisitContext.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/main/java/org/richfaces/context/ExtendedPartialVisitContext.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -1,532 +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.context;
-
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UINamingContainer;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitHint;
-import javax.faces.component.visit.VisitResult;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.component.AjaxOutput;
-import org.richfaces.component.MetaComponentResolver;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class ExtendedPartialVisitContext extends ExtendedVisitContext {
-
- static final String ANY_WILDCARD = "*";
-
- private static final int SHORT_ID_IN_CLIENTID_SEGMENTS_NUMBER = 2;
-
- private final class CollectionProxy extends AbstractCollection<String> {
-
- private CollectionProxy() {
- }
-
- @Override
- public boolean isEmpty() {
- return directNodesMap.isEmpty();
- }
-
- @Override
- public int size() {
- return directNodesMap.size();
- }
-
- @Override
- public Iterator<String> iterator() {
- return new IteratorProxy(directNodesMap.keySet().iterator());
- }
-
- @Override
- public boolean add(String o) {
- return addNode(o);
- }
- }
- // Little proxy collection implementation. We proxy the id
- // collection so that we can detect modifications and update
- // our internal state when ids to visit are added or removed.
-
- // Little proxy iterator implementation used by CollectionProxy
- // so that we can catch removes.
- private final class IteratorProxy implements Iterator<String> {
-
- private Iterator<String> wrapped;
-
- private String current = null;
-
- private IteratorProxy(Iterator<String> wrapped) {
- this.wrapped = wrapped;
- }
-
- public boolean hasNext() {
- return wrapped.hasNext();
- }
-
- public String next() {
- current = wrapped.next();
-
- return current;
- }
-
- public void remove() {
- if (current != null) {
- ComponentMatcherNode node = directNodesMap.get(current);
- removeNode(node);
-
- current = null;
- }
-
- wrapped.remove();
- }
- }
-
- private interface NodeOperationCommand {
-
- public ComponentMatcherNode getNextNode(ComponentMatcherNode currentNode, String nodeId, boolean isPattern);
-
- public boolean processLastNode(ComponentMatcherNode lastNode, String fullId);
- }
-
- private NodeOperationCommand addNodeOperation = new NodeOperationCommand() {
-
- public boolean processLastNode(ComponentMatcherNode lastNode, String fullId) {
- if (!directNodesMap.containsKey(fullId)) {
- directNodesMap.put(fullId, lastNode);
- lastNode.markAdded();
-
- ComponentMatcherNode n = lastNode;
- int addedSegmentsCount = 0;
- while (n != null && addedSegmentsCount < SHORT_ID_IN_CLIENTID_SEGMENTS_NUMBER) {
- if (!n.isPatternNode()) {
- String shortId = n.getSource();
- if (shortId != null) {
- addedSegmentsCount++;
- //TODO filter meta component ids
- shortIds.add(shortId);
- }
- }
-
- n = n.getParentNode();
- }
-
- if (!lastNode.hasPatternNodeInChain()) {
- lastNode.addSubtreeId(fullId);
- }
-
- return true;
- }
-
- return false;
- }
-
- public ComponentMatcherNode getNextNode(ComponentMatcherNode currentNode, String nodeId, boolean isPattern) {
- return currentNode.getOrCreateChild(nodeId, isPattern);
- }
- };
-
- private NodeOperationCommand removeNodeOperation = new NodeOperationCommand() {
-
- public boolean processLastNode(ComponentMatcherNode lastNode, String fullId) {
- ComponentMatcherNode node = directNodesMap.remove(fullId);
- if (node != null) {
- if (!node.hasPatternNodeInChain()) {
- node.removeSubtreeId(fullId);
- }
-
- removeNode(node);
-
- return true;
- }
-
- return false;
- }
-
- public ComponentMatcherNode getNextNode(ComponentMatcherNode currentNode, String nodeId, boolean isPattern) {
- return currentNode.getChild(nodeId, isPattern);
- }
- };
-
- private IdParser idParser;
-
- private boolean limitRender;
-
- // The client ids to visit
- private Collection<String> clientIds;
-
- private Collection<String> shortIds;
-
- // Our visit hints
- private Set<VisitHint> hints;
-
- private ComponentMatcherNode rootNode;
-
- private Map<String, ComponentMatcherNode> directNodesMap;
-
- /**
- * Creates a PartialVisitorContext instance.
- *
- * @param facesContext
- * the FacesContext for the current request
- * @param clientIds
- * the client ids of the components to visit
- * @throws NullPointerException
- * if {@code facesContext} is {@code null}
- */
- public ExtendedPartialVisitContext(FacesContext facesContext, Collection<String> clientIds, boolean limitRender) {
- this(facesContext, clientIds, null, limitRender);
- }
-
- /**
- * Creates a PartialVisitorContext instance with the specified hints.
- *
- * @param facesContext
- * the FacesContext for the current request
- * @param clientIds
- * the client ids of the components to visit
- * @param hints
- * a the VisitHints for this visit
- * @throws NullPointerException
- * if {@code facesContext} is {@code null}
- */
- public ExtendedPartialVisitContext(FacesContext facesContext, Collection<String> clientIds, Set<VisitHint> hints,
- boolean limitRender) {
-
- super(facesContext, ExtendedVisitContextMode.RENDER);
-
- // Initialize our various collections
- initializeCollections(clientIds);
-
- // Copy and store hints - ensure unmodifiable and non-empty
- EnumSet<VisitHint> hintsEnumSet = ((hints == null) || (hints.isEmpty())) ? EnumSet.noneOf(VisitHint.class)
- : EnumSet.copyOf(hints);
-
- this.hints = Collections.unmodifiableSet(hintsEnumSet);
-
- this.limitRender = limitRender;
- }
-
- private IdParser setupIdParser(String id) {
- if (idParser == null) {
- idParser = new IdParser(UINamingContainer.getSeparatorChar(getFacesContext()),
- MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR);
- }
-
- idParser.setId(id);
-
- return idParser;
- }
-
- private ComponentMatcherNode findMatchingNode(String clientId) {
- ComponentMatcherNode node = rootNode;
-
- IdParser idParser = setupIdParser(clientId);
-
- while (node != null && idParser.findNext()) {
- String componentId = idParser.getComponentId();
- String metadataComponentId = idParser.getMetadataComponentId();
-
- if (metadataComponentId != null) {
- node = node.getChild(componentId, false);
- if (node != null) {
- node = node.getChild(metadataComponentId, false);
- }
- } else {
- node = node.getMatchedChild(componentId);
- }
- }
-
- return node;
- }
-
- private ComponentMatcherNode findAddedNode(String clientId) {
- ComponentMatcherNode node = findMatchingNode(clientId);
-
- if (node != null && !node.isAdded()) {
- node = null;
- }
-
- return node;
- }
-
- private void removeNode(ComponentMatcherNode nodeToRemove) {
- nodeToRemove.markRemoved();
-
- ComponentMatcherNode node = nodeToRemove;
- while (node != null && !node.hasDirectChildren()) {
- ComponentMatcherNode parentNode = node.getParentNode();
- if (parentNode != null) {
- parentNode.removeChild(node);
- node = parentNode;
- } else {
- break;
- }
- }
- }
-
- private boolean invokeNodeOperation(NodeOperationCommand command, ComponentMatcherNode currentNode,
- IdTreeNode idTreeNode, StringBuilder sb) {
-
- String componentId = idTreeNode.getComponentId();
- String metadataComponentId = idTreeNode.getMetadataComponentId();
-
- ComponentMatcherNode nextNode;
-
- if (metadataComponentId != null) {
- nextNode = command.getNextNode(currentNode, componentId, false);
- if (nextNode != null) {
- nextNode = command.getNextNode(nextNode, metadataComponentId, false);
- }
- } else {
- boolean isPattern = ANY_WILDCARD.equals(componentId);
- nextNode = command.getNextNode(currentNode, componentId, isPattern);
- }
-
- boolean result = false;
-
- if (nextNode != null) {
- final int bufferLength = sb.length();
- if (bufferLength != 0) {
- //TODO replace with constant
- sb.append(':');
- }
- sb.append(componentId);
- if (metadataComponentId != null) {
- sb.append(metadataComponentId);
- }
-
- List<IdTreeNode> idTreeChildNodes = idTreeNode.getChildNodes();
- if (idTreeChildNodes != null) {
- final int newBufferLength = sb.length();
-
- for (IdTreeNode idTreeChildNode : idTreeChildNodes) {
- result |= invokeNodeOperation(command, nextNode, idTreeChildNode, sb);
-
- sb.setLength(newBufferLength);
- }
- } else {
- result |= command.processLastNode(nextNode, sb.toString());
- }
-
- sb.setLength(bufferLength);
- }
-
- return result;
- }
-
- private boolean invokeRootNodeOperation(NodeOperationCommand command, IdTreeNode idTreeNode) {
- boolean result = false;
-
- List<IdTreeNode> idTreeChildNodes = idTreeNode.getChildNodes();
- if (idTreeChildNodes != null) {
- StringBuilder sb = new StringBuilder();
-
- for (IdTreeNode idTreeChildNode : idTreeChildNodes) {
- result |= invokeNodeOperation(command, rootNode, idTreeChildNode, sb);
- }
- }
-
- return result;
- }
-
- private boolean addNode(String patternId) {
- IdTreeNode idTreeNode = new IdTreeNode();
- idTreeNode.appendNodesFromParser(setupIdParser(patternId));
-
- return invokeRootNodeOperation(addNodeOperation, idTreeNode);
- }
-
- private boolean removeNode(String patternId) {
- IdTreeNode idTreeNode = new IdTreeNode();
- idTreeNode.appendNodesFromParser(setupIdParser(patternId));
-
- return invokeRootNodeOperation(removeNodeOperation, idTreeNode);
- }
-
- /**
- * @see VisitContext#getHints VisitContext.getHints
- */
- @Override
- public Set<VisitHint> getHints() {
- return hints;
- }
-
- /**
- * @see VisitContext#getIdsToVisit VisitContext.getIdsToVisit()
- */
- @Override
- public Collection<String> getIdsToVisit() {
-
- // We just return our clientIds collection. This is
- // the modifiable (but proxied) collection of all of
- // the client ids to visit.
- return clientIds;
- }
-
- /**
- * @see VisitContext#getSubtreeIdsToVisit VisitContext.getSubtreeIdsToVisit()
- */
- @Override
- public Collection<String> getSubtreeIdsToVisit(UIComponent component) {
-
- // Make sure component is a NamingContainer
- if (!(component instanceof NamingContainer)) {
- throw new IllegalArgumentException("Component is not a NamingContainer: " + component);
- }
-
- if (!limitRender && PartialViewContextAjaxOutputTracker.hasNestedAjaxOutputs(component)) {
- return VisitContext.ALL_IDS;
- }
-
- String clientId = buildExtendedClientId(component);
-
- ComponentMatcherNode node = findMatchingNode(clientId);
-
- Collection<String> result = null;
-
-
- if (node != null) {
- if (node.hasKidPatternNodes()) {
- result = VisitContext.ALL_IDS;
- } else {
- Collection<String> subtreeIds = node.getSubtreeIds();
- if (subtreeIds != null) {
- result = Collections.unmodifiableCollection(subtreeIds);
- } else {
- //TODO nick - this code addresses the case of parent pattern nodes, and can be optimized
- if (node.hasDirectIdChildren()) {
- result = VisitContext.ALL_IDS;
- } else {
- result = Collections.emptySet();
- }
- }
- }
- } else {
- result = Collections.emptySet();
- }
-
- return result;
- }
-
- public Collection<String>getDirectSubtreeIdsToVisit(UIComponent component) {
- // Make sure component is a NamingContainer
- if (!(component instanceof NamingContainer)) {
- throw new IllegalArgumentException("Component is not a NamingContainer: " + component);
- }
-
- String clientId = component.getClientId(getFacesContext());
- ComponentMatcherNode node = findMatchingNode(clientId);
-
- if (node != null && node.hasDirectPatternChildren()) {
- return VisitContext.ALL_IDS;
- }
-
- Set<String> result = null;
- if (node != null && node.hasDirectIdChildren()) {
- result = new HashSet<String>();
- result.addAll(node.getIdChildren().keySet());
- }
-
- if (!limitRender) {
-
- Collection<String> directChildrenIds = PartialViewContextAjaxOutputTracker.getDirectChildrenIds(component);
- if (directChildrenIds != null && !directChildrenIds.isEmpty()) {
- if (result == null) {
- result = new HashSet<String>();
- }
-
- result.addAll(directChildrenIds);
- }
- }
-
- if (result != null && !result.isEmpty()) {
- return Collections.unmodifiableCollection(result);
- } else {
- return Collections.emptySet();
- }
- }
-
- /**
- * @see VisitContext#invokeVisitCallback VisitContext.invokeVisitCallback()
- */
- @Override
- public VisitResult invokeVisitCallback(UIComponent component, VisitCallback callback) {
- if (shortIds.contains(component.getId())) {
- String clientId = buildExtendedClientId(component);
- ComponentMatcherNode node = findAddedNode(clientId);
- if (node != null) {
- VisitResult visitResult = callback.visit(this, component);
-
- removeNode(clientId);
-
- if (clientIds.isEmpty() && limitRender) {
- return VisitResult.COMPLETE;
- } else {
- return visitResult;
- }
- }
- }
-
- if (!limitRender) {
- if (component instanceof AjaxOutput) {
- AjaxOutput ajaxOutput = (AjaxOutput) component;
- if (ajaxOutput.isAjaxRendered()) {
-
- // TODO - remove explicit nested IDs from update
- return callback.visit(this, component);
- }
- }
- }
-
- return VisitResult.ACCEPT;
- }
-
- // Called to initialize our various collections.
- private void initializeCollections(Collection<String> clientIds) {
- this.rootNode = new ComponentMatcherNode();
- this.directNodesMap = new HashMap<String, ComponentMatcherNode>();
- this.shortIds = new HashSet<String>();
- this.clientIds = new CollectionProxy();
- this.clientIds.addAll(clientIds);
- }
-
- public VisitContext createNamingContainerVisitContext(UIComponent component, Collection<String> directIds) {
- return new NamingContainerVisitContext(getFacesContext(), getVisitMode(), component, directIds);
- }
-}
Modified: trunk/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -185,15 +185,54 @@
return wrappedViewContext.getPartialResponseWriter();
}
+ private boolean isProcessedExecutePhase(PhaseId phaseId) {
+ return phaseId == PhaseId.APPLY_REQUEST_VALUES || phaseId == PhaseId.PROCESS_VALIDATIONS
+ || phaseId == PhaseId.UPDATE_MODEL_VALUES;
+ }
+
@Override
public void processPartial(PhaseId phaseId) {
- if (detectContextMode() == ContextMode.DIRECT && phaseId == PhaseId.RENDER_RESPONSE) {
- processPartialRenderPhase();
+ if (detectContextMode() == ContextMode.DIRECT) {
+ if (phaseId == PhaseId.RENDER_RESPONSE) {
+ processPartialRenderPhase();
+ } else if (isProcessedExecutePhase(phaseId)) {
+ processPartialExecutePhase(phaseId);
+ }
} else {
wrappedViewContext.processPartial(phaseId);
}
}
+ protected void processPartialExecutePhase(PhaseId phaseId) {
+ PartialViewContext pvc = facesContext.getPartialViewContext();
+ Collection <String> executeIds = pvc.getExecuteIds();
+
+ if (executeIds == null || executeIds.isEmpty()) {
+ if (phaseId == PhaseId.APPLY_REQUEST_VALUES) {
+ LOG.warn("Partial execute won't happen - executeIds were not specified");
+ }
+ return;
+ }
+
+ try {
+ executeComponents(phaseId, executeIds);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+
+ if (phaseId == PhaseId.APPLY_REQUEST_VALUES) {
+ PartialResponseWriter writer = pvc.getPartialResponseWriter();
+ facesContext.setResponseWriter(writer);
+ }
+ }
+
+ protected void executeComponents(PhaseId phaseId, Collection<String> executeIds) {
+ EnumSet<VisitHint> hints = EnumSet.of(VisitHint.SKIP_UNRENDERED);
+ VisitContext visitContext = new ExecuteExtendedVisitContext(facesContext, executeIds, hints);
+ PartialViewExecuteVisitCallback callback = new PartialViewExecuteVisitCallback(facesContext, phaseId);
+ facesContext.getViewRoot().visitTree(visitContext, callback);
+ }
+
protected void processPartialRenderPhase() {
PartialViewContext pvc = facesContext.getPartialViewContext();
UIViewRoot viewRoot = facesContext.getViewRoot();
@@ -223,7 +262,7 @@
(!limitRender && PartialViewContextAjaxOutputTracker.hasNestedAjaxOutputs(viewRoot))) {
EnumSet<VisitHint> hints = EnumSet.of(VisitHint.SKIP_UNRENDERED);
- VisitContext visitContext = new ExtendedPartialVisitContext(facesContext, phaseIds, hints, limitRender);
+ VisitContext visitContext = new RenderExtendedVisitContext(facesContext, phaseIds, hints, limitRender);
VisitCallback visitCallback = new RenderVisitCallback(facesContext);
viewRoot.visitTree(visitContext, visitCallback);
}
@@ -369,9 +408,10 @@
}
private boolean visitActivatorComponent(String componentActivatorId, VisitCallback visitCallback) {
+
Set<String> idsToVisit = Collections.singleton(componentActivatorId);
Set<VisitHint> visitHints = EnumSet.of(VisitHint.SKIP_UNRENDERED);
- VisitContext visitContext = VisitContext.createVisitContext(facesContext, idsToVisit, visitHints);
+ VisitContext visitContext = new ExecuteExtendedVisitContext(facesContext, idsToVisit, visitHints);
boolean visitResult = facesContext.getViewRoot().visitTree(visitContext, visitCallback);
return visitResult;
Added: trunk/core/impl/src/main/java/org/richfaces/context/PartialViewExecuteVisitCallback.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/PartialViewExecuteVisitCallback.java (rev 0)
+++ trunk/core/impl/src/main/java/org/richfaces/context/PartialViewExecuteVisitCallback.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -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.context;
+
+import javax.faces.component.UIComponent;
+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.PhaseId;
+
+import org.richfaces.component.MetaComponentProcessor;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+final class PartialViewExecuteVisitCallback implements VisitCallback {
+
+ private FacesContext facesContext;
+
+ private PhaseId phaseId;
+
+ PartialViewExecuteVisitCallback(FacesContext context, PhaseId phaseId) {
+ super();
+ this.facesContext = context;
+ this.phaseId = phaseId;
+ }
+
+ public VisitResult visit(VisitContext context, UIComponent target) {
+ String metaComponentId = (String) facesContext.getAttributes().get(ExtendedVisitContext.META_COMPONENT_ID);
+ if (metaComponentId != null) {
+ MetaComponentProcessor executor = (MetaComponentProcessor) target;
+ executor.processMetaComponent(facesContext, metaComponentId);
+ } else if (phaseId == PhaseId.APPLY_REQUEST_VALUES) {
+ target.processDecodes(facesContext);
+ } else if (phaseId == PhaseId.PROCESS_VALIDATIONS) {
+ target.processValidators(facesContext);
+ } else if (phaseId == PhaseId.UPDATE_MODEL_VALUES) {
+ target.processUpdates(facesContext);
+ } else {
+ throw new IllegalArgumentException(phaseId.toString());
+ }
+
+ return VisitResult.REJECT;
+ }
+}
Added: trunk/core/impl/src/main/java/org/richfaces/context/RenderExtendedVisitContext.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/RenderExtendedVisitContext.java (rev 0)
+++ trunk/core/impl/src/main/java/org/richfaces/context/RenderExtendedVisitContext.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -0,0 +1,81 @@
+/*
+ * 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.context;
+
+import java.util.Collection;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitHint;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.component.AjaxOutput;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class RenderExtendedVisitContext extends BaseExtendedVisitContext {
+
+ private boolean limitRender;
+
+ public RenderExtendedVisitContext(FacesContext facesContext, Collection<String> clientIds, Set<VisitHint> hints,
+ boolean limitRender) {
+ super(facesContext, clientIds, hints, ExtendedVisitContextMode.RENDER);
+
+ this.limitRender = limitRender;
+ }
+
+ @Override
+ protected boolean hasImplicitSubtreeIdsToVisit(UIComponent component) {
+ return !limitRender && PartialViewContextAjaxOutputTracker.hasNestedAjaxOutputs(component);
+ }
+
+ protected void addDirectSubtreeIdsToVisitForImplicitComponents(UIComponent component, Set<String> result) {
+ if (!limitRender) {
+ Collection<String> directChildrenIds = PartialViewContextAjaxOutputTracker.getDirectChildrenIds(component);
+ if (directChildrenIds != null && !directChildrenIds.isEmpty()) {
+ result.addAll(directChildrenIds);
+ }
+ }
+ }
+
+ protected VisitResult invokeVisitCallbackForImplicitComponent(UIComponent component, VisitCallback callback) {
+ if (!limitRender) {
+ if (component instanceof AjaxOutput) {
+ AjaxOutput ajaxOutput = (AjaxOutput) component;
+ if (ajaxOutput.isAjaxRendered()) {
+
+ // TODO - remove explicit nested IDs from update
+ return callback.visit(this, component);
+ }
+ }
+ }
+ return VisitResult.ACCEPT;
+ }
+
+ protected boolean shouldCompleteOnEmptyIds() {
+ return limitRender;
+ }
+}
Modified: trunk/core/impl/src/main/java/org/richfaces/renderkit/util/CoreRendererUtils.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/renderkit/util/CoreRendererUtils.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/main/java/org/richfaces/renderkit/util/CoreRendererUtils.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -37,7 +37,9 @@
import javax.faces.component.UIForm;
import javax.faces.context.FacesContext;
+import org.richfaces.component.MetaComponentResolver;
import org.richfaces.context.ComponentIdResolver;
+import org.richfaces.context.ExtendedVisitContext;
/**
* Util class for common render operations - render passthru html attributes,
@@ -71,6 +73,10 @@
} else if (NONE.equals(id)) {
return NONE;
} else if (THIS.equals(id)) {
+ String metaComponentId = (String) facesContext.getAttributes().get(ExtendedVisitContext.META_COMPONENT_ID);
+ if (metaComponentId != null) {
+ return component.getClientId(facesContext) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
+ }
return component.getClientId(facesContext);
} else if (FORM.equals(id)) {
UIForm nestingForm = getNestingForm(facesContext, component);
Modified: trunk/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/main/java/org/richfaces/resource/ResourceFactoryImpl.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -392,6 +392,8 @@
if (result != null) {
result.setLibraryName(resourceKey.getLibraryName());
result.setResourceName(resourceKey.getResourceName());
+ } else if (mappedResourceData != null) {
+ result = defaultHandler.createResource(actualKey.getResourceName(), actualKey.getLibraryName());
}
return result;
Modified: trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-10-31 13:42:28 UTC (rev 19793)
@@ -532,6 +532,10 @@
parameters.execute = "@component";
parameters.render = "@component";
+ if (options.clientParameters) {
+ jQuery.extend(parameters, options.clientParameters);
+ }
+
if (!parameters["org.richfaces.ajax.component"]) {
parameters["org.richfaces.ajax.component"] = sourceId;
}
Modified: trunk/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java
===================================================================
--- trunk/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -41,7 +41,7 @@
public class AjaxTableComponentImpl extends UIData {
private static final Logger LOG = RichfacesLogger.COMPONENTS.getLogger();
-
+
private boolean visitMetaComponent(String name, ExtendedVisitContext visitContext, VisitCallback callback) {
UIComponent facet = getFacet(name);
if (facet != null) {
@@ -107,7 +107,7 @@
// Visit children, short-circuiting as necessary
if ((result == VisitResult.ACCEPT) && doVisitChildren(visitContext)) {
setRowIndex(-1);
-
+
if (visitFixedChildren(visitContext, callback)) {
return true;
}
@@ -133,7 +133,7 @@
// Return false to allow the visit to continue
return false;
}
-
+
protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
if (visitContext instanceof ExtendedVisitContext) {
@@ -154,32 +154,32 @@
return true;
}
}
-
+
return false;
}
}
protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback) {
int rowIndex = 0;
-
+
for (setRowIndex(rowIndex); isRowAvailable(); setRowIndex(++rowIndex)) {
VisitResult result = visitContext.invokeVisitCallback(this, callback);
-
+
if (result == VisitResult.COMPLETE) {
return true;
}
-
+
if (result == VisitResult.REJECT) {
continue;
}
-
+
for (UIComponent child: getChildren()) {
if (child.visitTree(visitContext, callback)) {
return true;
}
}
}
-
+
return false;
}
Modified: trunk/core/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java
===================================================================
--- trunk/core/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -46,6 +46,7 @@
import javax.faces.application.Application;
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
import javax.faces.component.UIForm;
import javax.faces.component.UIOutput;
import javax.faces.component.UIViewRoot;
@@ -150,7 +151,7 @@
private List<String> tableData;
- private ExtendedPartialVisitContext renderingContext;
+ private BaseExtendedVisitContext renderingContext;
private TrackingVisitCallback trackingVisitCallback;
@@ -163,13 +164,17 @@
private UIOutput nestedTableFooter;
private static void assertEqualSets(Collection<?> expected, Collection<?> actual) {
- assertEquals(asSet(expected), asSet(actual));
+ assertEquals(asComparableCollection(expected), asComparableCollection(actual));
}
- private static <T> Set<T> asSet(Collection<T> c) {
- if (c instanceof Set) {
- return (Set) c;
+ private static <T> Collection<T> asComparableCollection(Collection<T> c) {
+ if (c instanceof Set || c instanceof List) {
+ return c;
} else {
+ if (c == VisitContext.ALL_IDS) {
+ return c;
+ }
+
if (c != null) {
return new HashSet<T>(c);
} else {
@@ -188,7 +193,7 @@
}
private void createVisitContext(boolean limitRender) {
- renderingContext = new ExtendedPartialVisitContext(facesContext, Collections.<String>emptySet(),
+ renderingContext = new RenderExtendedVisitContext(facesContext, Collections.<String>emptySet(),
EnumSet.<VisitHint>of(VisitHint.SKIP_UNRENDERED), limitRender);
}
Modified: trunk/core/impl/src/test/resources/javascript/4_0_0.html
===================================================================
--- trunk/core/impl/src/test/resources/javascript/4_0_0.html 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/core/impl/src/test/resources/javascript/4_0_0.html 2010-10-31 13:42:28 UTC (rev 19793)
@@ -164,6 +164,25 @@
RichFaces.ajax(ajaxSource, ajaxEvent, ajaxOptions);
});
+ test("RichFaces.ajax client parameters test", function() {
+ expect(7);
+ var ajaxSource = "source";
+ var ajaxEvent = "event";
+ var ajaxOptions = {clientParameters: {'param': 'value'}, incId: 1};
+ jsf.ajax = {
+ request : function(source, event, options) {
+ equals(source, ajaxSource);
+ equals(event, ajaxEvent);
+ equals(options['execute'], '@component');
+ equals(options['render'], '@component');
+ equals(options['param'], 'value');
+ equals(options['org.richfaces.ajax.component'], 'source');
+ equals(options['source'], 'source');
+ }
+ }
+ RichFaces.ajax(ajaxSource, ajaxEvent, ajaxOptions);
+ });
+
test("RichFaces.escapeCSSMetachars test", function() {
expect(6);
Modified: trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeNodeParser.java
===================================================================
--- trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeNodeParser.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeNodeParser.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -99,18 +99,18 @@
currentNode.addChild(newNode);
}
- currentNode.setData(JOINER.join(currentNode.getData(), localName.toLowerCase(Locale.US), " ["));
+ newNode.setData(JOINER.join(newNode.getData(), localName.toLowerCase(Locale.US), " ["));
currentNode = newNode;
}
public void endElement(String uri, String localName, String qName) throws SAXException {
- currentNode.setData(JOINER.join("]", currentNode.getData()));
+ currentNode.setData(JOINER.join(currentNode.getData(), "]"));
currentNode = (SwingTreeNodeImpl) currentNode.getParent();
}
public void characters(char[] ch, int start, int length) throws SAXException {
- currentNode.setData(JOINER.join(currentNode.getData(), new String(ch, start, length)));
+ currentNode.setData(JOINER.join(currentNode.getData(), new String(ch, start, length).trim()));
}
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
Modified: trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-10-31 13:42:28 UTC (rev 19793)
@@ -3,7 +3,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:it="http://richfaces.org/iteration">
+ xmlns:it="http://richfaces.org/tree">
<f:view contentType="text/html" />
<h:head>
@@ -18,5 +18,11 @@
</h:panelGroup>
</it:treeNode>
</it:tree>
+
+ <h:form>
+ <h:commandLink value="Re-render">
+ <f:ajax render=":tree" />
+ </h:commandLink>
+ </h:form>
</h:body>
</html>
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -292,6 +292,15 @@
return DataVisitResult.STOP;
}
+
+ if (result == VisitResult.ACCEPT) {
+ result = visitDataChildrenMetaComponents((ExtendedVisitContext) visitContext, callback);
+ if (VisitResult.COMPLETE.equals(result)) {
+ visitResult = true;
+
+ return DataVisitResult.STOP;
+ }
+ }
}
if (VisitResult.ACCEPT.equals(result)) {
@@ -1013,10 +1022,16 @@
serializableModel.update();
}
+
+ doUpdate();
popComponentFromEL(faces);
}
+ protected void doUpdate() {
+
+ }
+
@Override
public void setId(String id) {
super.setId(id);
@@ -1342,6 +1357,10 @@
return visitComponents(fixedChildren(), visitContext, callback);
}
+ protected VisitResult visitDataChildrenMetaComponents(ExtendedVisitContext extendedVisitContext, VisitCallback callback) {
+ return VisitResult.ACCEPT;
+ }
+
protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback, boolean visitRows) {
if (visitRows) {
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/component/util/HtmlUtil.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/util/HtmlUtil.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/util/HtmlUtil.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -128,10 +128,11 @@
return false;
}
- private static String concat(char separator, String... strings) {
+ private static String concat(char separator, Object... objects) {
StringBuilder result = new StringBuilder();
- for (String s : strings) {
+ for (Object o : objects) {
+ String s = (String) o;
if (!Strings.isNullOrEmpty(s)) {
if (result.length() != 0) {
result.append(separator);
@@ -144,11 +145,11 @@
return result.toString();
}
- public static String concatClasses(String... classes) {
+ public static String concatClasses(Object... classes) {
return concat(' ', classes);
}
- public static String concatStyles(String... styles) {
+ public static String concatStyles(Object... styles) {
return concat(';', styles);
}
}
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -21,23 +21,23 @@
package org.richfaces.renderkit;
-import org.ajax4jsf.javascript.ScriptStringBase;
-import org.ajax4jsf.javascript.ScriptUtils;
-
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.ajax4jsf.javascript.ScriptStringBase;
+import org.ajax4jsf.javascript.ScriptUtils;
+
/**
* @author Nick Belaevski
* @since 4.0
*/
public class AjaxEventOptions extends ScriptStringBase {
- /**
- *
- */
public static final String PARAMETERS = "parameters";
+
+ public static final String CLIENT_PARAMETERS = "clientParameters";
+
private Map<String, Object> options = new HashMap<String, Object>();
public void appendScript(StringBuffer functionString) {
@@ -100,4 +100,20 @@
parameters.remove(parameterName);
}
}
+
+ public Object getClientParameters() {
+ return options.get(CLIENT_PARAMETERS);
+ }
+
+ public void setClientParameters(Object value) {
+ options.put(CLIENT_PARAMETERS, value);
+ }
+
+ public Object getAjaxComponent() {
+ return getParameter(AjaxConstants.AJAX_COMPONENT_ID_PARAMETER);
+ }
+
+ public void setAjaxComponent(Object ajaxComponent) {
+ getParameters().put(AjaxConstants.AJAX_COMPONENT_ID_PARAMETER, ajaxComponent);
+ }
}
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -29,6 +29,7 @@
import javax.faces.render.Renderer;
import org.ajax4jsf.Messages;
+import org.richfaces.component.util.HtmlUtil;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.renderkit.util.RendererUtils;
@@ -281,4 +282,11 @@
}
}
+ public String concatClasses(Object... objects) {
+ return HtmlUtil.concatClasses(objects);
+ }
+
+ public String concatStyles(Object... objects) {
+ return HtmlUtil.concatStyles(objects);
+ }
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -291,4 +291,8 @@
throw new IllegalArgumentException(metaComponentId);
}
}
+
+ public void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) {
+ throw new UnsupportedOperationException();
+ }
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -596,6 +596,10 @@
}
}
+ public void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) {
+ throw new UnsupportedOperationException();
+ }
+
protected void partialStart(FacesContext facesContext, String id) throws IOException {
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(id);
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -275,6 +275,9 @@
}
}
+ public void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) {
+ throw new UnsupportedOperationException();
+ }
@Override
protected void doCleanup(FacesContext context, RowHolderBase rowHolder) throws IOException {
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -575,6 +575,10 @@
}
}
+ public void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) {
+ throw new UnsupportedOperationException();
+ }
+
protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component)
throws IOException {
Map<String, Object> attributes = component.getAttributes();
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java 2010-10-30 00:25:36 UTC (rev 19792)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java 2010-10-31 13:42:28 UTC (rev 19793)
@@ -23,28 +23,28 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.javascript.JSObject;
-import org.richfaces.TooltipMode;
-import org.richfaces.component.AbstractTooltip;
-import org.richfaces.component.html.HtmlTooltip;
-import org.richfaces.renderkit.HtmlConstants;
-import org.richfaces.renderkit.MetaComponentRenderer;
+import static org.richfaces.renderkit.RenderKitUtils.renderPassThroughAttributes;
+import static org.richfaces.renderkit.html.TogglePanelRenderer.addEventOption;
+import static org.richfaces.renderkit.html.TogglePanelRenderer.getAjaxOptions;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialResponseWriter;
import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import static org.richfaces.component.util.HtmlUtil.concatClasses;
-import static org.richfaces.renderkit.RenderKitUtils.renderPassThroughAttributes;
-import static org.richfaces.renderkit.html.TogglePanelRenderer.addEventOption;
-import static org.richfaces.renderkit.html.TogglePanelRenderer.getAjaxOptions;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSObject;
+import org.richfaces.TooltipMode;
+import org.richfaces.component.AbstractTooltip;
+import org.richfaces.component.html.HtmlTooltip;
+import org.richfaces.renderkit.HtmlConstants;
+import org.richfaces.renderkit.MetaComponentRenderer;
/**
* @author amarkhel
@@ -215,6 +215,10 @@
}
}
+ public void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) {
+ throw new UnsupportedOperationException();
+ }
+
@Override
protected Class<? extends UIComponent> getComponentClass() {
return AbstractTooltip.class;
14 years, 2 months
JBoss Rich Faces SVN: r19792 - in branches/RF-8742/ui/validator/ui/src/main: java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-10-29 20:25:36 -0400 (Fri, 29 Oct 2010)
New Revision: 19792
Added:
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
Log:
CODING IN PROGRESS - issue RF-9216: CSV: server side development
https://jira.jboss.org/browse/RF-9216
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2010-10-29 23:11:21 UTC (rev 19791)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2010-10-30 00:25:36 UTC (rev 19792)
@@ -59,6 +59,7 @@
*
*/
public class ClientValidatorImpl extends AjaxBehavior implements ClientValidatorBehavior {
+
private static final String VALUE = "value";
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-29 23:11:21 UTC (rev 19791)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-30 00:25:36 UTC (rev 19792)
@@ -67,6 +67,10 @@
}
}
+ @Override
+ public void decode(FacesContext context, UIComponent component, ClientBehavior behavior) {
+ // TODO - properly set phase and re-render.
+ }
/**
* <p class="changed_added_4_0">
* This method builds client-side validation script and stores it in View resource component
@@ -142,7 +146,7 @@
validatorScript = createValidatorScript(behaviorContext, behavior, validators, clientSideConverterScript);
} catch (ScriptNotFoundException e) {
// ajax-only validation
- validatorScript = new AjaxOnlyScript(behavior.getAjaxScript(behaviorContext));
+ validatorScript = new AjaxOnlyScript(createAjaxScript(behaviorContext, behavior));
}
} else {
validatorScript = createValidatorScript(behaviorContext, behavior, validators, null);
@@ -150,7 +154,7 @@
} catch (ConverterNotFoundException e) {
throw new FacesException(e);
}
- String clientId = behaviorContext.getComponent().getClientId(behaviorContext.getFacesContext());
+ String clientId = getComponentClientId(behaviorContext);
String name = ScriptUtils.getValidJavascriptName(clientId+":v");
validatorScript.setName(name);
return validatorScript;
@@ -160,20 +164,33 @@
}
}
+ private String getComponentClientId(ClientBehaviorContext behaviorContext) {
+ return behaviorContext.getComponent().getClientId(behaviorContext.getFacesContext());
+ }
+
private ValidatorScriptBase createValidatorScript(ClientBehaviorContext behaviorContext,
ClientValidatorBehavior behavior, Collection<ValidatorDescriptor> validators,
LibraryScriptString clientSideConverterScript) {
Collection<? extends LibraryScriptString> validatorScripts = getClientSideValidatorScript(behaviorContext.getFacesContext(), validators);
if (validatorScripts.isEmpty()) {
- return new AjaxOnlyScript(behavior.getAjaxScript(behaviorContext));
+ return new AjaxOnlyScript(createAjaxScript(behaviorContext, behavior));
} else if (validatorScripts.size() < validators.size()) {
return new ClientAndAjaxScript(clientSideConverterScript, validatorScripts,
- behavior.getAjaxScript(behaviorContext));
+ createAjaxScript(behaviorContext, behavior));
} else {
return new ClientOnlyScript(clientSideConverterScript, validatorScripts);
}
}
+ private String createAjaxScript(ClientBehaviorContext behaviorContext, ClientValidatorBehavior behavior) {
+ String ajaxScript = behavior.getAjaxScript(behaviorContext);
+ ajaxScript=ajaxScript.replace("this", "element");
+ String clientId = getComponentClientId(behaviorContext);
+ ajaxScript=ajaxScript.replace("'"+clientId+"'",ValidatorScriptBase.CLIENT_ID);
+ ajaxScript=ajaxScript.replace("\""+clientId+"\"",ValidatorScriptBase.CLIENT_ID);
+ return ajaxScript;
+ }
+
/**
* <p class="changed_added_4_0">
* Build client-side function call for Server-side component descriptor.
Added: branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml (rev 0)
+++ branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml 2010-10-30 00:25:36 UTC (rev 19792)
@@ -0,0 +1,15 @@
+<?xml-stylesheet type="text/xsl" href=""?>
+<facelet-taglib 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-facelettaglibrary_2_0.xsd"
+ version="2.0">
+ <namespace>http://richfaces.org/csv</namespace>
+
+ <tag>
+ <tag-name>validator</tag-name>
+ <behavior>
+ <behavior-id>org.richfaces.behavior.ClientValidator</behavior-id>
+ </behavior>
+ </tag>
+
+</facelet-taglib>
Property changes on: branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-10-29 23:11:21 UTC (rev 19791)
+++ branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-10-30 00:25:36 UTC (rev 19792)
@@ -4,11 +4,19 @@
<component-type>org.richfaces.ValidatroScript</component-type>
<component-class>org.richfaces.component.UIValidatorScript</component-class>
</component>
+<behavior>
+ <behavior-id>org.richfaces.behavior.ClientValidator</behavior-id>
+ <behavior-class>org.richfaces.component.behavior.ClientValidatorImpl</behavior-class>
+</behavior>
<render-kit>
<renderer>
<component-family>org.richfaces.Script</component-family>
<renderer-type>org.richfaces.renderer.ValidatorScriptRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.ValidatorScriptRenderer</renderer-class>
</renderer>
+ <client-behavior-renderer>
+ <client-behavior-renderer-type>org.richfaces.ClientValidatorRenderer</client-behavior-renderer-type>
+ <client-behavior-renderer-class>org.richfaces.renderkit.html.ClientValidatorRenderer</client-behavior-renderer-class>
+ </client-behavior-renderer>
</render-kit>
</faces-config>
\ No newline at end of file
14 years, 2 months
JBoss Rich Faces SVN: r19791 - in branches/RF-8742/ui: validator/api/src/main/java/org/richfaces/validator and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-10-29 19:11:21 -0400 (Fri, 29 Oct 2010)
New Revision: 19791
Added:
branches/RF-8742/ui/common/ui/src/main/java/org/richfaces/component/util/Strings.java
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/ClientSideScripts.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/Component.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java
branches/RF-8742/ui/validator/impl/src/test/resources/badcsv.xml
branches/RF-8742/ui/validator/impl/src/test/resources/csv.xml
Modified:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/CapturingELContext.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
Log:
RESOLVED - issue RF-9510: BeanValidatorService tests and implementation
https://jira.jboss.org/browse/RF-9510
RESOLVED - issue RF-9509: ClientScriptLookupService unit tests and implementation
https://jira.jboss.org/browse/RF-9509
Added: branches/RF-8742/ui/common/ui/src/main/java/org/richfaces/component/util/Strings.java
===================================================================
--- branches/RF-8742/ui/common/ui/src/main/java/org/richfaces/component/util/Strings.java (rev 0)
+++ branches/RF-8742/ui/common/ui/src/main/java/org/richfaces/component/util/Strings.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,109 @@
+/*
+ * $Id: Strings.java 19714 2010-10-27 19:04:55Z alexsmirnov $
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.util;
+
+import java.util.NoSuchElementException;
+
+import com.google.common.base.Joiner;
+
+
+/**
+ * <p class="changed_added_4_0">String manipulation utils.</p>
+ *
+ * @author asmirnov(a)exadel.com
+ */
+public final class Strings {
+
+ public static final Joiner DOT_JOINER = Joiner.on('.');
+
+ private Strings() {
+
+ // this is utility class with static methods only.
+ }
+
+ /**
+ * <p class="changed_added_4_0">Remove characters from string end</p>
+ *
+ * @param in input string
+ * @param size number of characters to remove.
+ * @return
+ */
+ public static String cut(String in, int size) {
+ if (size > 0) {
+ return in.substring(0, in.length() - size);
+ }
+
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Change case of the first character to lower, as it required by the Java Beans property and setter/getter method name conventions:</p>
+ * <p>"PropertyFoo" will be changed to "propertyFoo"</p>
+ *
+ * @param in
+ * @return {@code in} with first character changed to lower case.
+ */
+ public static String firstToLowerCase(String in) {
+ if (!isEmpty(in)) {
+ in = in.substring(0, 1).toLowerCase() + in.substring(1);
+ }
+
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Change case of the first character to upper, as it required by the Java Beans property and setter/getter method name conventions:</p>
+ * <p>"propertyFoo" will be changed to "PropertyFoo"</p>
+ *
+ * @param in
+ * @return {@code in} with first character changed to lower case.
+ */
+ public static String firstToUpperCase(String in) {
+ if (!isEmpty(in)) {
+ in = in.substring(0, 1).toUpperCase() + in.substring(1);
+ }
+
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Check string for null or empty value</p>
+ *
+ * @param type
+ * @return true if {@code type} is null or zero-length string.
+ */
+ public static boolean isEmpty(String type) {
+ return type == null || type.length() == 0;
+ }
+
+ public static String firstNonEmpty(String... strings) {
+ for (String s : strings) {
+ if (!isEmpty(s)) {
+ return s;
+ }
+ }
+
+ throw new NoSuchElementException();
+ }
+}
Property changes on: branches/RF-8742/ui/common/ui/src/main/java/org/richfaces/component/util/Strings.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java
===================================================================
--- branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java 2010-10-29 19:15:30 UTC (rev 19790)
+++ branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -23,6 +23,8 @@
package org.richfaces.validator;
+import javax.faces.context.FacesContext;
+
/**
* <p class="changed_added_4_0">This interface describes service that determines JavaScript module and function
* for Java corresponded version ( both Converter and Validator )</p>
@@ -33,10 +35,11 @@
/**
* <p class="changed_added_4_0">Get description for client-side version of Java implementation</p>
+ * @param facesContext TODO
* @param javaClass either Converter or Validator class.
* @return description of client-side script.
* @throws ScriptNotFoundException if no JavaScript code associated with Java class.
*/
- LibraryFunction getScript(Class<?> javaClass) throws ScriptNotFoundException;
+ LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass) throws ScriptNotFoundException;
}
Added: branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java
===================================================================
--- branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java (rev 0)
+++ branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,26 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation describes client-side version of Converter/validator.
+ * @author asmirnov
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.TYPE)
+public @interface ClientSideScript {
+
+ String library() default "";
+
+ String resource();
+
+ String function();
+
+}
Property changes on: branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java 2010-10-29 19:15:30 UTC (rev 19790)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -23,6 +23,8 @@
package org.richfaces.application;
+import java.util.Map;
+
import javax.validation.ValidationException;
import org.richfaces.el.ValueExpressionAnalayserImpl;
@@ -30,11 +32,15 @@
import org.richfaces.validator.BeanValidatorFactory;
import org.richfaces.validator.BeanValidatorService;
import org.richfaces.validator.BeanValidatorServiceImpl;
+import org.richfaces.validator.ClientScriptService;
+import org.richfaces.validator.ClientScriptServiceImpl;
+import org.richfaces.validator.ClientServiceConfigParser;
import org.richfaces.validator.ConverterServiceImpl;
import org.richfaces.validator.DummyBeanValidatorService;
import org.richfaces.validator.FacesConverterService;
import org.richfaces.validator.FacesValidatorService;
import org.richfaces.validator.FacesValidatorServiceImpl;
+import org.richfaces.validator.LibraryFunction;
import org.richfaces.validator.NullValidator;
import org.richfaces.validator.ObjectValidator;
import org.richfaces.validator.RichFacesBeanValidatorFactory;
@@ -58,9 +64,18 @@
configureBeanValidators(factory);
factory.setInstance(FacesConverterService.class, new ConverterServiceImpl());
factory.setInstance(FacesValidatorService.class, new FacesValidatorServiceImpl());
+ ClientScriptServiceImpl clientScriptService = createClientScriptService();
+ factory.setInstance(ClientScriptService.class, clientScriptService);
}
+ private ClientScriptServiceImpl createClientScriptService() {
+ Map<Class<?>, LibraryFunction> config = ClientServiceConfigParser.parseConfig("META-INF/csv.xml");
+ ClientScriptServiceImpl clientScriptService = new ClientScriptServiceImpl(config);
+ return clientScriptService;
+ }
+
+
void configureBeanValidators(ServicesFactory factory){
BeanValidatorService service ;
ObjectValidator validator;
Modified: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/CapturingELContext.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/CapturingELContext.java 2010-10-29 19:15:30 UTC (rev 19790)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/el/CapturingELContext.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -106,8 +106,6 @@
@Override
public Object getValue(ELContext context, Object base, Object property) {
- // Null value for the base means new properties chain.
- // TODO - record each chain to the separate collection for compound expressions.
reference = new ValueReference(base, property, reference);
return delegate.getValue(context, base, property);
}
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,74 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import java.util.Map;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.util.Strings;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ClientScriptServiceImpl implements ClientScriptService {
+
+ private static final String TEXT_JAVASCRIPT = "text/javascript";
+
+ private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
+
+ private final Map<Class<?>, LibraryFunction> defaultMapping;
+
+ public ClientScriptServiceImpl(Map<Class<?>, LibraryFunction> defaultMapping) {
+ this.defaultMapping = defaultMapping;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.validator.ClientScriptService#getScript(java.lang.Class)
+ */
+ public LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass) throws ScriptNotFoundException {
+ if (null == facesContext || null == javaClass) {
+ throw new NullPointerException();
+ }
+ LibraryFunction function;
+ try {
+ function = getScriptResource(facesContext, javaClass);
+ } catch (ScriptNotFoundException e) {
+ if (defaultMapping.containsKey(javaClass)) {
+ function = defaultMapping.get(javaClass);
+ } else {
+ function = getScriptFromAnnotation(javaClass);
+ }
+ }
+ return function;
+ }
+
+ private LibraryFunction getScriptFromAnnotation(Class<?> javaClass) throws ScriptNotFoundException {
+ if (javaClass.isAnnotationPresent(ClientSideScript.class)) {
+ ClientSideScript clientSideScript = javaClass.getAnnotation(ClientSideScript.class);
+ return new LibraryFunctionImplementation(clientSideScript.library(), clientSideScript.resource(), clientSideScript.function());
+ } else {
+ throw new ScriptNotFoundException();
+ }
+ }
+
+ private LibraryFunction getScriptResource(FacesContext facesContext, Class<?> javaClass)
+ throws ScriptNotFoundException {
+ ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
+ String resourceName = javaClass.getSimpleName() + ".js";
+ Resource facesResource = resourceHandler.createResource(resourceName, ORG_RICHFACES_CSV, TEXT_JAVASCRIPT);
+ if (null != facesResource) {
+ final String functionName = Strings.firstToLowerCase(javaClass.getSimpleName());
+ return new LibraryFunctionImplementation(ORG_RICHFACES_CSV,resourceName, functionName);
+ } else {
+ throw new ScriptNotFoundException();
+ }
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.xml.bind.JAXB;
+
+import org.richfaces.validator.model.ClientSideScripts;
+import org.richfaces.validator.model.Component;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Maps;
+
+/**
+ * @author asmirnov
+ *
+ */
+public final class ClientServiceConfigParser {
+
+ private ClientServiceConfigParser() {
+ }
+
+ public static Map<Class<?>, LibraryFunction> parseConfig(String name) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (null == loader) {
+ loader = ClientServiceConfigParser.class.getClassLoader();
+ }
+ Builder<Class<?>, LibraryFunction> resultBuilder = ImmutableMap.builder();
+ try {
+ Enumeration<URL> resources = loader.getResources(name);
+ while (resources.hasMoreElements()) {
+ URL url = (URL) resources.nextElement();
+ resultBuilder.putAll(parse(loader, url));
+ }
+ } catch (IOException e) {
+ return Collections.emptyMap();
+ }
+ return resultBuilder.build();
+ }
+
+ static Map<Class<?>, LibraryFunction> parse(ClassLoader loader, URL url) {
+ Map<Class<?>, LibraryFunction> result = Maps.newHashMap();
+ try {
+ ClientSideScripts clientSideScripts = JAXB.unmarshal(url, ClientSideScripts.class);
+ for (Component component : clientSideScripts.getComponent()) {
+ Class<?> componentClass = loader.loadClass(component.getType());
+ LibraryFunctionImplementation function = new LibraryFunctionImplementation(component.getLibrary(),
+ component.getResource(), component.getFunction());
+ result.put(componentClass, function);
+ }
+ } catch (ClassNotFoundException e) {
+ throw new FacesException("Class for component not found",e);
+ } catch (Exception e) {
+ throw new FacesException("Error parsing config file "+url,e);
+ }
+ return result;
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,24 @@
+package org.richfaces.validator;
+
+final class LibraryFunctionImplementation implements LibraryFunction {
+ private final LibraryResource library;
+ private final String functionName;
+
+ LibraryFunctionImplementation(LibraryResource library, String functionName) {
+ this.library = library;
+ this.functionName = functionName;
+ }
+
+ LibraryFunctionImplementation(String library, String resource, String functionName) {
+ this.library = new LibraryResource(library, resource);
+ this.functionName = functionName;
+ }
+
+ public LibraryResource getResource() {
+ return library;
+ }
+
+ public String getName() {
+ return functionName;
+ }
+}
\ No newline at end of file
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/ClientSideScripts.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/ClientSideScripts.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/ClientSideScripts.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package org.richfaces.validator.model;
+
+import java.util.Collection;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import com.google.common.collect.Lists;
+
+/**
+ * @author asmirnov
+ *
+ */
+@XmlRootElement(name="scripts")
+public class ClientSideScripts {
+
+ private Collection<Component> component = Lists.newArrayList();
+
+ public void setComponent(Collection<Component> component) {
+ this.component = component;
+ }
+
+ @XmlElement
+ public Collection<Component> getComponent() {
+ return component;
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/ClientSideScripts.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/Component.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/Component.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/Component.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,75 @@
+package org.richfaces.validator.model;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class Component {
+
+ private String type;
+
+ private String function;
+
+ private String library;
+
+ private String resource;
+
+ /**
+ * @return the type
+ */
+ @XmlElement
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return the function
+ */
+ @XmlElement
+ public String getFunction() {
+ return function;
+ }
+
+ /**
+ * @param function the function to set
+ */
+ public void setFunction(String function) {
+ this.function = function;
+ }
+
+ /**
+ * @return the library
+ */
+ @XmlElement
+ public String getLibrary() {
+ return library;
+ }
+
+ /**
+ * @param library the library to set
+ */
+ public void setLibrary(String library) {
+ this.library = library;
+ }
+
+ /**
+ * @return the resource
+ */
+ @XmlElement
+ public String getResource() {
+ return resource;
+ }
+
+ /**
+ * @param resource the resource to set
+ */
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/model/Component.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,121 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.util.Map;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.validation.constraints.Max;
+
+import org.jboss.test.faces.mock.Environment;
+import org.jboss.test.faces.mock.Environment.Feature;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockController;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author asmirnov
+ *
+ */
+(a)RunWith(MockTestRunner.class)
+public class ClientScriptServiceTest {
+
+ private static final String TEXT_JAVASCRIPT = "text/javascript";
+
+ private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
+
+ private static final String RESOURCE_NAME = ValidatorWithFacesResource.class.getSimpleName() + ".js";
+
+ @Mock
+ @Environment({ Feature.APPLICATION })
+ private MockFacesEnvironment environment;
+
+ @Mock
+ private ResourceHandler resourceHandler;
+
+ private MockController controller;
+
+ @Mock
+ private Resource resource;
+
+ @Mock
+ private LibraryFunction function;
+
+ private ClientScriptServiceImpl serviceImpl;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ expect(environment.getApplication().getResourceHandler()).andStubReturn(resourceHandler);
+ Map<Class<?>, LibraryFunction> defaultMapping = ImmutableMap
+ .<Class<?>, LibraryFunction> of(Max.class, function);
+ serviceImpl = new ClientScriptServiceImpl(defaultMapping);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ controller.verify();
+ }
+
+ /**
+ * Test method for {@link org.richfaces.validator.ClientScriptServiceImpl#getScript(FacesContext, java.lang.Class)}.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetScriptAsJsfResource() throws Exception {
+ LibraryFunction script = getScript(resource, ValidatorWithFacesResource.class);
+ assertEquals(RESOURCE_NAME, script.getResource().getResourceName());
+ assertEquals(ORG_RICHFACES_CSV, script.getResource().getLibrary());
+ assertEquals("validatorWithFacesResource", script.getName());
+ }
+
+ @Test
+ public void testGetScriptFromAnnotation() throws Exception {
+ LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
+ assertEquals("baz.js", script.getResource().getResourceName());
+ assertEquals("bar", script.getResource().getLibrary());
+ assertEquals("foo", script.getName());
+ }
+
+ @Test
+ public void testGetScriptFromDefaultMapping() throws Exception {
+ LibraryFunction script = getScript(null, Max.class);
+ assertSame(function, script);
+ }
+
+ @Test
+ public void testGetScriptOverrideAnnotation() throws Exception {
+ Map<Class<?>, LibraryFunction> defaultMapping = ImmutableMap.<Class<?>, LibraryFunction> of(
+ ValidatorWithFacesResource.class, function);
+ serviceImpl = new ClientScriptServiceImpl(defaultMapping);
+ LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
+ assertSame(function, script);
+ }
+
+ private LibraryFunction getScript(Resource resource, Class<?> serverSideType) throws ScriptNotFoundException {
+ expect(resourceHandler.createResource(serverSideType.getSimpleName() + ".js", ORG_RICHFACES_CSV, TEXT_JAVASCRIPT)).andReturn(resource);
+ controller.replay();
+ LibraryFunction script = serviceImpl.getScript(environment.getFacesContext(), serverSideType);
+ return script;
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,43 @@
+package org.richfaces.validator;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import javax.faces.FacesException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ServiceConfigParserTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testParseConfig() {
+ Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("csv.xml");
+ assertEquals(2, parseConfig.size());
+ assertTrue(parseConfig.containsKey(String.class));
+ LibraryFunction libraryFunction = parseConfig.get(String.class);
+ assertEquals("stringConverter", libraryFunction.getName());
+ assertEquals("csv.js", libraryFunction.getResource().getResourceName());
+ assertEquals("org.richfaces", libraryFunction.getResource().getLibrary());
+ }
+
+ @Test(expected=FacesException.class)
+ public void testParseBadConfig() {
+ Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("badcsv.xml");
+ }
+ @Test()
+ public void testParseNoConfig() {
+ Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("non-exists-csv.xml");
+ assertEquals(0, parseConfig.size());
+ }
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,6 @@
+package org.richfaces.validator;
+
+@ClientSideScript(function="foo",library="bar",resource="baz.js")
+public class ValidatorWithFacesResource {
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/test/resources/badcsv.xml
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/resources/badcsv.xml (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/test/resources/badcsv.xml 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scripts>
+ <component>
+ <type>non.existed.Class</type>
+ <library>org.richfaces</library>
+ <resource>csv.js</resource>
+ <function>stringConverter</function>
+ </component>
+</scripts>
\ No newline at end of file
Property changes on: branches/RF-8742/ui/validator/impl/src/test/resources/badcsv.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/test/resources/csv.xml
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/resources/csv.xml (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/test/resources/csv.xml 2010-10-29 23:11:21 UTC (rev 19791)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scripts>
+ <component>
+ <type>java.lang.String</type>
+ <library>org.richfaces</library>
+ <resource>csv.js</resource>
+ <function>stringConverter</function>
+ </component>
+ <component>
+ <type>java.lang.Integer</type>
+ <library>org.richfaces</library>
+ <resource>csv.js</resource>
+ <function>intConverter</function>
+ </component>
+</scripts>
\ No newline at end of file
Property changes on: branches/RF-8742/ui/validator/impl/src/test/resources/csv.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-29 19:15:30 UTC (rev 19790)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -197,12 +197,12 @@
ConverterDescriptor converter) throws ScriptNotFoundException {
ClientScriptService clientScriptService =
ServiceTracker.getService(facesContext, ClientScriptService.class);
- return createClientFunction(converter, VALUE_LITERAL, clientScriptService);
+ return createClientFunction(facesContext, converter, VALUE_LITERAL, clientScriptService);
}
- private LibraryScriptString createClientFunction(FacesObjectDescriptor descriptor, JSLiteral variable,
- ClientScriptService clientScriptService) throws ScriptNotFoundException {
- LibraryFunction script = clientScriptService.getScript(descriptor.getImplementationClass());
+ private LibraryScriptString createClientFunction(FacesContext facesContext, FacesObjectDescriptor descriptor,
+ JSLiteral variable, ClientScriptService clientScriptService) throws ScriptNotFoundException {
+ LibraryFunction script = clientScriptService.getScript(facesContext, descriptor.getImplementationClass());
return new LibraryScriptFunction(script, variable, descriptor.getMessage(), descriptor.getAdditionalParameters());
}
@@ -223,7 +223,7 @@
List<LibraryScriptString> scripts = Lists.newArrayList();
for (FacesObjectDescriptor validator : validators) {
try {
- scripts.add(createClientFunction(validator, CONVERTED_VALUE_LITERAL, clientScriptService));
+ scripts.add(createClientFunction(facesContext, validator, CONVERTED_VALUE_LITERAL, clientScriptService));
} catch (ScriptNotFoundException e) {
// Skip this validator for AJAX call.
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-10-29 19:15:30 UTC (rev 19790)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-10-29 23:11:21 UTC (rev 19791)
@@ -23,7 +23,7 @@
import org.richfaces.validator.LibraryFunction;
import org.richfaces.validator.LibraryScriptString;
import org.richfaces.validator.ScriptNotFoundException;
-import org.richfaces.validator.FacesObjectDescriptor;
+import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Iterables;
@@ -32,7 +32,7 @@
public class RendererGetClientSideScriptTest extends RendererTestBase {
@Mock
- private FacesObjectDescriptor descriptor;
+ private ValidatorDescriptor descriptor;
@Mock
private ConverterDescriptor converterDescriptor;
@@ -43,7 +43,7 @@
@Mock
private LibraryFunction script;
- private Collection<FacesObjectDescriptor> descriptors;
+ private Collection<ValidatorDescriptor> descriptors;
@Before
public void setupService() {
@@ -60,7 +60,7 @@
@Test()
public void testGetClientSideScriptNotExists() throws Throwable {
expect((Class) descriptor.getImplementationClass()).andReturn(RegexValidator.class);
- expect(scriptService.getScript(RegexValidator.class)).andThrow(new ScriptNotFoundException());
+ expect(scriptService.getScript(environment.getFacesContext(), RegexValidator.class)).andThrow(new ScriptNotFoundException());
controller.replay();
Collection<? extends LibraryScriptString> clientSideValidatorScript = renderer.getClientSideValidatorScript(
@@ -72,7 +72,7 @@
@Test(expected = ScriptNotFoundException.class)
public void testGetClientSideConverterScriptNotExists() throws Throwable {
expect((Class) converterDescriptor.getImplementationClass()).andReturn(NumberConverter.class);
- expect(scriptService.getScript(NumberConverter.class)).andThrow(new ScriptNotFoundException());
+ expect(scriptService.getScript(environment.getFacesContext(), NumberConverter.class)).andThrow(new ScriptNotFoundException());
controller.replay();
renderer.getClientSideConverterScript(environment.getFacesContext(), converterDescriptor);
controller.verify();
@@ -84,7 +84,7 @@
expect(descriptor.getMessage()).andReturn(VALIDATOR_MESSAGE);
expect((Map<String, Object>) descriptor.getAdditionalParameters()).andReturn(
(Map<String, Object>) VALIDATOR_PARAMS);
- expect(scriptService.getScript(RegexValidator.class)).andReturn(script);
+ expect(scriptService.getScript(environment.getFacesContext(), RegexValidator.class)).andReturn(script);
expect(script.getName()).andReturn(REGEX_VALIDATOR).atLeastOnce();
expect(script.getResource()).andReturn(CLIENT_VALIDATOR_LIBRARY);
controller.replay();
@@ -103,7 +103,7 @@
expect(converterDescriptor.getMessage()).andReturn(VALIDATOR_MESSAGE);
expect((Map<String, Object>) converterDescriptor.getAdditionalParameters()).andReturn(
(Map<String, Object>) VALIDATOR_PARAMS);
- expect(scriptService.getScript(NumberConverter.class)).andReturn(script);
+ expect(scriptService.getScript(environment.getFacesContext(), NumberConverter.class)).andReturn(script);
expect(script.getName()).andReturn(REGEX_VALIDATOR).atLeastOnce();
expect(script.getResource()).andReturn(CLIENT_VALIDATOR_LIBRARY);
controller.replay();
14 years, 2 months
JBoss Rich Faces SVN: r19790 - in sandbox/trunk/ui/tree-actual: api/src/main/java and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-29 15:15:30 -0400 (Fri, 29 Oct 2010)
New Revision: 19790
Added:
sandbox/trunk/ui/tree-actual/api/src/main/java/org/
sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/
sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/event/
sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/event/TreeToggleEvent.java
sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/event/TreeToggleListener.java
sandbox/trunk/ui/tree-actual/pom.xml
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeDecoderHelper.java
Modified:
sandbox/trunk/ui/tree-actual/ui/
sandbox/trunk/ui/tree-actual/ui/pom.xml
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
Log:
https://jira.jboss.org/browse/RF-9315
Added: sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/event/TreeToggleEvent.java
===================================================================
--- sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/event/TreeToggleEvent.java (rev 0)
+++ sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/event/TreeToggleEvent.java 2010-10-29 19:15:30 UTC (rev 19790)
@@ -0,0 +1,62 @@
+/*
+ * 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.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TreeToggleEvent extends FacesEvent {
+
+ private static final long serialVersionUID = -7264894390585192069L;
+
+ private boolean expanded;
+
+ public TreeToggleEvent(UIComponent component, boolean expanded) {
+ super(component);
+
+ this.expanded = expanded;
+ }
+
+ public boolean isExpanded() {
+ return expanded;
+ }
+
+ public boolean isCollapsed() {
+ return !isExpanded();
+ }
+
+ @Override
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof TreeToggleListener;
+ }
+
+ @Override
+ public void processListener(FacesListener listener) {
+ ((TreeToggleListener) listener).processToggle(this);
+ }
+
+}
Added: sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/event/TreeToggleListener.java
===================================================================
--- sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/event/TreeToggleListener.java (rev 0)
+++ sandbox/trunk/ui/tree-actual/api/src/main/java/org/richfaces/event/TreeToggleListener.java 2010-10-29 19:15:30 UTC (rev 19790)
@@ -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;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface TreeToggleListener extends FacesListener {
+
+ public void processToggle(TreeToggleEvent event);
+
+}
Added: sandbox/trunk/ui/tree-actual/pom.xml
===================================================================
--- sandbox/trunk/ui/tree-actual/pom.xml (rev 0)
+++ sandbox/trunk/ui/tree-actual/pom.xml 2010-10-29 19:15:30 UTC (rev 19790)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-root-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.richfaces.ui.iteration</groupId>
+ <artifactId>richfaces-ui-tree-aggregator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Richfaces UI Components: Tree Aggregator</name>
+
+ <modules>
+ <module>api</module>
+ <module>ui</module>
+ </modules>
+
+</project>
\ No newline at end of file
Property changes on: sandbox/trunk/ui/tree-actual/ui
___________________________________________________________________
Name: svn:ignore
+ bin
Modified: sandbox/trunk/ui/tree-actual/ui/pom.xml
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/pom.xml 2010-10-29 16:45:44 UTC (rev 19789)
+++ sandbox/trunk/ui/tree-actual/ui/pom.xml 2010-10-29 19:15:30 UTC (rev 19790)
@@ -42,6 +42,11 @@
</dependency>
<dependency>
<groupId>org.richfaces.ui.iteration</groupId>
+ <artifactId>tree-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.iteration</groupId>
<artifactId>richfaces-ui-iteration-api</artifactId>
</dependency>
<dependency>
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-10-29 16:45:44 UTC (rev 19789)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-10-29 19:15:30 UTC (rev 19790)
@@ -22,18 +22,34 @@
package org.richfaces.component;
import java.util.Iterator;
+import java.util.Map;
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
+import javax.faces.component.UpdateModelException;
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 org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.ExtendedDataModel;
+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.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.component.util.MessageUtil;
import org.richfaces.convert.SequenceRowKeyConverter;
+import org.richfaces.event.TreeToggleEvent;
import org.richfaces.model.TreeDataModelImpl;
import com.google.common.base.Predicate;
@@ -52,7 +68,7 @@
public abstract class AbstractTree extends UIDataAdaptor {
public static final String COMPONENT_TYPE = "org.richfaces.Tree";
-
+
public static final String COMPONENT_FAMILY = "org.richfaces.Tree";
private static final Predicate<UIComponent> RENDERED_UITREE_NODE = new Predicate<UIComponent>() {
@@ -60,15 +76,23 @@
return (input instanceof AbstractTreeNode) && input.isRendered();
};
};
-
+
private static final Converter ROW_KEY_CONVERTER = new SequenceRowKeyConverter();
+
+ private enum PropertyKeys {
+ expanded
+ }
+
+ private transient UIComponent decoderHelper = null;
public AbstractTree() {
setRendererType("org.richfaces.TreeRenderer");
}
public abstract Object getValue();
-
+
+ public abstract boolean isImmediate();
+
@Override
public String getFamily() {
return COMPONENT_FAMILY;
@@ -76,7 +100,37 @@
@Attribute(defaultValue = "SwitchType.DEFAULT")
public abstract SwitchType getToggleMode();
-
+
+ @SuppressWarnings("unchecked")
+ protected Boolean getLocalExpandedValue(FacesContext facesContext) {
+ Map<String, Object> stateMap = (Map<String, Object>) getStateHelper().get(PropertyKeys.expanded);
+ if (stateMap == null) {
+ return null;
+ }
+
+ String key = this.getClientId(facesContext);
+ return (Boolean) stateMap.get(key);
+ }
+
+ public boolean isExpanded() {
+ FacesContext context = getFacesContext();
+ Boolean localExpandedValue = getLocalExpandedValue(context);
+ if (localExpandedValue != null) {
+ return localExpandedValue.booleanValue();
+ }
+
+ ValueExpression ve = getValueExpression(PropertyKeys.expanded.toString());
+ if (ve != null) {
+ return Boolean.TRUE.equals(ve.getValue(context.getELContext()));
+ }
+
+ return false;
+ }
+
+ public void setExpanded(boolean newValue) {
+ getStateHelper().put(PropertyKeys.expanded, this.getClientId(getFacesContext()), newValue);
+ }
+
/* (non-Javadoc)
* @see org.richfaces.component.UIDataAdaptor#createExtendedDataModel()
*/
@@ -108,18 +162,96 @@
public Iterator<Object> getChildrenIterator(FacesContext faces, Object rowKey) {
return ((TreeDataModelImpl) getExtendedDataModel()).getChildrenIterator(faces, rowKey);
}
-
+
public AbstractTreeNode getTreeNodeComponent() {
if (getChildCount() == 0) {
return null;
}
-
+
Iterator<UIComponent> iterator = Iterators.filter(getChildren().iterator(), RENDERED_UITREE_NODE);
if (iterator.hasNext()) {
return (AbstractTreeNode) iterator.next();
}
-
+
return null;
}
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+
+ 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);
+ }
+ }
+ }
+ @Override
+ public void decode(FacesContext context) {
+ try {
+ decoderHelper = new TreeDecoderHelper(this);
+ super.decode(context);
+ } finally {
+ decoderHelper = null;
+ }
+ }
+
+ @Override
+ protected Iterator<UIComponent> dataChildren() {
+ if (decoderHelper != null) {
+ return Iterators.concat(super.dataChildren(), Iterators.<UIComponent>singletonIterator(decoderHelper));
+ } else {
+ return super.dataChildren();
+ }
+ }
}
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-10-29 16:45:44 UTC (rev 19789)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-10-29 19:15:30 UTC (rev 19790)
@@ -21,11 +21,17 @@
*/
package org.richfaces.component;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.event.TreeToggleEvent;
/**
* @author Nick Belaevski
@@ -51,4 +57,38 @@
public String getFamily() {
return COMPONENT_FAMILY;
}
+
+ @Attribute(defaultValue = "findTreeComponent().isImmediate()")
+ public abstract boolean isImmediate();
+
+ protected AbstractTree findTreeComponent() {
+ UIComponent c = this;
+ while (c != null && !(c instanceof AbstractTree)) {
+ c = c.getParent();
+ }
+
+ return (AbstractTree) c;
+ }
+
+ @Override
+ public void queueEvent(FacesEvent event) {
+ if (this.equals(event.getComponent())) {
+ if (event instanceof TreeToggleEvent) {
+ PhaseId targetPhase = isImmediate() ? PhaseId.APPLY_REQUEST_VALUES : PhaseId.PROCESS_VALIDATIONS;
+ event.setPhaseId(targetPhase);
+ }
+ }
+
+ super.queueEvent(event);
+ }
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+
+ if (event instanceof TreeToggleEvent) {
+ TreeToggleEvent toggleEvent = (TreeToggleEvent) event;
+ new TreeToggleEvent(findTreeComponent(), toggleEvent.isExpanded()).queue();
+ }
+ }
}
Added: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeDecoderHelper.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeDecoderHelper.java (rev 0)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/component/TreeDecoderHelper.java 2010-10-29 19:15:30 UTC (rev 19790)
@@ -0,0 +1,64 @@
+/*
+ * 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 javax.faces.component.UIComponentBase;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class TreeDecoderHelper extends UIComponentBase {
+
+ public static final String HELPER_ID = "__treeDecoderHelper";
+
+ private AbstractTree tree;
+
+ public TreeDecoderHelper(AbstractTree tree) {
+ super();
+ this.tree = tree;
+ setId(HELPER_ID);
+ setTransient(true);
+ }
+
+ @Override
+ public boolean isInView() {
+ return tree.isInView();
+ }
+
+ @Override
+ public boolean isRendered() {
+ return tree.isRendered();
+ }
+
+ @Override
+ public String getFamily() {
+ return null;
+ }
+
+ @Override
+ public UIComponent getParent() {
+ return tree;
+ }
+
+}
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-10-29 16:45:44 UTC (rev 19789)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-10-29 19:15:30 UTC (rev 19790)
@@ -166,13 +166,26 @@
return new SequenceRowKeyIterator<TreeNode>(sequenceKey, itr);
}
+ protected void walk(FacesContext context, DataVisitor visitor, Range range, Object argument, Iterator<Object> keysIterator) {
+ while (keysIterator.hasNext()) {
+ Object object = (Object) keysIterator.next();
+
+ visitor.process(context, object, argument);
+
+ Iterator<Object> childrenIterator = getChildrenIterator(context, object);
+ walk(context, visitor, range, argument, childrenIterator);
+ }
+ }
+
/* (non-Javadoc)
* @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
*/
@Override
public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
// TODO Auto-generated method stub
-
+
+ Iterator<Object> iterator = getChildrenIterator(context, null);
+ walk(context, visitor, range, argument, iterator);
}
}
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-10-29 16:45:44 UTC (rev 19789)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-10-29 19:15:30 UTC (rev 19790)
@@ -26,18 +26,29 @@
import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
import java.io.IOException;
+import java.util.Collections;
+import java.util.EnumSet;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.Map;
import javax.faces.component.UIComponent;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitHint;
+import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSReference;
import org.richfaces.component.AbstractTree;
+import org.richfaces.component.AbstractTreeNode;
import org.richfaces.component.SwitchType;
+import org.richfaces.component.TreeDecoderHelper;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.event.TreeToggleEvent;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -53,14 +64,20 @@
private static final Logger LOGGER = RichfacesLogger.RENDERKIT.getLogger();
- private static final String NODE_ID = "nodeId";
+ private static final String TOGGLE_DATA = "toggleData";
- private static final String NEW_STATE = "newState";
+ private static final String TREE_TOGGLE_ID_PARAM = "org.richfaces.Tree.TREE_TOGGLE_ID";
+
+ private static final String NODE_TOGGLE_ID_PARAM = "org.richfaces.Tree.NODE_TOGGLE_ID";
- private static final String TOGGLE_ID_PARAM = "org.richfaces.Tree.TOGGLE_ID";
-
private static final String NEW_STATE_PARAM = "org.richfaces.Tree.NEW_STATE";
+
+ private static final JSReference JS_TREE_ID = new JSReference(TOGGLE_DATA + ".treeId");
+ private static final JSReference JS_NODE_ID = new JSReference(TOGGLE_DATA + ".nodeId");
+
+ private static final JSReference JS_NEW_STATE = new JSReference(TOGGLE_DATA + ".treeId");
+
private static final class QueuedData {
private Object rowKey;
@@ -206,8 +223,9 @@
JSFunction ajaxFunction = buildAjaxFunction(context, component, AJAX_FUNCTION_NAME);
AjaxEventOptions eventOptions = buildEventOptions(context, component);
- eventOptions.setParameter(TOGGLE_ID_PARAM, new JSReference(NODE_ID));
- eventOptions.setParameter(NEW_STATE_PARAM, new JSReference(NEW_STATE));
+ eventOptions.setParameter(TREE_TOGGLE_ID_PARAM, JS_TREE_ID);
+ eventOptions.setParameter(NODE_TOGGLE_ID_PARAM, JS_NODE_ID);
+ eventOptions.setParameter(NEW_STATE_PARAM, JS_NEW_STATE);
if (!eventOptions.isEmpty()) {
ajaxFunction.addParameter(eventOptions);
@@ -215,4 +233,40 @@
return ajaxFunction.toScript();
}
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ super.doDecode(context, component);
+
+ final Map<String, String> map = context.getExternalContext().getRequestParameterMap();
+ String toggleId = map.get(TREE_TOGGLE_ID_PARAM);
+ if (component.getClientId(context).equals(toggleId)) {
+
+ String nodeId = map.get(NODE_TOGGLE_ID_PARAM) + UINamingContainer.getSeparatorChar(context)
+ + TreeDecoderHelper.HELPER_ID;
+
+ VisitContext visitContext = createVisitContext(context, nodeId);
+ component.visitTree(visitContext, new VisitCallback() {
+
+ public VisitResult visit(VisitContext context, UIComponent target) {
+ AbstractTree tree = (AbstractTree) target.getParent();
+ AbstractTreeNode treeNode = tree.getTreeNodeComponent();
+ if (treeNode != null) {
+ boolean expanded = Boolean.valueOf(map.get(NEW_STATE_PARAM));
+ if (tree.isExpanded() ^ expanded) {
+ new TreeToggleEvent(treeNode, expanded);
+ }
+ }
+
+ return VisitResult.COMPLETE;
+ }
+ });
+
+ }
+ }
+
+ private VisitContext createVisitContext(FacesContext context, String nodeId) {
+ return VisitContext.createVisitContext(context, Collections.singleton(nodeId),
+ EnumSet.<VisitHint>of(VisitHint.SKIP_UNRENDERED));
+ }
}
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-10-29 16:45:44 UTC (rev 19789)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-10-29 19:15:30 UTC (rev 19790)
@@ -28,6 +28,10 @@
});
}
+ var TREE_HANDLE_CLASSES = ["tree_collapse", "tree_expand"];
+
+ var TREE_CLASSES = ["tree_handle_collapsed", "tree_handle_expanded"];
+
richfaces.ui = richfaces.ui || {};
richfaces.ui.TreeNode = richfaces.BaseComponent.extendClass({
@@ -113,18 +117,24 @@
}
},
- collapse: function() {
+ __changeToggleState: function(newState) {
if (!this.isLeaf()) {
var tree = this.getTree();
switch (tree.getToggleMode()) {
case 'client':
- this.elt.addClass("tree_collapse");
- this.handler.addClass("tree_handle_collapsed").removeClass("tree_handle_expanded");
+ this.elt.addClass(TREE_HANDLE_CLASSES[newState ? 1 : 0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
+ this.handler.addClass(TREE_CLASSES[newState ? 1 : 0]).removeClass(TREE_CLASSES[!newState ? 1 : 0]);
break;
case 'ajax':
- tree.toggleByAjax(null, richfaces.getDomElement(this.id).id, false);
+ var toggleData = {
+ nodeId: richfaces.getDomElement(this.id).id,
+ newState: newState
+ };
+
+ //TODO - event?
+ tree.toggleByAjax(null, toggleData);
break;
case 'server':
@@ -134,26 +144,13 @@
}
},
+
+ collapse: function() {
+ this.__changeToggleState(false);
+ },
expand: function() {
- if (!this.isLeaf()) {
- var tree = this.getTree();
-
- switch (tree.getToggleMode()) {
- case 'client':
- this.elt.removeClass("tree_collapse");
- this.handler.removeClass("tree_handle_collapsed").addClass("tree_handle_expanded");
- break;
-
- case 'ajax':
- tree.toggleByAjax(null, richfaces.getDomElement(this.id).id, true);
- break;
-
- case 'server':
-
- break;
- }
- }
+ this.__changeToggleState(true);
},
getTree: function() {
@@ -187,7 +184,7 @@
this.__selectionMode = options.selectionMode || 'ajax';
if (options.ajaxToggler) {
- this.__ajaxToggler = new Function("event", "nodeId", "newState", options.ajaxToggler);
+ this.__ajaxToggler = new Function("event", "toggleData", options.ajaxToggler);
}
},
@@ -197,8 +194,9 @@
this.__ajaxToggler = null;
},
- toggleByAjax: function(event, nodeId, newState) {
- this.__ajaxToggler(event, nodeId, newState);
+ toggleByAjax: function(event, toggleData) {
+ toggleData.treeId = this.id;
+ this.__ajaxToggler(event, toggleData);
},
getToggleMode: function() {
14 years, 2 months
JBoss Rich Faces SVN: r19789 - management/design-4x/fileUpload.
by richfaces-svn-commits@lists.jboss.org
Author: admitriev
Date: 2010-10-29 12:45:44 -0400 (Fri, 29 Oct 2010)
New Revision: 19789
Modified:
management/design-4x/fileUpload/fileUpload.html
Log:
Modified: management/design-4x/fileUpload/fileUpload.html
===================================================================
--- management/design-4x/fileUpload/fileUpload.html 2010-10-29 16:44:27 UTC (rev 19788)
+++ management/design-4x/fileUpload/fileUpload.html 2010-10-29 16:45:44 UTC (rev 19789)
@@ -8,271 +8,259 @@
<style>
body{margin : 20px}
-.rf_upd_font{ font-family : verdana /*generalFamilyFont*/ ; font-size : 11px/*generalSizeFont*/;}
-.rf_upd_itm{border-bottom:1px solid #c0c0c0 /*tableBorderColor*/;}
+.rf-upd-itm{ display : inline-block; border-bottom:1px solid #c0c0c0 /*tableBorderColor*/;}
-.rf_upd_lst_width{ width:400px;}
-.rf_upd_lst_decor{ border:1px solid #c0c0c0 /*tableBorderColor*/; background : #FFFFFF /*tableBackgroundColor*/;}
-.rf_upd_lst_oflw{height : 210px; overflow : auto; overflow-x : hidden;}
-.rf_upd_name{ padding : 2px 0px 2px 0px; font-family : verdana /*generalFamilyFont*/ ; font-size : 11px/*generalSizeFont*/;word-wrap: break-word;}
-.rf_upd_stb{ padding : 5px 0px 2px 0px;}
-.rf_upd_sts{ padding : 2px 0px 0px 0px; font-family : verdana /*generalFamilyFont*/ ; font-size : 11px/*generalSizeFont*/;}
-.rf_upd_lnk{ text-align : center; float : right; line-height : 150%; width : 20%; margin : 9px 20px 0px 0px; font-family : verdana /*generalFamilyFont*/ ; font-size : 11px/*generalSizeFont*/;}
-.rf_upd_fl {width : 70%; padding : 10px 0px 10px 10px;}
+.rf-upd-lst-width{ display : inline-block; width:400px;}
+.rf-upd-lst-decor{ display : inline-block; border:1px solid #c0c0c0 /*tableBorderColor*/; background : #FFFFFF /*tableBackgroundColor*/;}
+.rf-upd-lst-oflw{ display : inline-block; height : 210px; overflow : auto; overflow-x : hidden;}
+.rf-upd-name{ display : block; padding : 2px 0px 2px 0px; font-family : verdana /*generalFamilyFont*/ ; font-size : 11px/*generalSizeFont*/;word-wrap: break-word;}
+.rf-upd-stb{ display : block; padding : 5px 0px 2px 0px;}
+.rf-upd-sts{ display : block; padding : 2px 0px 0px 0px; font-family : verdana /*generalFamilyFont*/ ; font-size : 11px/*generalSizeFont*/;}
+.rf-upd-lnk{ display : inline-block; text-align : center; float : right; line-height : 150%; width : 20%; margin : 9px 20px 0px 0px; font-family : verdana /*generalFamilyFont*/ ; font-size : 11px/*generalSizeFont*/;}
+.rf-upd-fl { display : inline-block; width : 70%; padding : 10px 0px 10px 10px;}
-.rf_upd_anc{ color : #0078D0/*generalLinkColor*/;}
+.rf-upd-anc{ color : #0078D0/*generalLinkColor*/;}
-.rf_upd_tbr_decor{ background : #EAF0F8 /*additionalBackgroundColor*/;border-bottom:1px solid #c0c0c0 /*tableBorderColor*/;border-top:1px solid #FFFFFF /*tableBackgroundColor*/;border-left:1px solid #FFFFFF /*tableBackgroundColor*/;padding : 2px}
+.rf-upd-tbr-decor{ display : block; background : #EAF0F8 /*additionalBackgroundColor*/;border-bottom:1px solid #c0c0c0 /*tableBorderColor*/;border-top:1px solid #FFFFFF /*tableBackgroundColor*/;border-left:1px solid #FFFFFF /*tableBackgroundColor*/;padding : 2px}
-.rf_upd_bar_extr{height : 7px; border : 1px solid #c0c0c0 /*panelBorderColor*/;}
-.rf_upd_bar_uploaded{height : 7px; width : 70%; height : 100%; background : #FF9409 /**/; background-image : url(images/bg_ProgressBar_perm.gif);background-repeat : repeat-x; font-size : 0px;}
-.rf_upd_bar_del{height : 7px; width : 40%; height : 100%; background : #FF9409 /**/; background-image : url(images/bg_RegressBar_perm.gif);background-repeat : repeat-x; font-size : 0px;}
-.rf_upd_bar_shell{height : 7px; width : 100%; height : 8; background : #F1F1F1/*tableSubfooterBackgroundColor*/;}
+.rf-upd-bar-extr{ display : block; height : 7px; border : 1px solid #c0c0c0 /*panelBorderColor*/;}
+.rf-upd-bar-uploaded{ display : block; height : 7px; width : 70%; height : 100%; background : #FF9409 /**/; background-image : url(images/bg_ProgressBar_perm.gif);background-repeat : repeat-x; font-size : 0px;}
+.rf-upd-bar-del{ display : block; height : 7px; width : 40%; height : 100%; background : #FF9409 /**/; background-image : url(images/bg_RegressBar_perm.gif);background-repeat : repeat-x; font-size : 0px;}
+.rf-upd-bar-shell{ display : block; height : 7px; width : 100%; height : 8; background : #F1F1F1/*tableSubfooterBackgroundColor*/;}
-.rf_upd_btn_brd{
+.rf-upd-btn{
+ background : url(images/bg_header.png) /*from additionalBackgroundColor to trimColor*/ top left #C6D6EA /*trimColor*/ repeat-x;
+ cursor : pointer;
+ padding : 1px;
border : 1px solid #C0C0C0; /*tableBorderColor*/
margin : 2px;
}
-.rf_upd_btn{
- background : url(images/bg_header.png) /*from additionalBackgroundColor to trimColor*/ top left #C6D6EA /*trimColor*/ repeat-x;
- cursor : pointer;
- padding : 2px;
-}
-.rf_upd_btn_light{
+.rf-upd-btn-light{
background : url(images/bg_header.png) /*from additionalBackgroundColor to headerGradientColor*/ top left #C6D6EA /*trimColor*/ repeat-x;
border : 1px solid #E79A00; /*selectControlColor*/
cursor : pointer;
padding : 1px;
+ margin : 2px;
}
-.rf_upd_btn_dis{
+.rf-upd-btn-dis{
background :#f1f1f1 /*trimColor*/ repeat-x;
cursor : pointer;
padding : 2px;
}
-.rf_upd_btn_press{
+.rf-upd-btn-press{
background : url(images/bg_press.png) /*from additionalBackgroundColor to trimColor*/ top left repeat-x #EAF0F8; /* additionalBackgroundColor*/
- border : 1px solid #E79A00; /*selectControlColor*/
- padding : 2px 0px 0px 2px;
+ cursor : pointer;
+ padding : 1px;
+ border : 1px solid #C0C0C0; /*tableBorderColor*/
+ margin : 2px;
}
-a.rf_upd_btn_sel{
- text-decoration : none;
- color : #000000; /*generalTextColor*/
- display : block;
-}
-.rf_upd_btn_cnt{
- padding : 2px 6px 2px 3px;
- text-align : left;
- white-space : nowrap;
-}
-.rf_upd_ico{
- vertical-align: middle;
- margin-right : 3px;
-}
-.rf_upd_pdng { padding : 10px 0px 10px 10px;}
-.rf_upd_ico{background-position : 0px 50%; background-repeat : no-repeat; padding-left : 19px}
-.rf_upd_ico_add{background-image : url(images/ico_add.gif)}
-.rf_upd_ico_add_dis{background-image : url(images/ico_add_dis.gif); color:#C0C0C0; /*tableBorderColor*/}
+.rf-upd-btn-cnt{ display : inline-block; padding : 2px 6px 2px 3px; text-align : left; white-space : nowrap;}
-.rf_upd_ico_start{background-image : url(images/ico_start.gif)}
-.rf_upd_ico_start_dis{background-image : url(images/ico_start_dis.gif); color:#C0C0C0; /*tableBorderColor*/}
+.rf-upd-ico{ display : inline-block; background-repeat : no-repeat; padding-left : 19px; font-family : verdana /*generalFamilyFont*/ ; font-size : 11px/*generalSizeFont*/;}
+.rf-upd-ico-add{ display : inline-block; background-image : url(images/ico_add.gif)}
+.rf-upd-ico-add-dis{ display : inline-block; background-image : url(images/ico_add_dis.gif); color:#C0C0C0; /*tableBorderColor*/}
-.rf_upd_ico_stop{background-image : url(images/ico_stop.gif)}
+.rf-upd-ico-start{ display : inline-block; background-image : url(images/ico_start.gif)}
+.rf-upd-ico-start-dis{ display : inline-block; background-image : url(images/ico_start_dis.gif); color:#C0C0C0; /*tableBorderColor*/}
-.rf_upd_ico_clear{background-image : url(images/ico_clear.gif)}
-.rf_upd_ico_clear_dis{background-image : url(images/ico_clear_dis.gif); color:#C0C0C0; /*tableBorderColor*/}
+.rf-upd-ico-stop{ display : inline-block; background-image : url(images/ico_stop.gif)}
+.rf-upd-ico-clear{ display : inline-block; background-image : url(images/ico_clear.gif)}
+.rf-upd-ico-clear-dis{ display : inline-block; background-image : url(images/ico_clear_dis.gif); color:#C0C0C0; /*tableBorderColor*/}
+
</style>
+
+
</head>
<body>
-<div class="rf_upd_lst_width rf_upd_lst_decor">
- <table class="rf_upd_lst_width" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="rf_upd_tbr_decor rf_upd_lst_width">
- <div class="rf_upd_btn_brd" style=" float:left"><div class="rf_upd_btn rf_upd_font" onmouseover="this.className='rf_upd_btn_light rf_upd_font'" onmousedown="this.className='rf_upd_btn_press rf_upd_font'" onmouseup="this.className='rf_upd_btn rf_upd_font'" onmouseout="this.className='rf_upd_btn rf_upd_font'"><a href="#" class="rf_upd_btn_sel"><div class="rf_upd_btn_cnt rf_upd_font rf_upd_ico rf_upd_ico_add">Add...</div></a></div></div>
- <div class="rf_upd_btn_brd" style=" float:left"><div class="rf_upd_btn_dis rf_upd_font" onmouseover="this.className='rf_upd_btn_light rf_upd_font'" onmousedown="this.className='rf_upd_btn_press rf_upd_font'" onmouseup="this.className='rf_upd_btn rf_upd_font'" onmouseout="this.className='rf_upd_btn rf_upd_font'"><a href="#" class="rf_upd_btn_sel"><div class="rf_upd_btn_cnt rf_upd_font rf_upd_ico rf_upd_ico_start_dis"><b>Upload</b></div></a></div></div>
- <!--div class="rf_upd_btn_brd" style=" float:left"><div class="rf_upd_btn rf_upd_font" onmouseover="this.className='rf_upd_btn_light rf_upd_font'" onmousedown="this.className='rf_upd_btn_press rf_upd_font'" onmouseup="this.className='rf_upd_btn rf_upd_font'" onmouseout="this.className='rf_upd_btn rf_upd_font'"><a href="#" class="rf_upd_btn_sel"><div class="rf_upd_btn_cnt rf_upd_font rf_upd_ico rf_upd_ico_stop"><b>Stop</b></div></a></div></div-->
- <div class="rf_upd_btn_brd" style=" float:right"><div class="rf_upd_btn rf_upd_font" onmouseover="this.className='rf_upd_btn_light rf_upd_font'" onmousedown="this.className='rf_upd_btn_press rf_upd_font'" onmouseup="this.className='rf_upd_btn rf_upd_font'" onmouseout="this.className='rf_upd_btn rf_upd_font'"><a href="#" class="rf_upd_btn_sel"><div class="rf_upd_btn_cnt rf_upd_font rf_upd_ico rf_upd_ico_clear">Clear All</div></a></div></div>
- </td>
- </tr>
- </table>
- <div class="rf_upd_lst_width rf_upd_lst_oflw">
+<span class="rf-upd-lst-width rf-upd-lst-decor">
- <div class="rf_upd_itm rf_upd_lst_width">
- <div class="rf_upd_lnk"><a href="#" class="rf_upd_anc">Clear</a><br /></div>
- <div class="rf_upd_fl">
- <div class="rf_upd_name">
+ <span class="rf-upd-tbr-decor">
+ <button style="float : right" class="rf-upd-btn" onmouseover="this.className='rf-upd-btn-light'" onmousedown="this.className='rf-upd-btn-press'" onmouseup="this.className='rf-upd-btn'" onmouseout="this.className='rf-upd-btn'"><span class="rf-upd-btn-cnt rf-upd-font rf-upd-ico rf-upd-ico-clear">Clear All</span></button>
+ <button class="rf-upd-btn" onmouseover="this.className='rf-upd-btn-light'" onmousedown="this.className='rf-upd-btn-press'" onmouseup="this.className='rf-upd-btn'" onmouseout="this.className='rf-upd-btn'"><span class="rf-upd-btn-cnt rf-upd-ico rf-upd-ico-add">Add...</span></button>
+ <button class="rf-upd-btn" onmouseover="this.className='rf-upd-btn-light'" onmousedown="this.className='rf-upd-btn-press'" onmouseup="this.className='rf-upd-btn'" onmouseout="this.className='rf-upd-btn'"><span class="rf-upd-btn-cnt rf-upd-font rf-upd-ico rf-upd-ico-start-dis"><b>Upload</b></span></button>
+
+ </span>
+
+
+ <span class="rf-upd-lst-width rf-upd-lst-oflw">
+
+ <span class="rf-upd-itm rf-upd-lst-width">
+ <span class="rf-upd-lnk"><a href="#" class="rf-upd-anc">Clear</a><br /></span>
+ <span class="rf-upd-fl">
+ <span class="rf-upd-name">
N:\Projects\UIComponents\4.0\fileUpload\fileUpload.html
- </div>
- <!--div class="rf_upd_stb">
+ </span>
+ <!--span class="rf-upd-stb">
- <div class="rf_upd_bar_extr">
- <div class="rf_upd_bar_shell">
- <div class="rf_upd_bar_uploaded">
+ <span class="rf-upd-bar-extr">
+ <span class="rf-upd-bar-shell">
+ <span class="rf-upd-bar-uploaded">
- </div>
- </div>
- </div>
+ </span>
+ </span>
+ </span>
- </div -->
- <div class="rf_upd_sts">
+ </span -->
+ <span class="rf-upd-sts">
<b>Done</b>
- </div>
- </div>
- </div>
+ </span>
+ </span>
+ </span>
- <div class="rf_upd_itm rf_upd_lst_width">
- <!-- div class="rf_upd_lnk"><a href="#" class="rf_upd_anc">Stop</a><br /></div -->
- <div class="rf_upd_fl">
- <div class="rf_upd_name">
- file_upload.html
- </div>
- <div class="rf_upd_stb">
+ <span class="rf-upd-itm rf-upd-lst-width">
+ <!-- span class="rf-upd-lnk"><a href="#" class="rf-upd-anc">Stop</a><br /></span -->
+ <span class="rf-upd-fl">
+ <span class="rf-upd-name">
+ file-upload.html
+ </span>
+ <span class="rf-upd-stb">
- <div class="rf_upd_bar_extr">
- <div class="rf_upd_bar_shell">
- <div class="rf_upd_bar_uploaded">
+ <span class="rf-upd-bar-extr">
+ <span class="rf-upd-bar-shell">
+ <span class="rf-upd-bar-uploaded">
- </div>
- </div>
- </div>
+ </span>
+ </span>
+ </span>
- </div>
- <!--div class="rf_upd_sts">
+ </span>
+ <!--span class="rf-upd-sts">
<b>Done</b>
- </div -->
- </div>
- </div>
+ </span -->
+ </span>
+ </span>
- <div class="rf_upd_itm rf_upd_lst_width">
- <div class="rf_upd_lnk"><a href="#" class="rf_upd_anc">Delete</a><br /></div>
- <div class="rf_upd_fl">
- <div class="rf_upd_name">
- file_upload.html
- </div>
- <!-- div class="rf_upd_stb">
+ <span class="rf-upd-itm rf-upd-lst-width">
+ <span class="rf-upd-lnk"><a href="#" class="rf-upd-anc">Delete</a><br /></span>
+ <span class="rf-upd-fl">
+ <span class="rf-upd-name">
+ file-upload.html
+ </span>
+ <!-- span class="rf-upd-stb">
- <div class="rf_upd_bar_extr">
- <div class="rf_upd_bar_shell">
- <div class="rf_upd_bar_uploaded">
+ <span class="rf-upd-bar-extr">
+ <span class="rf-upd-bar-shell">
+ <span class="rf-upd-bar-uploaded">
- </div>
- </div>
- </div>
+ </span>
+ </span>
+ </span>
- </div -->
- <!-- div class="rf_upd_sts">
+ </span -->
+ <!-- span class="rf-upd-sts">
<b>Done</b>
- </div -->
- </div>
- </div>
+ </span -->
+ </span>
+ </span>
- <div class="rf_upd_itm rf_upd_lst_width">
- <div class="rf_upd_lnk"><a href="#" class="rf_upd_anc">Delete</a><br /></div>
- <div class="rf_upd_fl">
- <div class="rf_upd_name">
- file_upload.html
- </div>
- <!-- div class="rf_upd_stb">
+ <span class="rf-upd-itm rf-upd-lst-width">
+ <span class="rf-upd-lnk"><a href="#" class="rf-upd-anc">Delete</a><br /></span>
+ <span class="rf-upd-fl">
+ <span class="rf-upd-name">
+ file-upload.html
+ </span>
+ <!-- span class="rf-upd-stb">
- <div class="rf_upd_bar_extr">
- <div class="rf_upd_bar_shell">
- <div class="rf_upd_bar_uploaded">
+ <span class="rf-upd-bar-extr">
+ <span class="rf-upd-bar-shell">
+ <span class="rf-upd-bar-uploaded">
- </div>
- </div>
- </div>
+ </span>
+ </span>
+ </span>
- </div -->
- <!-- div class="rf_upd_sts">
+ </span -->
+ <!-- span class="rf-upd-sts">
<b>Done</b>
- </div -->
- </div>
- </div>
+ </span -->
+ </span>
+ </span>
- <div class="rf_upd_itm rf_upd_lst_width">
- <div class="rf_upd_lnk"><a href="#" class="rf_upd_anc">Delete</a><br /></div>
- <div class="rf_upd_fl">
- <div class="rf_upd_name">
+ <span class="rf-upd-itm rf-upd-lst-width">
+ <span class="rf-upd-lnk"><a href="#" class="rf-upd-anc">Delete</a><br /></span>
+ <span class="rf-upd-fl">
+ <span class="rf-upd-name">
N:\Projects\UIComponents\4.0\fileUpload\fileUpload.html
- </div>
- <!-- div class="rf_upd_stb">
+ </span>
+ <!-- span class="rf-upd-stb">
- <div class="rf_upd_bar_extr">
- <div class="rf_upd_bar_shell">
- <div class="rf_upd_bar_uploaded">
+ <span class="rf-upd-bar-extr">
+ <span class="rf-upd-bar-shell">
+ <span class="rf-upd-bar-uploaded">
- </div>
- </div>
- </div>
+ </span>
+ </span>
+ </span>
- </div -->
- <!-- div class="rf_upd_sts">
+ </span -->
+ <!-- span class="rf-upd-sts">
<b>Done</b>
- </div -->
- </div>
- </div>
+ </span -->
+ </span>
+ </span>
- <div class="rf_upd_itm rf_upd_lst_width">
- <div class="rf_upd_lnk"><a href="#" class="rf_upd_anc">Delete</a><br /></div>
- <div class="rf_upd_fl">
- <div class="rf_upd_name">
- file_upload.html
- </div>
- <!-- div class="rf_upd_stb">
+ <span class="rf-upd-itm rf-upd-lst-width">
+ <span class="rf-upd-lnk"><a href="#" class="rf-upd-anc">Delete</a><br /></span>
+ <span class="rf-upd-fl">
+ <span class="rf-upd-name">
+ file-upload.html
+ </span>
+ <!-- span class="rf-upd-stb">
- <div class="rf_upd_bar_extr">
- <div class="rf_upd_bar_shell">
- <div class="rf_upd_bar_uploaded">
+ <span class="rf-upd-bar-extr">
+ <span class="rf-upd-bar-shell">
+ <span class="rf-upd-bar-uploaded">
- </div>
- </div>
- </div>
+ </span>
+ </span>
+ </span>
- </div -->
- <!-- div class="rf_upd_sts">
+ </span -->
+ <!-- span class="rf-upd-sts">
<b>Done</b>
- </div -->
- </div>
- </div>
+ </span -->
+ </span>
+ </span>
- <div class="rf_upd_itm rf_upd_lst_width">
- <div class="rf_upd_lnk"><a href="#" class="rf_upd_anc">Delete</a><br /></div>
- <div class="rf_upd_fl">
- <div class="rf_upd_name">
- file_upload.html
- </div>
- <!-- div class="rf_upd_stb">
+ <span class="rf-upd-itm rf-upd-lst-width">
+ <span class="rf-upd-lnk"><a href="#" class="rf-upd-anc">Delete</a><br /></span>
+ <span class="rf-upd-fl">
+ <span class="rf-upd-name">
+ file-upload.html
+ </span>
+ <!-- span class="rf-upd-stb">
- <div class="rf_upd_bar_extr">
- <div class="rf_upd_bar_shell">
- <div class="rf_upd_bar_uploaded">
+ <span class="rf-upd-bar-extr">
+ <span class="rf-upd-bar-shell">
+ <span class="rf-upd-bar-uploaded">
- </div>
- </div>
- </div>
+ </span>
+ </span>
+ </span>
- </div -->
- <!-- div class="rf_upd_sts">
+ </span -->
+ <!-- span class="rf-upd-sts">
<b>Done</b>
- </div -->
- </div>
- </div>
+ </span -->
+ </span>
+ </span>
@@ -282,11 +270,11 @@
- </div>
+ </span>
-</div>
+</span>
</body>
14 years, 2 months
JBoss Rich Faces SVN: r19788 - management/design-4x/panel_menu.
by richfaces-svn-commits@lists.jboss.org
Author: admitriev
Date: 2010-10-29 12:44:27 -0400 (Fri, 29 Oct 2010)
New Revision: 19788
Modified:
management/design-4x/panel_menu/panel_menu.html
Log:
Modified: management/design-4x/panel_menu/panel_menu.html
===================================================================
--- management/design-4x/panel_menu/panel_menu.html 2010-10-29 16:18:11 UTC (rev 19787)
+++ management/design-4x/panel_menu/panel_menu.html 2010-10-29 16:44:27 UTC (rev 19788)
@@ -212,16 +212,211 @@
</div>
+</div>
+
+
+<div class="rf-pm-size">
+
+ <div class="rf-pm-lbl">
+
+ <div id="1">
+
+ <div class="rf-pm-itm rf-pm-1">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1
+ </span>
+ <br clear="all">
+ </div>
+
+ <div class="rf-pm-2 rf-pm-hid">
+
+ <div id="1.1">
+ <div class="rf-pm-itm">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item 1.1
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ <div id="1.2">
+ <div class="rf-pm-itm">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.2
+ </span>
+ <br clear="all">
+ </div>
+
+ <div class="rf-pm-3 rf-pm-vis ">
+
+ <div id="1.2.1">
+ <div class="rf-pm-itm">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.2.1
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ <div id="1.2.2">
+ <div class="rf-pm-itm rf-pm-sel">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.2.2
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ </div>
+ </div>
+
+ <div id="1.3">
+ <div class="rf-pm-itm rf-pm-dis">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.3
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ <div id="1.4">
+ <div class="rf-pm-itm rf-pm-dis">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.4
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
+
</div>
+<div class="rf-pm-size">
+ <div class="rf-pm-lbl">
+
+ <div id="1">
+
+ <div class="rf-pm-itm rf-pm-1">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1
+ </span>
+ <br clear="all">
+ </div>
+
+ <div class="rf-pm-2 rf-pm-hid">
+ <div id="1.1">
+ <div class="rf-pm-itm">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item 1.1
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ <div id="1.2">
+ <div class="rf-pm-itm">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.2
+ </span>
+ <br clear="all">
+ </div>
+
+ <div class="rf-pm-3 rf-pm-vis ">
+
+ <div id="1.2.1">
+ <div class="rf-pm-itm">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.2.1
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ <div id="1.2.2">
+ <div class="rf-pm-itm rf-pm-sel">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.2.2
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ </div>
+ </div>
+
+ <div id="1.3">
+ <div class="rf-pm-itm rf-pm-dis">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.3
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ <div id="1.4">
+ <div class="rf-pm-itm rf-pm-dis">
+ <span class="rf-pm-ico-lft rf-pm-icon"></span>
+ <span class="rf-pm-ico-rgt rf-pm-icon"></span>
+ <span class="rf-pm-txt">
+ Display item name 1.4
+ </span>
+ <br clear="all">
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
+
+</div>
+
+
+
+
+
+
+
</body>
</html>
14 years, 2 months