JBoss Rich Faces SVN: r20105 - in trunk: ui/common/ui/src/main/java/org/richfaces/component and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 12:01:46 -0500 (Thu, 18 Nov 2010)
New Revision: 20105
Modified:
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/renderkit/RenderKitUtils.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
trunk/ui/iteration/ui/src/main/templates/tree.template.xml
trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml
Log:
https://jira.jboss.org/browse/RF-9714
Modified: trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18 17:01:46 UTC (rev 20105)
@@ -31,6 +31,32 @@
</h:head>
<h:body>
+ <h:outputScript>
+ function getNodeStateString(treeNode) {
+ return treeNode.isLeaf() ?
+ 'leaf'
+ : (treeNode.isExpanded() ? 'expanded' : 'collapsed');
+ }
+
+ function handleNodeToggle(nodeData, event, isTreeNodeLevel) {
+ var treeNode = RichFaces.$(event.target);
+ RichFaces.log.info('Toggle event ' + (isTreeNodeLevel ? '(treeNode level)' : '')
+ + '[' + nodeData + ']:\n ' + treeNode.getId() + ' became ' + getNodeStateString(treeNode));
+ }
+
+ function handleNodeSelect(event) {
+ var treeNode = RichFaces.$(event.target);
+
+ var selectedNodes = event.rf.data.selection;
+ var selection = new Array();
+ jQuery.each(selectedNodes, function(k, v) {
+ selection.push(v.getId());
+ });
+
+ RichFaces.log.info('Select event:\n ' + selection.join(''));
+ }
+ </h:outputScript>
+
<h:messages id="messages" />
<h:form>
@@ -78,7 +104,9 @@
Tree with customized look:
<it:tree id="customizedTree" var="node" value="#{treeBean.rootNodes}"
selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}"
- styleClass="#{treeBean.showCustomClasses ? 'customClass' : ''}">
+ styleClass="#{treeBean.showCustomClasses ? 'customClass' : ''}"
+ nodeClass="customNodeClassFromTree"
+ handleClass="customHandleClassFromTree" iconClass="customIconClassFromTree" labelClass="customLabelClassFromTree">
<it:treeNode iconLeaf="/images/leaf.png" iconExpanded="/images/minus.png" iconCollapsed="/images/plus.png"
styleClass="customNodeClass" handleClass="customHandleClass" iconClass="customIconClass" labelClass="customLabelClass">
@@ -93,10 +121,11 @@
Tree with client-side event handlers:
<it:tree id="clientSideEventsTree" var="node" value="#{treeBean.rootNodes}"
- selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
+ selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}"
+ onnodetoggle="handleNodeToggle("#{node.data}", event, false)"
+ onselectionchange="handleNodeSelect(event)">
- <it:treeNode ontoggle="RichFaces.log.info('Toggle event: target is - ' + event.target.id)"
- onselect="RichFaces.log.info('Select event: target is - ' + event.target.id)">
+ <it:treeNode ontoggle="handleNodeToggle("#{node.data}", event, true)">
#{node.data}
</it:treeNode>
</it:tree>
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-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-11-18 17:01:46 UTC (rev 20105)
@@ -853,6 +853,10 @@
return clientId;
}
+ public String getBaseClientId(FacesContext context) {
+ return super.getClientId(context);
+ }
+
/**
* Save current state of data variable.
*
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-11-18 17:01:46 UTC (rev 20105)
@@ -326,6 +326,8 @@
return false;
} else if (attributeValue instanceof Long && (Long) attributeValue == Long.MIN_VALUE) {
return false;
+ } else if (attributeValue instanceof Collection<?> || attributeValue instanceof Map<?, ?>) {
+ return true;
}
return attributeValue.toString().length() > 0;
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18 17:01:46 UTC (rev 20105)
@@ -43,6 +43,7 @@
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.Range;
import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
@@ -134,6 +135,26 @@
public abstract boolean isImmediate();
+ public abstract String getIconLeaf();
+
+ public abstract String getIconExpanded();
+
+ public abstract String getIconCollapsed();
+
+ public abstract String getNodeClass();
+
+ public abstract String getHandleClass();
+
+ public abstract String getIconClass();
+
+ public abstract String getLabelClass();
+
+ @Attribute(events = @EventName("nodetoggle"))
+ public abstract String getOnnodetoggle();
+
+ @Attribute(events = @EventName("selectionchange"))
+ public abstract String getOnselectionchange();
+
@Attribute(defaultValue = "SwitchType.DEFAULT")
public abstract SwitchType getToggleType();
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-18 17:01:46 UTC (rev 20105)
@@ -28,6 +28,8 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunction;
import org.richfaces.component.AbstractTree;
import org.richfaces.component.AbstractTreeNode;
import org.richfaces.component.TreeRange;
@@ -125,6 +127,7 @@
null);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE, treeNodeComponent.getClientId(context), null);
+ emitClientToggleEvent(treeNodeComponent, nodeState);
treeNodeComponent.encodeAll(context);
}
@@ -134,4 +137,15 @@
public abstract void encode() throws IOException;
+ private void emitClientToggleEvent(AbstractTreeNode treeNode, TreeNodeState nodeState) {
+ if (treeNode.getClientId(context).equals(context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_ATTRIBUTE))) {
+ TreeNodeState submittedState = ((Boolean) (context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_STATE_ATTRIBUTE)))
+ ? TreeNodeState.expanded : TreeNodeState.collapsed;
+
+ if (submittedState == nodeState || nodeState == TreeNodeState.leaf) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ajaxContext.appendOncomplete(new JSFunction("RichFaces.ui.TreeNode.emitToggleEvent", treeNode.getClientId(context)));
+ }
+ }
+ }
}
\ No newline at end of file
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java 2010-11-18 17:01:46 UTC (rev 20105)
@@ -22,6 +22,7 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Collections;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialResponseWriter;
@@ -58,6 +59,7 @@
PartialResponseWriter prw = context.getPartialViewContext().getPartialResponseWriter();
prw.startUpdate(elementId);
+ Object clientEventHandlers = null;
Object initialRowKey = tree.getRowKey();
try {
TreeRenderingContext.create(context, tree);
@@ -66,6 +68,7 @@
prw.endUpdate();
+ clientEventHandlers = TreeRenderingContext.get(context).getHandlers();
} finally {
try {
tree.setRowKey(context, initialRowKey);
@@ -77,7 +80,8 @@
}
prw.startEval();
- JSFunction function = new JSFunction("RichFaces.ui.TreeNode.initNodeByAjax", elementId);
+ JSFunction function = new JSFunction("RichFaces.ui.TreeNode.initNodeByAjax", elementId,
+ Collections.singletonMap("clientEventHandlers", clientEventHandlers));
prw.write(function.toScript());
prw.endEval();
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-11-18 17:01:46 UTC (rev 20105)
@@ -21,6 +21,8 @@
*/
package org.richfaces.renderkit;
+import static org.richfaces.renderkit.RenderKitUtils.getFirstNonEmptyAttribute;
+
import java.io.IOException;
import java.util.Map;
@@ -29,6 +31,7 @@
import javax.faces.context.PartialViewContext;
import javax.faces.context.ResponseWriter;
+import org.richfaces.component.AbstractTree;
import org.richfaces.component.AbstractTreeNode;
import org.richfaces.component.MetaComponentResolver;
import org.richfaces.component.SwitchType;
@@ -42,14 +45,14 @@
*/
public class TreeNodeRendererBase extends RendererBase implements MetaComponentRenderer {
+ static final String AJAX_TOGGLED_NODE_ATTRIBUTE = TreeNodeRendererBase.class.getName() + ":AJAX_TOGGLED_NODE_ATTRIBUTE";
+
+ static final String AJAX_TOGGLED_NODE_STATE_ATTRIBUTE = TreeNodeRendererBase.class.getName() + ":AJAX_TOGGLED_NODE_STATE_ATTRIBUTE";
+
private static final String NEW_NODE_TOGGLE_STATE = "__NEW_NODE_TOGGLE_STATE";
private static final String TRIGGER_NODE_AJAX_UPDATE = "__TRIGGER_NODE_AJAX_UPDATE";
- private static final ComponentAttribute ONTOGGLE_ATTRIBUTE = new ComponentAttribute("ontoggle").setEventNames("toggle");
-
- private static final ComponentAttribute ONSELECT_ATTRIBUTE = new ComponentAttribute("onselect").setEventNames("select");
-
@Override
public void decode(FacesContext context, UIComponent component) {
super.decode(context, component);
@@ -68,6 +71,9 @@
PartialViewContext pvc = context.getPartialViewContext();
if (pvc.isAjaxRequest() && map.get(component.getClientId(context) + TRIGGER_NODE_AJAX_UPDATE) != null) {
pvc.getRenderIds().add(treeNode.getClientId(context) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + AbstractTreeNode.SUBTREE_META_COMPONENT_ID);
+
+ context.getAttributes().put(AJAX_TOGGLED_NODE_ATTRIBUTE, component.getClientId(context));
+ context.getAttributes().put(AJAX_TOGGLED_NODE_STATE_ATTRIBUTE, expanded);
}
}
}
@@ -91,12 +97,15 @@
return (TreeNodeState) context.getAttributes().get(TreeEncoderBase.TREE_NODE_STATE_ATTRIBUTE);
}
+ protected UIComponent getTreeComponent(UIComponent treeNodeComponent) {
+ return ((AbstractTreeNode) treeNodeComponent).findTreeComponent();
+ }
+
protected void encodeDefaultIcon(FacesContext context, UIComponent component, String styleClass) throws IOException {
ResponseWriter writer = context.getResponseWriter();
writer.startElement(HtmlConstants.SPAN_ELEM, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
- concatClasses(styleClass, component.getAttributes().get("iconClass")), null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, styleClass, null);
writer.endElement(HtmlConstants.SPAN_ELEM);
}
@@ -104,55 +113,57 @@
ResponseWriter writer = context.getResponseWriter();
writer.startElement(HtmlConstants.IMG_ELEMENT, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
- concatClasses(styleClass, component.getAttributes().get("iconClass")), null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, styleClass, null);
writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
writer.writeURIAttribute(HtmlConstants.SRC_ATTRIBUTE, RenderKitUtils.getResourceURL(iconSource, context), null);
writer.endElement(HtmlConstants.IMG_ELEMENT);
}
-
-
protected void encodeIcon(FacesContext context, UIComponent component) throws IOException {
TreeNodeState nodeState = getNodeState(context);
AbstractTreeNode treeNode = (AbstractTreeNode) component;
+
+ AbstractTree tree = treeNode.findTreeComponent();
if (nodeState.isLeaf()) {
- String iconLeaf = (String) treeNode.getAttributes().get("iconLeaf");
- encodeIconForNodeState(context, treeNode, nodeState, iconLeaf);
+ String iconLeaf = (String) getFirstNonEmptyAttribute("iconLeaf", treeNode, tree);
+ encodeIconForNodeState(context, tree, treeNode, nodeState, iconLeaf);
} else {
- String iconExpanded = (String) treeNode.getAttributes().get("iconExpanded");
- String iconCollapsed = (String) treeNode.getAttributes().get("iconCollapsed");
+ String iconExpanded = (String) getFirstNonEmptyAttribute("iconExpanded", treeNode, tree);
+ String iconCollapsed = (String) getFirstNonEmptyAttribute("iconCollapsed", treeNode, tree);
if (Strings.isNullOrEmpty(iconCollapsed) && Strings.isNullOrEmpty(iconExpanded)) {
- encodeDefaultIcon(context, component, nodeState.getIconClass());
+ encodeIconForNodeState(context, tree, treeNode, nodeState, null);
} else {
SwitchType toggleType = treeNode.findTreeComponent().getToggleType();
if (toggleType == SwitchType.client || nodeState == TreeNodeState.collapsed) {
- encodeIconForNodeState(context, treeNode, TreeNodeState.collapsed, iconCollapsed);
+ encodeIconForNodeState(context, tree, treeNode, TreeNodeState.collapsed, iconCollapsed);
}
if (toggleType == SwitchType.client || nodeState == TreeNodeState.expanded) {
- encodeIconForNodeState(context, treeNode, TreeNodeState.expanded, iconExpanded);
+ encodeIconForNodeState(context, tree, treeNode, TreeNodeState.expanded, iconExpanded);
}
}
}
}
- protected void encodeIconForNodeState(FacesContext context, AbstractTreeNode treeNode, TreeNodeState nodeState, String customIcon) throws IOException {
+ protected void encodeIconForNodeState(FacesContext context, AbstractTree tree, AbstractTreeNode treeNode, TreeNodeState nodeState, String customIcon) throws IOException {
if (Strings.isNullOrEmpty(customIcon)) {
- encodeDefaultIcon(context, treeNode, nodeState.getIconClass());
+ encodeDefaultIcon(context, treeNode, concatClasses(nodeState.getIconClass(), treeNode.getAttributes().get("iconClass"),
+ tree.getAttributes().get("iconClass")));
} else {
- encodeCustomIcon(context, treeNode, nodeState.getCustomIconClass(), customIcon);
+ encodeCustomIcon(context, treeNode, concatClasses(nodeState.getCustomIconClass(), treeNode.getAttributes().get("iconClass"),
+ tree.getAttributes().get("iconClass")), customIcon);
}
}
- protected void addEventHandlersToRenderingContext(FacesContext facesContext, UIComponent component) {
- String ontoggle = (String) RenderKitUtils.getAttributeAndBehaviorsValue(facesContext, component, ONTOGGLE_ATTRIBUTE);
- String onselect = (String) RenderKitUtils.getAttributeAndBehaviorsValue(facesContext, component, ONSELECT_ATTRIBUTE);
+ protected void addClientEventHandlers(FacesContext facesContext, UIComponent component) {
+ AbstractTreeNode treeNode = (AbstractTreeNode) component;
- TreeRenderingContext.get(facesContext).addHandlers(ontoggle, null, onselect, null);
+ //TODO check toggle/selection types
+ TreeRenderingContext renderingContext = TreeRenderingContext.get(facesContext);
+ renderingContext.addHandlers(treeNode);
}
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java 2010-11-18 17:01:46 UTC (rev 20105)
@@ -29,8 +29,13 @@
import javax.faces.context.FacesContext;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptStringBase;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.component.AbstractTree;
+import org.richfaces.component.AbstractTreeNode;
+import org.richfaces.component.SwitchType;
/**
* @author Nick Belaevski
@@ -40,24 +45,32 @@
private static final String ATTRIBUTE_NAME = TreeRenderingContext.class.getName() + ":ATTRIBUTE_NAME";
+ private static final ComponentAttribute ONTOGGLE_ATTRIBUTE = new ComponentAttribute("ontoggle").setEventNames("toggle");
+
+ private static final ComponentAttribute ONNODETOGGLE_ATTRIBUTE = new ComponentAttribute("onnodetoggle").setEventNames("nodetoggle");
+
public static final class Handlers extends ScriptStringBase {
-
+
private String toggleHandler;
- private String treeToggleHandler;
+ private String nodeToggleHandler;
- private String selectHandler;
-
- private String treeSelectHandler;
-
- public void setSelectHandler(String selectHandler) {
- this.selectHandler = selectHandler;
+ protected Object chain(String firstHandler, String secondHandler) {
+ if (isNullOrEmpty(firstHandler) && isNullOrEmpty(secondHandler)) {
+ return null;
+ }
+
+ if (isNullOrEmpty(firstHandler)) {
+ return secondHandler;
+ }
+
+ if (isNullOrEmpty(secondHandler)) {
+ return firstHandler;
+ }
+
+ return new JSFunction("jsf.util.chain", JSReference.THIS, JSReference.EVENT, firstHandler, secondHandler).toScript();
}
- public String getSelectHandler() {
- return selectHandler;
- }
-
public void setToggleHandler(String toggleHandler) {
this.toggleHandler = toggleHandler;
}
@@ -66,41 +79,35 @@
return toggleHandler;
}
- public String getTreeToggleHandler() {
- return treeToggleHandler;
+ public String getNodeToggleHandler() {
+ return nodeToggleHandler;
}
- public void setTreeToggleHandler(String treeToggleHandler) {
- this.treeToggleHandler = treeToggleHandler;
+ public void setNodeToggleHandler(String nodeToggleHandler) {
+ this.nodeToggleHandler = nodeToggleHandler;
}
- public String getTreeSelectHandler() {
- return treeSelectHandler;
- }
-
- public void setTreeSelectHandler(String treeSelectHandler) {
- this.treeSelectHandler = treeSelectHandler;
- }
-
public void appendScript(Appendable target) throws IOException {
- // TODO Auto-generated method stub
-
+ Object chain = chain(toggleHandler, nodeToggleHandler);
+ ScriptUtils.appendScript(target, chain);
}
}
private FacesContext context;
-
+
private AbstractTree tree;
private String baseClientId;
private Map<String, Handlers> handlersMap = new HashMap<String, Handlers>();
+ private Handlers handlers;
+
private TreeRenderingContext(FacesContext context, AbstractTree tree) {
super();
this.context = context;
this.tree = tree;
- this.baseClientId = tree.getClientId(context);
+ this.baseClientId = tree.getBaseClientId(context);
}
public static TreeRenderingContext create(FacesContext context, AbstractTree tree) {
@@ -117,24 +124,32 @@
context.getAttributes().remove(ATTRIBUTE_NAME);
}
- public void addHandlers(String toggleHandler, String treeToggleHandler, String selectHandler, String treeSelectHandler) {
- String clientId = tree.findTreeNodeComponent().getClientId(context);
+ private Handlers getOrCreateHandlers(String relativeClientId) {
+ if (handlers == null) {
+ handlers = new Handlers();
+ handlersMap.put(relativeClientId, handlers);
+ }
+ return handlers;
+ }
+
+ public void addHandlers(AbstractTreeNode treeNode) {
+ handlers = null;
+ String clientId = treeNode.getClientId(context);
+
String relativeClientId = clientId.substring(baseClientId.length());
- if (isNullOrEmpty(toggleHandler) && isNullOrEmpty(treeToggleHandler)
- && isNullOrEmpty(selectHandler) && isNullOrEmpty(treeSelectHandler)) {
+ if (tree.getToggleType() != SwitchType.server) {
+ String toggleHandler = (String) RenderKitUtils.getAttributeAndBehaviorsValue(context, treeNode, ONTOGGLE_ATTRIBUTE);
+ if (!isNullOrEmpty(toggleHandler)) {
+ getOrCreateHandlers(relativeClientId).setToggleHandler(toggleHandler);
+ }
- return;
+ String nodeToggleHandler = (String) RenderKitUtils.getAttributeAndBehaviorsValue(context, tree, ONNODETOGGLE_ATTRIBUTE);
+ if (!isNullOrEmpty(nodeToggleHandler)) {
+ getOrCreateHandlers(relativeClientId).setNodeToggleHandler(nodeToggleHandler);
+ }
}
-
- Handlers handlers = new Handlers();
- handlers.setToggleHandler(toggleHandler);
- handlers.setTreeToggleHandler(treeToggleHandler);
- handlers.setSelectHandler(selectHandler);
- handlers.setTreeSelectHandler(treeSelectHandler);
-
- handlersMap.put(relativeClientId, handlers);
}
public Object getHandlers() {
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 17:01:46 UTC (rev 20105)
@@ -46,10 +46,16 @@
this.__initializeChildren(commonOptions);
- this.__clientEventHandlers = (commonOptions.clientEventHandlers || {})[commonOptions.treeId + id];
+ var __toggleHandler = (commonOptions.clientEventHandlers || {})[this.getId().substring(commonOptions.treeId.length)];
+
+ if (__toggleHandler) {
+ richfaces.Event.bind(this.__rootElt, "toggle", new Function("event", __toggleHandler));
+ }
},
destroy: function() {
+ this.$super.destroy.call(this);
+
if (this.parent) {
this.parent.removeChild(this);
this.parent = null;
@@ -157,6 +163,10 @@
},
+ __fireToggleEvent: function() {
+ richfaces.Event.fire(this.__rootElt, "toggle");
+ },
+
__changeToggleState: function(newState) {
if (!this.isLeaf()) {
if (newState ^ this.isExpanded()) {
@@ -173,6 +183,7 @@
}
this.__updateClientToggleStateInput(newState);
+ this.__fireToggleEvent();
break;
case 'ajax':
@@ -221,6 +232,8 @@
richfaces.ui.TreeNode.initNodeByAjax = function(nodeId, commonOptions) {
var node = $(document.getElementById(nodeId));
+ var opts = commonOptions || {};
+
if (node.nextAll(".rf-tr-nd:first").length != 0) {
node.removeClass("rf-tr-nd-last");
}
@@ -230,11 +243,22 @@
var idx = node.prevAll(".rf-tr-nd").length;
var parentNode = richfaces.$(parent[0]);
- var newChild = new richfaces.ui.TreeNode(node[0], commonOptions);
+ opts.treeId = parentNode.getTree().getId();
+
+ var newChild = new richfaces.ui.TreeNode(node[0], opts);
parentNode.addChild(newChild, idx);
parentNode.getTree().__updateSelection();
};
+ richfaces.ui.TreeNode.emitToggleEvent = function(nodeId) {
+ var node = document.getElementById(nodeId);
+ if (!node) {
+ return;
+ }
+
+ richfaces.$(node).__fireToggleEvent();
+ };
+
var findTree = function(elt) {
return richfaces.$($(elt).closest(".rf-tr"));
};
@@ -267,6 +291,10 @@
this.__ajaxSubmitFunction = new Function("event", "source", "params", options.ajaxSubmitFunction);
}
+ if (options.onselectionchange) {
+ richfaces.Event.bind(this.__treeRootElt, "selectionchange", new Function("event", options.onselectionchange));
+ }
+
this.__selectionInput = $(" > .rf-tr-sel-inp", this.__treeRootElt);
this.__treeRootElt.delegate(".rf-trn-hnd", "click", this, this.__itemHandleClicked);
@@ -369,13 +397,14 @@
this.__handleSelectionChange();
},
- __resetSelection: function() {
- this.__selectedNodeId = null;
- this.__selectionInput.val("");
- },
-
__updateSelection: function() {
var oldSelection = this.__selectedNodeId;
+ var nodeId = this.__selectionInput.val();
+
+ if (oldSelection == nodeId) {
+ return;
+ }
+
if (oldSelection) {
var oldSelectionNode = richfaces.$(oldSelection);
if (oldSelectionNode) {
@@ -383,13 +412,20 @@
}
}
- var nodeId = this.__selectionInput.val();
+ var newSelectionNode;
+ var selection = new Array();
- var newSelectionNode = richfaces.$(nodeId);
+ if (nodeId) {
+ newSelectionNode = richfaces.$(nodeId);
+ }
+
if (newSelectionNode) {
newSelectionNode.__setSelected(true);
+ selection.push(newSelectionNode);
}
+
this.__selectedNodeId = nodeId;
+ richfaces.Event.fire(this.__treeRootElt, "selectionchange", {selection: selection});
}
});
Modified: trunk/ui/iteration/ui/src/main/templates/tree.template.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/templates/tree.template.xml 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/iteration/ui/src/main/templates/tree.template.xml 2010-11-18 17:01:46 UTC (rev 20105)
@@ -13,6 +13,7 @@
<cdk:resource-dependency name="ajax.reslib" library="org.richfaces" />
<cdk:resource-dependency name="base-component.reslib" library="org.richfaces" />
+ <cdk:resource-dependency name="richfaces-event.js" />
<cdk:resource-dependency name="tree.js" library="org.richfaces" />
<cdk:resource-dependency name="tree.ecss" library="org.richfaces" />
@@ -43,6 +44,7 @@
<cdk:scriptOption attributes="toggleType" defaultValue="SwitchType.DEFAULT" />
<cdk:scriptOption name="selectionType" value="#{getSelectionMode(facesContext, component)}" defaultValue="SwitchType.client" />
<cdk:scriptOption name="ajaxSubmitFunction" value="#{getAjaxSubmitFunction(facesContext, component)}" />
+ <cdk:scriptOption attributes="onselectionchange" />
<cdk:scriptOption variables="clientEventHandlers" />
</cdk:scriptObject>
Modified: trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-11-18 16:56:05 UTC (rev 20104)
+++ trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-11-18 17:01:46 UTC (rev 20105)
@@ -22,9 +22,11 @@
<cc:implementation>
<cdk:object name="nodeState" value="#{getNodeState(facesContext)}" type="org.richfaces.renderkit.TreeNodeState" />
- <div class="#{concatClasses('rf-trn', component.attributes['styleClass'])}">
- <span class="#{concatClasses(nodeState.handleClass, component.attributes['handleClass'])}"></span>
+ <cdk:call expression="addClientEventHandlers(facesContext, component)" />
+ <div class="#{concatClasses('rf-trn', component.attributes['styleClass'], tree.attributes['nodeClass'])}">
+ <span class="#{concatClasses(nodeState.handleClass, component.attributes['handleClass'], tree.attributes['handleClass'])}"></span>
+
<span class="rf-trn-cnt">
<cdk:call expression="encodeIcon(facesContext, component)" />
<span class="#{concatClasses('rf-trn-lbl', component.attributes['labelClass'])}">
14 years, 2 months
JBoss Rich Faces SVN: r20104 - trunk/ui/output/ui/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 11:56:05 -0500 (Thu, 18 Nov 2010)
New Revision: 20104
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java
Log:
svn rebase...
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java 2010-11-18 16:56:05 UTC (rev 20104)
@@ -0,0 +1,49 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
+
+/**
+ * JSF component class
+ *
+ */
+@JsfComponent(tag = @Tag(type = TagType.Facelets),
+ renderer = @JsfRenderer(type = "org.richfaces.PanelRenderer")
+ )
+public class UIPanel extends UIComponentBase {
+ private static final String COMPONENT_FAMILY = "org.richfaces.Panel";
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+}
14 years, 2 months
JBoss Rich Faces SVN: r20103 - in trunk: core/api/src/test/java/org/ajax4jsf/javascript and 13 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 11:54:07 -0500 (Thu, 18 Nov 2010)
New Revision: 20103
Added:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java
Modified:
trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSBind.java
trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunction.java
trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java
trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java
trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptString.java
trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptStringBase.java
trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java
trunk/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java
trunk/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java
trunk/core/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java
trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/ClientSelectItem.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
trunk/ui/iteration/ui/src/main/templates/tree.template.xml
trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
trunk/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
trunk/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
Log:
RF-9714
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSBind.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSBind.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSBind.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -23,6 +23,8 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
/**
* Created 04.08.2008
* @author Nick Belaevski
@@ -38,9 +40,9 @@
this.vars = vars;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append("function () {");
- functionString.append("var vars = {");
+ public void appendScript(Appendable target) throws IOException {
+ target.append("function () {");
+ target.append("var vars = {");
boolean isFirst = true;
@@ -48,17 +50,18 @@
if (isFirst) {
isFirst = false;
} else {
- functionString.append(',');
+ target.append(',');
}
- functionString.append(var);
- functionString.append(':');
- functionString.append(var);
+ target.append(var);
+ target.append(':');
+ target.append(var);
}
- functionString.append("};");
- functionString.append("return function() { with (vars) {");
- functionString.append(function.toScript());
- functionString.append("}}}()");
+ target.append("};");
+ target.append("return function() { with (vars) {");
+ target.append(function.toScript());
+ target.append("}}}()");
}
+
}
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunction.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunction.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunction.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -23,6 +23,7 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -52,8 +53,8 @@
return this;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(name).append('(');
+ public void appendScript(Appendable target) throws IOException {
+ target.append(name).append('(');
boolean first = true;
List<?> parameters = getParameters();
@@ -63,26 +64,27 @@
Object element = param.next();
if (!first) {
- functionString.append(',');
+ target.append(',');
}
if (null != element) {
- functionString.append(ScriptUtils.toScript(element));
+ ScriptUtils.appendScript(target, element);
} else {
- functionString.append("null");
+ target.append("null");
}
first = false;
}
}
- functionString.append(")");
+ target.append(")");
}
-
+
/**
* @return the parameters
*/
public List<Object> getParameters() {
return this.parameters;
}
+
}
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -23,6 +23,7 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -56,18 +57,14 @@
return this;
}
- /*
- * (non-Javadoc)
- * @see org.ajax4jsf.components.renderkit.scriptutils.ScriptString#appendScript(java.lang.StringBuffer)
- */
- public void appendScript(StringBuffer functionString) {
- functionString.append("function");
+ public void appendScript(Appendable target) throws IOException {
+ target.append("function");
if (null != name) {
- functionString.append(" ").append(name);
+ target.append(" ").append(name);
}
- functionString.append("(");
+ target.append("(");
boolean first = true;
@@ -75,16 +72,16 @@
Object element = param.next();
if (!first) {
- functionString.append(',');
+ target.append(',');
}
- functionString.append(element.toString());
+ target.append(element.toString());
first = false;
}
- functionString.append("){").append(body).append("}");
+ target.append("){").append(body).append("}");
}
-
+
/**
* @return the name
*/
@@ -98,4 +95,5 @@
public void setName(String name) {
this.name = name;
}
+
}
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -23,6 +23,7 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
import java.io.Serializable;
/**
@@ -53,14 +54,10 @@
this.literal = literal;
}
- /*
- * (non-Javadoc)
- * @see org.ajax4jsf.javascript.ScriptString#appendScript(java.lang.StringBuffer)
- */
- public void appendScript(StringBuffer jsString) {
- jsString.append(literal);
+ public void appendScript(Appendable target) throws IOException {
+ target.append(literal);
}
-
+
/**
* @return the literal
*/
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSObject.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -23,6 +23,8 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:30 $
@@ -40,8 +42,8 @@
// TODO Auto-generated constructor stub
}
- public void appendScript(StringBuffer functionString) {
- functionString.append("new ");
- super.appendScript(functionString);
+ public void appendScript(Appendable target) throws IOException {
+ target.append("new ");
+ super.appendScript(target);
}
}
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -23,6 +23,8 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
/**
* Create reference to JavaScript variable with optional index.
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
@@ -58,15 +60,14 @@
this.index = index;
}
- /*
- * (non-Javadoc)
- * @see org.ajax4jsf.javascript.ScriptString#appendScript(java.lang.StringBuffer)
- */
- public void appendScript(StringBuffer functionString) {
- functionString.append(name);
+ public void appendScript(Appendable target) throws IOException {
+ target.append(name);
if (null != index) {
- functionString.append("[").append(ScriptUtils.toScript(index)).append("]");
+ target.append("[");
+ ScriptUtils.appendScript(target, index);
+ target.append("]");
}
}
+
}
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptString.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptString.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptString.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -23,6 +23,9 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
+
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:32 $
@@ -37,8 +40,15 @@
public abstract String toScript();
/**
- * Append JavaScript code to @link StringBuffer
- * @param functionString
+ * Append JavaScript code to @link {@link Appendable}
+ * @param target
+ * @throws IOException
*/
- public void appendScript(StringBuffer functionString);
+ public void appendScript(Appendable target) throws IOException;
+
+ /**
+ * Append JavaScript code to @link {@link StringBuilder}
+ * @param stringBuilder
+ */
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder);
}
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptStringBase.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptStringBase.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptStringBase.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -23,6 +23,11 @@
package org.ajax4jsf.javascript;
+import java.io.IOException;
+
+import javax.faces.FacesException;
+
+
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.2 $ $Date: 2007/01/26 10:38:52 $
@@ -30,13 +35,24 @@
*/
public abstract class ScriptStringBase implements ScriptString {
public String toScript() {
- StringBuffer functionString = new StringBuffer();
+ StringBuilder builder = new StringBuilder();
- appendScript(functionString);
+ try {
+ appendScript(builder);
+ return builder.toString();
+ } catch (IOException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
- return functionString.toString();
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
}
-
+
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
@@ -44,4 +60,5 @@
public String toString() {
return toScript();
}
+
}
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -26,8 +26,8 @@
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.io.Writer;
import java.lang.reflect.Array;
+import java.nio.CharBuffer;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
@@ -66,7 +66,7 @@
return cs;
}
- private static void writeScriptToStream(Writer writer, Object obj, Map<Object, Boolean> cycleBusterMap) throws IOException {
+ private static void appendScript(Appendable appendable, Object obj, Map<Object, Boolean> cycleBusterMap) throws IOException {
Boolean cycleBusterValue = cycleBusterMap.put(obj, Boolean.TRUE);
if (cycleBusterValue != null) {
@@ -81,14 +81,14 @@
LOG.debug(formattedMessage);
}
- writer.write("null");
+ appendable.append("null");
} else if (null == obj) {
//TODO nick - skip non-rendered values like Integer.MIN_VALUE
- writer.write("null");
+ appendable.append("null");
} else if (obj instanceof ScriptString) {
- writer.write(((ScriptString) obj).toScript());
+ ((ScriptString) obj).appendScript(appendable);
} else if (obj.getClass().isArray()) {
- writer.write("[");
+ appendable.append("[");
boolean first = true;
@@ -96,20 +96,20 @@
Object element = Array.get(obj, i);
if (!first) {
- writer.write(',');
+ appendable.append(',');
}
- writeScriptToStream(writer, element, cycleBusterMap);
+ appendScript(appendable, element, cycleBusterMap);
first = false;
}
- writer.write("] ");
+ appendable.append("] ");
} else if (obj instanceof Collection<?>) {
// Collections put as JavaScript array.
@SuppressWarnings("unchecked") Collection<Object> collection = (Collection<Object>) obj;
- writer.write("[");
+ appendable.append("[");
boolean first = true;
@@ -117,51 +117,51 @@
Object element = iter.next();
if (!first) {
- writer.write(',');
+ appendable.append(',');
}
- writeScriptToStream(writer, element, cycleBusterMap);
+ appendScript(appendable, element, cycleBusterMap);
first = false;
}
- writer.write("] ");
+ appendable.append("] ");
} else if (obj instanceof Map<?, ?>) {
// Maps put as JavaScript hash.
@SuppressWarnings("unchecked") Map<Object, Object> map = (Map<Object, Object>) obj;
- writer.write("{");
+ appendable.append("{");
boolean first = true;
for (Map.Entry<Object, Object> entry : map.entrySet()) {
if (!first) {
- writer.write(',');
+ appendable.append(',');
}
- writeEncodedString(writer, entry.getKey());
- writer.write(":");
- writeScriptToStream(writer, entry.getValue(), cycleBusterMap);
+ appendEncodedString(appendable, entry.getKey());
+ appendable.append(":");
+ appendScript(appendable, entry.getValue(), cycleBusterMap);
first = false;
}
- writer.write("} ");
+ appendable.append("} ");
} else if (obj instanceof Number || obj instanceof Boolean) {
// numbers and boolean put as-is, without conversion
- writer.write(obj.toString());
+ appendable.append(obj.toString());
} else if (obj instanceof String) {
// all other put as encoded strings.
- writeEncodedString(writer, obj);
+ appendEncodedString(appendable, obj);
} else if (obj instanceof Enum<?>) {
// all other put as encoded strings.
- writeEncodedString(writer, obj);
+ appendEncodedString(appendable, obj);
} else {
// All other objects threaded as Java Beans.
- writer.write("{");
+ appendable.append("{");
PropertyDescriptor[] propertyDescriptors;
@@ -194,16 +194,16 @@
}
if (!first) {
- writer.write(',');
+ appendable.append(',');
}
- writeEncodedString(writer, key);
- writer.write(":");
- writeScriptToStream(writer, propertyValue, cycleBusterMap);
+ appendEncodedString(appendable, key);
+ appendable.append(":");
+ appendScript(appendable, propertyValue, cycleBusterMap);
first = false;
}
- writer.write("} ");
+ appendable.append("} ");
}
if (cycleBusterValue == null) {
@@ -220,7 +220,7 @@
* @throws IOException
*/
public static void writeToStream(final ResponseWriter responseWriter, Object obj) throws IOException {
- writeScriptToStream(new ResponseWriterWrapper(responseWriter), obj, new IdentityHashMap<Object, Boolean>());
+ appendScript(new ResponseWriterWrapper(responseWriter), obj, new IdentityHashMap<Object, Boolean>());
}
/**
@@ -233,7 +233,7 @@
StringBuilder sb = new StringBuilder();
try {
- writeScriptToStream(new StringBuilderWriter(sb), obj, new IdentityHashMap<Object, Boolean>());
+ appendScript(sb, obj, new IdentityHashMap<Object, Boolean>());
} catch (IOException e) {
// ignore
@@ -242,22 +242,17 @@
return sb.toString();
}
- public static void writeEncodedString(Writer w, Object obj) throws IOException {
- w.write("\"");
- writeEncoded(w, obj);
- w.write("\"");
+ public static void appendScript(Appendable appendable, Object obj) throws IOException {
+ appendScript(appendable, obj, new IdentityHashMap<Object, Boolean>());
}
-
- public static void addEncodedString(StringBuilder buff, Object obj) {
- try {
- writeEncodedString(new StringBuilderWriter(buff), obj);
- } catch (IOException e) {
-
- // ignore
- }
+
+ public static void appendEncodedString(Appendable appendable, Object obj) throws IOException {
+ appendable.append("\"");
+ appendEncoded(appendable, obj);
+ appendable.append("\"");
}
- public static void writeEncoded(Writer w, Object obj) throws IOException {
+ public static void appendEncoded(Appendable appendable, Object obj) throws IOException {
JSEncoder encoder = new JSEncoder();
char[] chars = obj.toString().toCharArray();
@@ -265,22 +260,13 @@
char c = chars[i];
if (!encoder.compile(c)) {
- w.write(encoder.encode(c));
+ appendable.append(CharBuffer.wrap(encoder.encode(c)));
} else {
- w.write(c);
+ appendable.append(c);
}
}
}
- public static void addEncoded(StringBuilder buff, Object obj) {
- try {
- writeEncoded(new StringBuilderWriter(buff), obj);
- } catch (IOException e) {
-
- // ignore
- }
- }
-
public static String getValidJavascriptName(String s) {
StringBuffer buf = null;
final int len = s.length();
Modified: trunk/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java
===================================================================
--- trunk/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -246,21 +246,23 @@
/**
* Test method for {@link org.ajax4jsf.javascript.ScriptUtils#addEncodedString(java.lang.StringBuffer, java.lang.Object)}.
+ * @throws Exception
*/
- public void testAddEncodedString() {
+ public void testAddEncodedString() throws Exception {
StringBuilder buff = new StringBuilder();
- ScriptUtils.addEncodedString(buff, "foo");
+ ScriptUtils.appendEncodedString(buff, "foo");
assertEquals("\"foo\"", buff.toString());
}
/**
* Test method for {@link org.ajax4jsf.javascript.ScriptUtils#addEncoded(java.lang.StringBuffer, java.lang.Object)}.
+ * @throws Exception
*/
- public void testAddEncoded() {
+ public void testAddEncoded() throws Exception {
StringBuilder buff = new StringBuilder();
- ScriptUtils.addEncoded(buff, "foo");
+ ScriptUtils.appendEncoded(buff, "foo");
assertEquals("foo", buff.toString());
}
Modified: trunk/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -70,17 +70,31 @@
}
public String toScript() {
+ Map<String, Object> map = createScriptMap();
+
+ return ScriptUtils.toScript(map);
+ }
+
+ private Map<String, Object> createScriptMap() {
Map<String,Object> map = new HashMap<String, Object>(2);
map.put(TOPIC_KEY, topicKey.getTopicAddress());
map.put(DATA_KEY, new JSLiteral(serializedData));
-
- return ScriptUtils.toScript(map);
+ return map;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(toScript());
+ public void appendScript(Appendable target) throws IOException {
+ target.append(toScript());
}
+
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+
}
private static final class FlushMessagesTask implements Runnable {
Modified: trunk/core/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/core/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -21,16 +21,18 @@
package org.richfaces.renderkit;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.ScriptStringBase;
-import org.ajax4jsf.javascript.ScriptUtils;
-
-import javax.faces.component.UIComponent;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.ScriptStringBase;
+import org.ajax4jsf.javascript.ScriptUtils;
+
/**
* @author Maksim Kaszynski
*/
@@ -42,8 +44,8 @@
this.component = component;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(ScriptUtils.toScript(opts));
+ public void appendScript(Appendable target) throws IOException {
+ ScriptUtils.appendScript(target, opts);
}
public void addOption(String name) {
Modified: trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18 16:54:07 UTC (rev 20103)
@@ -3,7 +3,8 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:it="http://richfaces.org/iteration">
+ xmlns:it="http://richfaces.org/iteration"
+ xmlns:a4j="http://richfaces.org/a4j">
<f:view contentType="text/html" />
<h:head>
@@ -45,6 +46,7 @@
</h:form>
<h:form id="form">
+ Base tree:
<it:tree id="tree" nodeType="#{node.parent == null ? 'rootNode': 'childNode'}" var="node" value="#{treeBean.rootNodes}"
selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}" selection="#{treeBean.selection}">
<it:treeNode type="rootNode">
@@ -73,6 +75,7 @@
<f:ajax render=":form:tree" execute="@all" />
</h:commandLink>
+ Tree with customized look:
<it:tree id="customizedTree" var="node" value="#{treeBean.rootNodes}"
selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}"
styleClass="#{treeBean.showCustomClasses ? 'customClass' : ''}">
@@ -83,9 +86,22 @@
</it:treeNode>
</it:tree>
+ Tree with default node:
<it:tree id="defaultNodeTree" var="node" value="#{treeBean.rootNodes}"
selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
</it:tree>
+
+ Tree with client-side event handlers:
+ <it:tree id="clientSideEventsTree" var="node" value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
+
+ <it:treeNode ontoggle="RichFaces.log.info('Toggle event: target is - ' + event.target.id)"
+ onselect="RichFaces.log.info('Select event: target is - ' + event.target.id)">
+ #{node.data}
+ </it:treeNode>
+ </it:tree>
+
+ <a4j:log />
</h:form>
</h:body>
</html>
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-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxEventOptions.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -21,6 +21,7 @@
package org.richfaces.renderkit;
+import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -40,8 +41,8 @@
private Map<String, Object> options = new HashMap<String, Object>();
- public void appendScript(StringBuffer functionString) {
- functionString.append(ScriptUtils.toScript(options));
+ public void appendScript(Appendable target) throws IOException {
+ ScriptUtils.appendScript(target, options);
}
public boolean isEmpty() {
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -382,6 +382,7 @@
}
}
+ //TODO - create special method for event handlers that will return String?
public static Object getAttributeAndBehaviorsValue(FacesContext facesContext, UIComponent component,
ComponentAttribute componentAttribute) {
if (facesContext == null) {
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -23,19 +23,20 @@
package org.richfaces.renderkit;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.renderkit.util.AjaxRendererUtils;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIParameter;
-import javax.faces.context.FacesContext;
-import java.util.Iterator;
-import java.util.Map;
-
/**
* @author shura
*
@@ -48,7 +49,7 @@
throw new FacesException("Value of 'name' attribute of a4j:jsFunction component is null!");
}
- StringBuffer script = new StringBuffer(functionName).append("=");
+ StringBuilder script = new StringBuilder(functionName).append("=");
JSFunctionDefinition func = new JSFunctionDefinition();
// func.setName(component.getName());
@@ -94,7 +95,7 @@
// TODO - added in 4.0 - ?
func.addParameter(JSReference.EVENT);
func.addToBody(ajaxFunction.toScript());
- func.appendScript(script);
+ func.appendScriptToStringBuilder(script);
return script.toString();
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/ClientSelectItem.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/ClientSelectItem.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/ClientSelectItem.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -22,6 +22,8 @@
package org.richfaces.renderkit;
+import java.io.IOException;
+
import org.ajax4jsf.javascript.ScriptString;
import org.ajax4jsf.javascript.ScriptUtils;
@@ -59,14 +61,23 @@
return convertedValue;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(this.toScript());
+ public void appendScript(Appendable target) throws IOException {
+ target.append(this.toScript());
}
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+
public String toScript() {
return "{ 'id' : " + ScriptUtils.toScript(clientId)
+ " , 'label' : " + ScriptUtils.toScript(label)
+ ", 'value' : " + ScriptUtils.toScript(convertedValue)
+ "}";
}
+
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -69,7 +69,8 @@
type = AbstractTree.COMPONENT_TYPE,
family = AbstractTree.COMPONENT_FAMILY,
tag = @Tag(name = "tree"),
- renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer")
+ renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer"),
+ attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"}
)
public abstract class AbstractTree extends UIDataAdaptor implements MetaComponentResolver, MetaComponentEncoder {
@@ -133,11 +134,6 @@
public abstract boolean isImmediate();
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
@Attribute(defaultValue = "SwitchType.DEFAULT")
public abstract SwitchType getToggleType();
@@ -146,8 +142,10 @@
public abstract String getNodeType();
- //TODO - move to template
- public abstract String getStyleClass();
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
public Collection<Object> getSelection() {
@SuppressWarnings("unchecked")
@@ -209,7 +207,6 @@
}
if (Strings.isNullOrEmpty(nodeType)) {
- //make PSS happy
if (getAttributes().put(DEFAULT_TREE_NODE_CREATED, Boolean.TRUE) != null) {
return null;
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -45,6 +45,7 @@
import org.richfaces.application.ServiceTracker;
import org.richfaces.appplication.FacesMessages;
import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
@@ -63,7 +64,8 @@
type = AbstractTreeNode.COMPONENT_TYPE,
family = AbstractTreeNode.COMPONENT_FAMILY,
tag = @Tag(name = "treeNode"),
- renderer = @JsfRenderer(type = "org.richfaces.TreeNodeRenderer")
+ renderer = @JsfRenderer(type = "org.richfaces.TreeNodeRenderer"),
+ attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"}
)
public abstract class AbstractTreeNode extends UIComponentBase implements MetaComponentResolver, MetaComponentEncoder, IterationStateHolder {
@@ -91,9 +93,6 @@
public abstract String getType();
- //TODO - move to template
- public abstract String getStyleClass();
-
public abstract String getIconLeaf();
public abstract String getIconExpanded();
@@ -106,6 +105,9 @@
public abstract String getLabelClass();
+ @Attribute(events = @EventName("toggle"))
+ public abstract String getOntoggle();
+
protected Boolean getLocalExpandedValue(FacesContext facesContext) {
return (Boolean) getStateHelper().get(PropertyKeys.expanded);
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -321,9 +321,9 @@
function.addParameter(options);
- StringBuffer buffer = new StringBuffer();
- function.appendScript(buffer);
- definition.addToBody(buffer);
+ StringBuilder sb = new StringBuilder();
+ function.appendScriptToStringBuilder(sb);
+ definition.addToBody(sb);
return definition;
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderPartial.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -60,7 +60,8 @@
Object initialRowKey = tree.getRowKey();
try {
-
+ TreeRenderingContext.create(context, tree);
+
encodeTreeNode(rowKey, true);
prw.endUpdate();
@@ -71,6 +72,8 @@
} catch (Exception e) {
TreeRendererBase.LOGGER.error(e.getMessage(), e);
}
+
+ TreeRenderingContext.delete(context);
}
prw.startEval();
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -46,6 +46,10 @@
private static final String TRIGGER_NODE_AJAX_UPDATE = "__TRIGGER_NODE_AJAX_UPDATE";
+ private static final ComponentAttribute ONTOGGLE_ATTRIBUTE = new ComponentAttribute("ontoggle").setEventNames("toggle");
+
+ private static final ComponentAttribute ONSELECT_ATTRIBUTE = new ComponentAttribute("onselect").setEventNames("select");
+
@Override
public void decode(FacesContext context, UIComponent component) {
super.decode(context, component);
@@ -144,4 +148,11 @@
encodeCustomIcon(context, treeNode, nodeState.getCustomIconClass(), customIcon);
}
}
+
+ protected void addEventHandlersToRenderingContext(FacesContext facesContext, UIComponent component) {
+ String ontoggle = (String) RenderKitUtils.getAttributeAndBehaviorsValue(facesContext, component, ONTOGGLE_ATTRIBUTE);
+ String onselect = (String) RenderKitUtils.getAttributeAndBehaviorsValue(facesContext, component, ONSELECT_ATTRIBUTE);
+
+ TreeRenderingContext.get(facesContext).addHandlers(ontoggle, null, onselect, null);
+ }
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -271,4 +271,17 @@
+ AbstractTree.SELECTION_META_COMPONENT_ID);
}
}
+
+ protected void createTreeRenderingContext(FacesContext context, UIComponent component) {
+ TreeRenderingContext.create(context, (AbstractTree) component);
+ }
+
+ protected Object getClientEventHandlers(FacesContext facesContext) {
+ TreeRenderingContext treeRenderingContext = TreeRenderingContext.get(facesContext);
+ return treeRenderingContext.getHandlers();
+ }
+
+ protected void deleteTreeRenderingContext(FacesContext context) {
+ TreeRenderingContext.delete(context);
+ }
}
Added: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRenderingContext.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.ScriptStringBase;
+import org.richfaces.component.AbstractTree;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class TreeRenderingContext {
+
+ private static final String ATTRIBUTE_NAME = TreeRenderingContext.class.getName() + ":ATTRIBUTE_NAME";
+
+ public static final class Handlers extends ScriptStringBase {
+
+ private String toggleHandler;
+
+ private String treeToggleHandler;
+
+ private String selectHandler;
+
+ private String treeSelectHandler;
+
+ public void setSelectHandler(String selectHandler) {
+ this.selectHandler = selectHandler;
+ }
+
+ public String getSelectHandler() {
+ return selectHandler;
+ }
+
+ public void setToggleHandler(String toggleHandler) {
+ this.toggleHandler = toggleHandler;
+ }
+
+ public String getToggleHandler() {
+ return toggleHandler;
+ }
+
+ public String getTreeToggleHandler() {
+ return treeToggleHandler;
+ }
+
+ public void setTreeToggleHandler(String treeToggleHandler) {
+ this.treeToggleHandler = treeToggleHandler;
+ }
+
+ public String getTreeSelectHandler() {
+ return treeSelectHandler;
+ }
+
+ public void setTreeSelectHandler(String treeSelectHandler) {
+ this.treeSelectHandler = treeSelectHandler;
+ }
+
+ public void appendScript(Appendable target) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+ }
+
+ private FacesContext context;
+
+ private AbstractTree tree;
+
+ private String baseClientId;
+
+ private Map<String, Handlers> handlersMap = new HashMap<String, Handlers>();
+
+ private TreeRenderingContext(FacesContext context, AbstractTree tree) {
+ super();
+ this.context = context;
+ this.tree = tree;
+ this.baseClientId = tree.getClientId(context);
+ }
+
+ public static TreeRenderingContext create(FacesContext context, AbstractTree tree) {
+ TreeRenderingContext renderingContext = new TreeRenderingContext(context, tree);
+ context.getAttributes().put(ATTRIBUTE_NAME, renderingContext);
+ return renderingContext;
+ }
+
+ public static TreeRenderingContext get(FacesContext context) {
+ return (TreeRenderingContext) context.getAttributes().get(ATTRIBUTE_NAME);
+ }
+
+ public static void delete(FacesContext context) {
+ context.getAttributes().remove(ATTRIBUTE_NAME);
+ }
+
+ public void addHandlers(String toggleHandler, String treeToggleHandler, String selectHandler, String treeSelectHandler) {
+ String clientId = tree.findTreeNodeComponent().getClientId(context);
+
+ String relativeClientId = clientId.substring(baseClientId.length());
+
+ if (isNullOrEmpty(toggleHandler) && isNullOrEmpty(treeToggleHandler)
+ && isNullOrEmpty(selectHandler) && isNullOrEmpty(treeSelectHandler)) {
+
+ return;
+ }
+
+ Handlers handlers = new Handlers();
+ handlers.setToggleHandler(toggleHandler);
+ handlers.setTreeToggleHandler(treeToggleHandler);
+ handlers.setSelectHandler(selectHandler);
+ handlers.setTreeSelectHandler(treeSelectHandler);
+
+ handlersMap.put(relativeClientId, handlers);
+ }
+
+ public Object getHandlers() {
+ return handlersMap;
+ }
+}
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:54:07 UTC (rev 20103)
@@ -39,12 +39,14 @@
name: "TreeNode",
- init: function (id) {
+ init: function (id, commonOptions) {
this.__rootElt = $(this.attachToDom(id));
this.__children = new Array();
- this.__initializeChildren();
+ this.__initializeChildren(commonOptions);
+
+ this.__clientEventHandlers = (commonOptions.clientEventHandlers || {})[commonOptions.treeId + id];
},
destroy: function() {
@@ -60,10 +62,10 @@
this.__rootElt = null;
},
- __initializeChildren: function() {
+ __initializeChildren: function(commonOptions) {
var _this = this;
this.__rootElt.children(".rf-tr-nd").each(function() {
- _this.addChild(new richfaces.ui.TreeNode(this));
+ _this.addChild(new richfaces.ui.TreeNode(this, commonOptions));
});
},
@@ -216,7 +218,7 @@
});
- richfaces.ui.TreeNode.initNodeByAjax = function(nodeId) {
+ richfaces.ui.TreeNode.initNodeByAjax = function(nodeId, commonOptions) {
var node = $(document.getElementById(nodeId));
if (node.nextAll(".rf-tr-nd:first").length != 0) {
@@ -228,7 +230,7 @@
var idx = node.prevAll(".rf-tr-nd").length;
var parentNode = richfaces.$(parent[0]);
- var newChild = new richfaces.ui.TreeNode(node[0]);
+ var newChild = new richfaces.ui.TreeNode(node[0], commonOptions);
parentNode.addChild(newChild, idx);
parentNode.getTree().__updateSelection();
};
@@ -252,8 +254,12 @@
init: function (id, options) {
this.__treeRootElt = $(richfaces.getDomElement(id));
- this.$super.init.call(this, this.__treeRootElt);
+ var commonOptions = {};
+ commonOptions.clientEventHandlers = options.clientEventHandlers || {};
+ commonOptions.treeId = id;
+ this.$super.init.call(this, this.__treeRootElt, commonOptions);
+
this.__toggleType = options.toggleType || 'ajax';
this.__selectionType = options.selectionType || 'client';
Modified: trunk/ui/iteration/ui/src/main/templates/tree.template.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/templates/tree.template.xml 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/iteration/ui/src/main/templates/tree.template.xml 2010-11-18 16:54:07 UTC (rev 20103)
@@ -16,16 +16,26 @@
<cdk:resource-dependency name="tree.js" library="org.richfaces" />
<cdk:resource-dependency name="tree.ecss" library="org.richfaces" />
+ <cdk:import-attributes src="urn:attributes:events-props.xml"/>
+ <cdk:import-attributes src="urn:attributes:core-props.xml"/>
+ <cdk:import-attributes src="urn:attributes:i18n-props.xml"/>
+
<cdk:import package="org.richfaces.component" names="SwitchType" />
</cc:interface>
<cc:implementation>
<div id="#{clientId}" class="#{concatClasses('rf-tr', component.attributes['styleClass'])}"
cdk:passThroughWithExclusions="">
+
+ <cdk:call expression="createTreeRenderingContext(facesContext, component)" />
+
<cdk:body>
<cdk:call expression="encodeTree(facesContext, component)" />
</cdk:body>
+ <cdk:object name="clientEventHandlers" value="#{getClientEventHandlers(facesContext)}" />
+ <cdk:call expression="deleteTreeRenderingContext(facesContext)" />
+
<cdk:call expression="encodeSelectionStateInput(facesContext, component)" />
<script type="text/javascript">
@@ -33,6 +43,7 @@
<cdk:scriptOption attributes="toggleType" defaultValue="SwitchType.DEFAULT" />
<cdk:scriptOption name="selectionType" value="#{getSelectionMode(facesContext, component)}" defaultValue="SwitchType.client" />
<cdk:scriptOption name="ajaxSubmitFunction" value="#{getAjaxSubmitFunction(facesContext, component)}" />
+ <cdk:scriptOption variables="clientEventHandlers" />
</cdk:scriptObject>
new RichFaces.ui.Tree(#{toScriptArgs(clientId, options)});
Modified: trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-11-18 16:54:07 UTC (rev 20103)
@@ -13,6 +13,10 @@
</cdk:component-family>
<cdk:renderer-type>org.richfaces.TreeNodeRenderer
</cdk:renderer-type>
+
+ <cdk:import-attributes src="urn:attributes:events-props.xml"/>
+ <cdk:import-attributes src="urn:attributes:core-props.xml"/>
+ <cdk:import-attributes src="urn:attributes:i18n-props.xml"/>
</cc:interface>
<cc:implementation>
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -206,7 +206,7 @@
addToScriptHash(options, "onbeforeshow", buildEventFunction(attributes.get("onbeforeshow")));
addToScriptHash(options, "onbeforehide", buildEventFunction(attributes.get("onbeforehide")));
- result.append(ScriptUtils.toScript(options));
+ ScriptUtils.appendScript(result, options);
result.append(");");
return result.toString();
}
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -36,35 +36,35 @@
@Override
protected Object buildBody() {
- StringBuffer body = new StringBuffer();
+ StringBuilder body = new StringBuilder();
// Get component value by clientId.
body.append("var ").append(ClientValidatorRenderer.VALUE_VAR).append("=");
- GET_VALUE_FUNCTION.appendScript(body);
+ GET_VALUE_FUNCTION.appendScriptToStringBuilder(body);
body.append(EOL);
// Try client-side validation
body.append("try {\n");
// convert value
body.append("var ").append(ClientValidatorRenderer.CONVERTED_VALUE_VAR).append("=");
- converter.appendScript(body);
+ converter.appendScriptToStringBuilder(body);
body.append(EOL);
// call validators
for (LibraryScriptString validatorScript : validators) {
- validatorScript.appendScript(body);
+ validatorScript.appendScriptToStringBuilder(body);
body.append(EOL);
}
finishValidation(body);
body.append("return true;\n");
// Catch errors
body.append("} catch(e) {\n");
- SEND_ERROR_FUNCTION.appendScript(body);body.append(EOL);
+ SEND_ERROR_FUNCTION.appendScriptToStringBuilder(body);body.append(EOL);
body.append("return false;\n}");
return body;
}
- protected void finishValidation(StringBuffer body) {
+ protected void finishValidation(StringBuilder body) {
// clear messages after successful validation
body.append("if(!").append(DISABLE_AJAX).append("){\n");
- CLEAR_ERROR_FUNCTION.appendScript(body);
+ CLEAR_ERROR_FUNCTION.appendScriptToStringBuilder(body);
body.append(EOL).append("}\n");
}
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -1,5 +1,7 @@
package org.richfaces.renderkit.html;
+import java.io.IOException;
+
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSLiteral;
@@ -29,13 +31,13 @@
super(CLIENT_ID,ELEMENT,EVENT,DISABLE_AJAX);
}
- public void appendScript(StringBuffer functionString) {
+ public void appendScript(Appendable target) throws IOException {
if(!bodyProcessed){
// pending RF-9565
addToBody(buildBody());
bodyProcessed = true;
}
- super.appendScript(functionString);
+ super.appendScript(target);
}
protected abstract Object buildBody();
Modified: trunk/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -3,6 +3,7 @@
*/
package org.richfaces.component;
+import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
@@ -36,10 +37,18 @@
return TEST_SCRIPT;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(TEST_SCRIPT);
+ public void appendScript(Appendable target) throws IOException {
+ target.append(TEST_SCRIPT);
}
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+
public Collection<LibraryResource> getResources() {
return Collections.singleton(TEST_RESOURCE);
}
@@ -51,6 +60,7 @@
public String createCallScript(String clientId,String sourceId) {
return FOO+"("+clientId+")";
}
+
};
private String value=FOO_VALUE;
Modified: trunk/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-18 16:37:36 UTC (rev 20102)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-18 16:54:07 UTC (rev 20103)
@@ -1,5 +1,7 @@
package org.richfaces.component;
+import java.io.IOException;
+
import org.richfaces.validator.LibraryResource;
import org.richfaces.validator.LibraryScriptString;
@@ -14,11 +16,18 @@
return name;
}
- public void appendScript(StringBuffer functionString) {
- functionString.append(name);
-
+ public void appendScript(Appendable target) throws IOException {
+ target.append(name);
}
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+
public LibraryResource getResource() {
return UIValidatorScriptCollectionTest.FOO_RESOURCE;
}
14 years, 2 months
JBoss Rich Faces SVN: r20102 - in trunk/core/api/src: test/java/org/ajax4jsf/javascript and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 11:37:36 -0500 (Thu, 18 Nov 2010)
New Revision: 20102
Removed:
trunk/core/api/src/main/java/org/ajax4jsf/javascript/StringBuilderWriter.java
trunk/core/api/src/test/java/org/ajax4jsf/javascript/StringBuilderWriterTest.java
Log:
RF-9714
Deleted: trunk/core/api/src/main/java/org/ajax4jsf/javascript/StringBuilderWriter.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/StringBuilderWriter.java 2010-11-18 16:35:18 UTC (rev 20101)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/StringBuilderWriter.java 2010-11-18 16:37:36 UTC (rev 20102)
@@ -1,88 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.javascript;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.2
- */
-final class StringBuilderWriter extends Writer {
- private StringBuilder builder;
-
- public StringBuilderWriter(StringBuilder builder) {
- super();
- this.builder = builder;
- }
-
- /**
- * Closing this writer doesn't have any effect
- */
- @Override
- public void close() throws IOException {
-
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.Writer#flush()
- */
- @Override
- public void flush() throws IOException {
-
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.Writer#write(char[], int, int)
- */
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- builder.append(cbuf, off, len);
- }
-
- @Override
- public void write(char[] cbuf) throws IOException {
- builder.append(cbuf);
- }
-
- @Override
- public void write(String str) throws IOException {
- builder.append(str);
- }
-
- @Override
- public void write(String str, int off, int len) throws IOException {
- builder.append(str, off, off + len);
- }
-
- @Override
- public void write(int c) throws IOException {
- builder.append((char) c);
- }
-}
Deleted: trunk/core/api/src/test/java/org/ajax4jsf/javascript/StringBuilderWriterTest.java
===================================================================
--- trunk/core/api/src/test/java/org/ajax4jsf/javascript/StringBuilderWriterTest.java 2010-11-18 16:35:18 UTC (rev 20101)
+++ trunk/core/api/src/test/java/org/ajax4jsf/javascript/StringBuilderWriterTest.java 2010-11-18 16:37:36 UTC (rev 20102)
@@ -1,96 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.javascript;
-
-import java.io.Writer;
-
-import junit.framework.TestCase;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.2
- */
-public class StringBuilderWriterTest extends TestCase {
- private StringBuilder builder;
- private Writer writer;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.builder = new StringBuilder();
- this.writer = new StringBuilderWriter(this.builder);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- this.builder = null;
- this.writer = null;
- }
-
- public void testWrite() throws Exception {
- writer.write(new char[] {'a', 'b'});
- assertEquals("ab", builder.toString());
- }
-
- public void testWrite2() throws Exception {
- writer.write(0x12345678);
-
- String s = builder.toString();
-
- assertEquals(1, s.length());
- assertEquals(0x5678, s.charAt(0));
- }
-
- public void testWrite3() throws Exception {
- writer.write("test");
- assertEquals("test", builder.toString());
- }
-
- public void testWrite4() throws Exception {
- writer.write("abcd".toCharArray(), 1, 2);
- assertEquals("bc", builder.toString());
- writer.write("efgh".toCharArray(), 0, 3);
- assertEquals("bcefg", builder.toString());
- writer.write("ijkl".toCharArray(), 2, 2);
- assertEquals("bcefgkl", builder.toString());
- }
-
- public void testWrite5() throws Exception {
- writer.write("abcd", 1, 2);
- assertEquals("bc", builder.toString());
- writer.write("efgh", 0, 3);
- assertEquals("bcefg", builder.toString());
- writer.write("ijklm", 2, 3);
- assertEquals("bcefgklm", builder.toString());
- }
-
- public void testFlush() throws Exception {
- writer.flush();
- }
-
- public void testClose() throws Exception {
- writer.close();
- }
-}
14 years, 2 months
JBoss Rich Faces SVN: r20101 - trunk/ui/iteration/ui/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 11:35:18 -0500 (Thu, 18 Nov 2010)
New Revision: 20101
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
Log:
Checkstyle error fixed
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18 16:33:28 UTC (rev 20100)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18 16:35:18 UTC (rev 20101)
@@ -51,8 +51,6 @@
import org.richfaces.convert.SequenceRowKeyConverter;
import org.richfaces.event.TreeSelectionEvent;
import org.richfaces.event.TreeSelectionListener;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
import org.richfaces.model.ExtendedTreeDataModelImpl;
import org.richfaces.model.SwingTreeNodeDataModelImpl;
import org.richfaces.model.TreeDataModel;
14 years, 2 months
JBoss Rich Faces SVN: r20100 - trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 11:33:28 -0500 (Thu, 18 Nov 2010)
New Revision: 20100
Modified:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
Log:
https://jira.jboss.org/browse/RF-9715
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:31:41 UTC (rev 20099)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:33:28 UTC (rev 20100)
@@ -67,8 +67,8 @@
});
},
- __getHandles: function() {
- return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd");
+ __getHandle: function() {
+ return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd:first");
},
__getContent: function() {
@@ -163,19 +163,11 @@
switch (tree.getToggleType()) {
case 'client':
this.__rootElt.addClass(TREE_CLASSES[newState ? 1 : 0]).removeClass(TREE_CLASSES[!newState ? 1 : 0]);
-<<<<<<< HEAD
this.__getHandle().addClass(TREE_HANDLE_CLASSES[newState ? 1 : 0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
var icons = this.__getIcons();
if (icons.length == 1) {
icons.addClass(TREE_ICON_CLASSES[newState ? 1 : 0]).removeClass(TREE_ICON_CLASSES[!newState ? 1 : 0]);
-=======
-
- var handles = this.__getHandles();
-
- if (handles.length == 1) {
- handles.addClass(TREE_HANDLE_CLASSES[newState ? 1 : 0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
->>>>>>> https://jira.jboss.org/browse/RF-9715
}
this.__updateClientToggleStateInput(newState);
14 years, 2 months
JBoss Rich Faces SVN: r20099 - in trunk/ui: output/ui/src/main/java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 11:31:41 -0500 (Thu, 18 Nov 2010)
New Revision: 20099
Removed:
trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java
Modified:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
Log:
https://jira.jboss.org/browse/RF-9715
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:28:44 UTC (rev 20098)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:31:41 UTC (rev 20099)
@@ -67,8 +67,8 @@
});
},
- __getHandle: function() {
- return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd:first");
+ __getHandles: function() {
+ return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd");
},
__getContent: function() {
@@ -163,11 +163,19 @@
switch (tree.getToggleType()) {
case 'client':
this.__rootElt.addClass(TREE_CLASSES[newState ? 1 : 0]).removeClass(TREE_CLASSES[!newState ? 1 : 0]);
+<<<<<<< HEAD
this.__getHandle().addClass(TREE_HANDLE_CLASSES[newState ? 1 : 0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
var icons = this.__getIcons();
if (icons.length == 1) {
icons.addClass(TREE_ICON_CLASSES[newState ? 1 : 0]).removeClass(TREE_ICON_CLASSES[!newState ? 1 : 0]);
+=======
+
+ var handles = this.__getHandles();
+
+ if (handles.length == 1) {
+ handles.addClass(TREE_HANDLE_CLASSES[newState ? 1 : 0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
+>>>>>>> https://jira.jboss.org/browse/RF-9715
}
this.__updateClientToggleStateInput(newState);
Deleted: trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java 2010-11-18 16:28:44 UTC (rev 20098)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanel.java 2010-11-18 16:31:41 UTC (rev 20099)
@@ -1,49 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.faces.component.UIComponentBase;
-
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.cdk.annotations.TagType;
-
-/**
- * JSF component class
- *
- */
-@JsfComponent(tag = @Tag(type = TagType.Facelets),
- renderer = @JsfRenderer(type = "org.richfaces.PanelRenderer")
- )
-public class UIPanel extends UIComponentBase {
- private static final String COMPONENT_FAMILY = "org.richfaces.Panel";
-
- public boolean getRendersChildren() {
- return true;
- }
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-}
14 years, 2 months
JBoss Rich Faces SVN: r20098 - trunk/ui/iteration/ui/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 11:28:44 -0500 (Thu, 18 Nov 2010)
New Revision: 20098
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
Log:
https://jira.jboss.org/browse/RF-9716
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18 16:26:56 UTC (rev 20097)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-18 16:28:44 UTC (rev 20098)
@@ -51,6 +51,8 @@
import org.richfaces.convert.SequenceRowKeyConverter;
import org.richfaces.event.TreeSelectionEvent;
import org.richfaces.event.TreeSelectionListener;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
import org.richfaces.model.ExtendedTreeDataModelImpl;
import org.richfaces.model.SwingTreeNodeDataModelImpl;
import org.richfaces.model.TreeDataModel;
14 years, 2 months
JBoss Rich Faces SVN: r20097 - in trunk: ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 11:26:56 -0500 (Thu, 18 Nov 2010)
New Revision: 20097
Modified:
trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
Log:
https://jira.jboss.org/browse/RF-9715
Modified: trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18 16:24:23 UTC (rev 20096)
+++ trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18 16:26:56 UTC (rev 20097)
@@ -74,27 +74,18 @@
</h:commandLink>
<it:tree id="customizedTree" var="node" value="#{treeBean.rootNodes}"
-<<<<<<< HEAD
selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}"
styleClass="#{treeBean.showCustomClasses ? 'customClass' : ''}">
<it:treeNode iconLeaf="/images/leaf.png" iconExpanded="/images/minus.png" iconCollapsed="/images/plus.png"
styleClass="customNodeClass" handleClass="customHandleClass" iconClass="customIconClass" labelClass="customLabelClass">
-=======
- selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
-
- <it:treeNode iconLeaf="/images/leaf.png" iconExpanded="/images/minus.png" iconCollapsed="/images/plus.png">
->>>>>>> https://jira.jboss.org/browse/RF-9715
#{node.data}
</it:treeNode>
</it:tree>
-<<<<<<< HEAD
<it:tree id="defaultNodeTree" var="node" value="#{treeBean.rootNodes}"
selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
</it:tree>
-=======
->>>>>>> https://jira.jboss.org/browse/RF-9715
</h:form>
</h:body>
</html>
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:24:23 UTC (rev 20096)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:26:56 UTC (rev 20097)
@@ -67,8 +67,8 @@
});
},
- __getHandles: function() {
- return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd");
+ __getHandle: function() {
+ return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd:first");
},
__getContent: function() {
14 years, 2 months
JBoss Rich Faces SVN: r20096 - in trunk: ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-18 11:24:23 -0500 (Thu, 18 Nov 2010)
New Revision: 20096
Modified:
trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
Log:
https://jira.jboss.org/browse/RF-9715
Modified: trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18 16:21:47 UTC (rev 20095)
+++ trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-18 16:24:23 UTC (rev 20096)
@@ -74,18 +74,27 @@
</h:commandLink>
<it:tree id="customizedTree" var="node" value="#{treeBean.rootNodes}"
+<<<<<<< HEAD
selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}"
styleClass="#{treeBean.showCustomClasses ? 'customClass' : ''}">
<it:treeNode iconLeaf="/images/leaf.png" iconExpanded="/images/minus.png" iconCollapsed="/images/plus.png"
styleClass="customNodeClass" handleClass="customHandleClass" iconClass="customIconClass" labelClass="customLabelClass">
+=======
+ selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
+
+ <it:treeNode iconLeaf="/images/leaf.png" iconExpanded="/images/minus.png" iconCollapsed="/images/plus.png">
+>>>>>>> https://jira.jboss.org/browse/RF-9715
#{node.data}
</it:treeNode>
</it:tree>
+<<<<<<< HEAD
<it:tree id="defaultNodeTree" var="node" value="#{treeBean.rootNodes}"
selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
</it:tree>
+=======
+>>>>>>> https://jira.jboss.org/browse/RF-9715
</h:form>
</h:body>
</html>
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:21:47 UTC (rev 20095)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-18 16:24:23 UTC (rev 20096)
@@ -67,8 +67,8 @@
});
},
- __getHandle: function() {
- return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd:first");
+ __getHandles: function() {
+ return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd");
},
__getContent: function() {
14 years, 2 months