Author: nbelaevski
Date: 2010-12-03 15:34:04 -0500 (Fri, 03 Dec 2010)
New Revision: 20388
Added:
trunk/examples/iteration-demo/src/main/webapp/images/loading.gif
Modified:
trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
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/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.ecss
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml
Log:
https://jira.jboss.org/browse/RF-9838
- IE7:
-- visual fixes
-- selection was not submitted correctly
- Improved trees & queues compatibility
- Default treeNode was not working
Added: trunk/examples/iteration-demo/src/main/webapp/images/loading.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/iteration-demo/src/main/webapp/images/loading.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-12-03 20:09:51 UTC (rev
20387)
+++ trunk/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-12-03 20:34:04 UTC (rev
20388)
@@ -27,6 +27,11 @@
border: 1px solid green;
}
+ .loadingWithoutFacet .rf-trn-ldn .rf-trn-hnd {
+ cursor: default;
+ background-image:
url(#{facesContext.externalContext.requestContextPath}/images/loading.gif);
+ }
+
/*]]>*/</h:outputStylesheet>
</h:head>
@@ -244,6 +249,22 @@
</h:panelGroup>
</h:panelGrid>
+ 'loading' facet:
+ <it:tree value="#{treeBean.rootNodes}" toggleType="ajax"
var="node">
+ <it:treeNode>
+ <f:facet name="loading">
+ <h:graphicImage value="/images/loading.gif" />
+ </f:facet>
+
+ #{node}
+ </it:treeNode>
+ </it:tree>
+
+ 'loading' without facet:
+ <it:tree value="#{treeBean.rootNodes}" toggleType="ajax"
var="node" styleClass="loadingWithoutFacet" />
+
+ <a4j:queue />
+
<a4j:log />
</h:form>
</h:body>
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-12-03
20:09:51 UTC (rev 20387)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-03
20:34:04 UTC (rev 20388)
@@ -256,10 +256,6 @@
}
public AbstractTreeNode findTreeNodeComponent() {
- if (getRowKey() == null) {
- return null;
- }
-
FacesContext facesContext = getFacesContext();
String nodeType = getNodeType();
@@ -280,6 +276,7 @@
return null;
}
+ //TODO default TreeNode is created when getRowKey() == null but it's not
used for presentational purposes
Application application = facesContext.getApplication();
AbstractTreeNode treeNode = (AbstractTreeNode)
application.createComponent(AbstractTreeNode.COMPONENT_TYPE);
treeNode.setId("__defaultTreeNode");
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-12-03
20:09:51 UTC (rev 20387)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-12-03
20:34:04 UTC (rev 20388)
@@ -162,8 +162,7 @@
writeTreeNodeEndElement();
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new FacesException(e.getMessage(), e);
}
}
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-12-03
20:09:51 UTC (rev 20387)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-12-03
20:34:04 UTC (rev 20388)
@@ -53,6 +53,8 @@
private static final String TRIGGER_NODE_AJAX_UPDATE =
"__TRIGGER_NODE_AJAX_UPDATE";
+ private static final String LOADING_FACET_NAME = "loading";
+
@Override
public void decode(FacesContext context, UIComponent component) {
super.decode(context, component);
@@ -168,4 +170,21 @@
TreeRenderingContext renderingContext = TreeRenderingContext.get(facesContext);
renderingContext.addHandlers(treeNode);
}
+
+ protected UIComponent getLoadingFacetIfApplicable(UIComponent component) {
+ AbstractTreeNode treeNode = (AbstractTreeNode) component;
+
+ AbstractTree tree = treeNode.findTreeComponent();
+
+ if (tree.getToggleType() != SwitchType.ajax) {
+ return null;
+ }
+
+ UIComponent facet = treeNode.getFacet(LOADING_FACET_NAME);
+ if (facet == null) {
+ facet = tree.getFacet(LOADING_FACET_NAME);
+ }
+
+ return facet;
+ }
}
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-12-03
20:09:51 UTC (rev 20387)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-12-03
20:34:04 UTC (rev 20388)
@@ -23,7 +23,6 @@
import static org.richfaces.component.AbstractTree.SELECTION_META_COMPONENT_ID;
import static org.richfaces.renderkit.util.AjaxRendererUtils.AJAX_FUNCTION_NAME;
-import static org.richfaces.renderkit.util.AjaxRendererUtils.buildAjaxFunction;
import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
import java.io.IOException;
@@ -66,8 +65,11 @@
private static final JSReference SOURCE_JS_REF = new
JSReference("source");
+ private static final JSReference COMPLETE_JS_REF = new
JSReference("complete");
+
private static final String SELECTION_STATE = "__SELECTION_STATE";
+
/**
* @author Nick Belaevski
*
@@ -98,10 +100,15 @@
return null;
}
- JSFunction ajaxFunction = buildAjaxFunction(context, component,
AJAX_FUNCTION_NAME);
+ JSFunction ajaxFunction = new JSFunction(AJAX_FUNCTION_NAME);
+
+ ajaxFunction.addParameter(SOURCE_JS_REF);
+ ajaxFunction.addParameter(JSReference.EVENT);
+
AjaxEventOptions eventOptions = buildEventOptions(context, component);
- eventOptions.setAjaxComponent(SOURCE_JS_REF);
+ eventOptions.set("complete", COMPLETE_JS_REF);
+
eventOptions.setClientParameters(PARAMS_JS_REF);
if (!eventOptions.isEmpty()) {
Modified:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
===================================================================
---
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-12-03
20:09:51 UTC (rev 20387)
+++
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-12-03
20:34:04 UTC (rev 20388)
@@ -27,6 +27,7 @@
.rf-tr-nd {
background: "url(#{resource['org.richfaces.images:line.png']})
repeat-y";
+ min-height: 0px;
}
.rf-tr-nd-last {
@@ -37,7 +38,7 @@
margin-left: 16px;
}
-.rf-trn-ico, .rf-trn-hnd {
+.rf-trn-ico, .rf-trn-hnd, .rf-trn-ldn-fct {
vertical-align: middle;
margin: 0px;
cursor: pointer;
@@ -78,3 +79,16 @@
.rf-tr-nd.rf-tr-nd-colps .rf-tr-nd {
display: none;
}
+
+.rf-trn-ldn-fct {
+ cursor: default;
+ display: none;
+}
+
+.rf-trn-ldn > .rf-trn-ldn-fct {
+ display: inline-block;
+}
+
+.rf-trn-ldn > .rf-trn-ldn-fct + .rf-trn-hnd {
+ display: none;
+}
\ No newline at end of file
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-12-03
20:09:51 UTC (rev 20387)
+++
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-12-03
20:34:04 UTC (rev 20388)
@@ -89,12 +89,16 @@
}
},
+ __getNodeContainer: function() {
+ return this.__rootElt.find(" > .rf-trn:first");
+ },
+
__getHandle: function() {
- return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd:first");
+ return this.__getNodeContainer().find(" > .rf-trn-hnd:first");
},
__getContent: function() {
- return this.__rootElt.find(" > .rf-trn:first > .rf-trn-cnt:first");
+ return this.__getNodeContainer().find(" > .rf-trn-cnt:first");
},
__getIcons: function() {
@@ -156,7 +160,7 @@
},
__canBeToggled: function() {
- return !this.isLeaf() &&
!this.__rootElt.hasClass("rf-tr-nd-exp-nc");
+ return !this.isLeaf() && !this.__rootElt.hasClass("rf-tr-nd-exp-nc")
&& !this.__loading;
},
toggle: function() {
@@ -189,6 +193,16 @@
richfaces.Event.callHandler(this.__rootElt, "toggle");
},
+ __makeLoading: function() {
+ this.__loading = true;
+ this.__getNodeContainer().addClass("rf-trn-ldn");
+ },
+
+ __resetLoading: function() {
+ this.__loading = false;
+ this.__getNodeContainer().removeClass("rf-trn-ldn");
+ },
+
__changeToggleState: function(newState) {
if (!this.isLeaf()) {
if (newState ^ this.isExpanded()) {
@@ -216,7 +230,7 @@
case 'ajax':
case 'server':
//TODO - event?
- tree.__sendToggleRequest(null, this.getId(), newState);
+ tree.__sendToggleRequest(null, this, newState);
break;
}
}
@@ -314,7 +328,7 @@
this.__selectionType = options.selectionType || 'client';
if (options.ajaxSubmitFunction) {
- this.__ajaxSubmitFunction = new Function("event", "source",
"params", options.ajaxSubmitFunction);
+ this.__ajaxSubmitFunction = new Function("event", "source",
"params", "complete", options.ajaxSubmitFunction);
}
if (options.onbeforeselectionchange) {
@@ -387,15 +401,23 @@
},
__sendToggleRequest: function(event, toggleSource, newNodeState) {
+ var toggleSourceId = toggleSource.getId();
+
var clientParams = {};
- clientParams[toggleSource + NEW_NODE_TOGGLE_STATE] = newNodeState;
+ clientParams[toggleSourceId + NEW_NODE_TOGGLE_STATE] = newNodeState;
if (this.getToggleType() == 'server') {
var form = this.__treeRootElt.closest('form');
richfaces.submitForm(form, clientParams);
} else {
- clientParams[toggleSource + TRIGGER_NODE_AJAX_UPDATE] = newNodeState;
- this.__ajaxSubmitFunction(event, toggleSource, clientParams);
+ toggleSource.__makeLoading();
+ clientParams[toggleSourceId + TRIGGER_NODE_AJAX_UPDATE] = newNodeState;
+ this.__ajaxSubmitFunction(event, toggleSourceId, clientParams, function() {
+ var treeNode = richfaces.$(toggleSourceId);
+ if (treeNode) {
+ treeNode.__resetLoading();
+ }
+ });
}
},
@@ -425,7 +447,7 @@
return;
}
- this.__selectionInput.val(newSelection.toString());
+ this.__selectionInput.val(newSelection.getNodeString());
if (this.getSelectionType() == 'client') {
this.__updateSelection(newSelection);
Modified: trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-12-03 20:09:51 UTC
(rev 20387)
+++ trunk/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-12-03 20:34:04 UTC
(rev 20388)
@@ -26,6 +26,16 @@
<cdk:call expression="addClientEventHandlers(facesContext,
component)" />
<div class="#{concatClasses('rf-trn',
component.attributes['styleClass'],
tree.attributes['nodeClass'])}">
+ <cdk:object name="loadingFacet" type="UIComponent"
value="#{getLoadingFacetIfApplicable(component)}" />
+
+ <c:if test="#{not empty loadingFacet and
loadingFacet.isRendered()}">
+ <span class="rf-trn-ldn-fct">
+ <cdk:call>
+ loadingFacet.encodeAll(facesContext);
+ </cdk:call>
+ </span>
+ </c:if>
+
<span class="#{concatClasses(nodeState.handleClass,
component.attributes['handleClass'],
tree.attributes['handleClass'])}"></span>
<span class="rf-trn-cnt">