You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/02/07 16:53:39 UTC
svn commit: r1241503 - in /myfaces/tobago/branches/tobago-tree-table:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-example/tobago-example-test/src/main/webapp/tc/tree/
tobago-theme/tobago-theme-scarborough/src/main/jav...
Author: lofwyr
Date: Tue Feb 7 15:53:38 2012
New Revision: 1241503
URL: http://svn.apache.org/viewvc?rev=1241503&view=rev
Log:
TOBAGO-1049: Tree inside of the Sheet (aka TreeTable)
- working on the "marked" hidden field:
- fixed: after marking on node, all nodes are marked, when there is no model
Added:
myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-with-model.xhtml
- copied, changed from r1241368, myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-command.xhtml
myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-without-model.xhtml
Modified:
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java
myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java?rev=1241503&r1=1241502&r2=1241503&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIData.java Tue Feb 7 15:53:38 2012
@@ -40,6 +40,9 @@ public class AbstractUIData extends java
*/
private TreeDataModel dataModel;
+ // is transient
+ private Integer submittedMarked;
+
@Override
protected DataModel getDataModel() {
if (!initialized) {
@@ -104,4 +107,12 @@ public class AbstractUIData extends java
public boolean isRendersRowContainer() {
return false;
}
+
+ public Integer getSubmittedMarked() {
+ return submittedMarked;
+ }
+
+ public void setSubmittedMarked(Integer submittedMarked) {
+ this.submittedMarked = submittedMarked;
+ }
}
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java?rev=1241503&r1=1241502&r2=1241503&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java Tue Feb 7 15:53:38 2012
@@ -164,13 +164,13 @@ public abstract class AbstractUITreeNode
if (FacesUtils.hasValueBindingOrValueExpression(this, Attributes.MARKED)) {
try {
FacesUtils.setValueOfBindingOrExpression(getFacesContext(), marked, this, Attributes.MARKED);
+ // after processing this, we remove the value, so we'll got the value from the model while rendering
+ ComponentUtils.findAncestor(this, AbstractUIData.class).setSubmittedMarked(null);
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Can't set marked.", e);
}
}
- } else {
- setMarked(marked);
}
}
}
Copied: myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-with-model.xhtml (from r1241368, myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-command.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-with-model.xhtml?p2=myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-with-model.xhtml&p1=myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-command.xhtml&r1=1241368&r2=1241503&rev=1241503&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-command.xhtml (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-with-model.xhtml Tue Feb 7 15:53:38 2012
@@ -28,12 +28,12 @@
<tc:gridLayout rows="auto;*"/>
</f:facet>
- <tc:out value="Tree with commands as nodes:"/>
+ <tc:out value="Tree with a marked node which should be stored tempotarily in the view:"/>
<tc:tree id="tree" value="#{tree.tree}" var="node" showRoot="true" showRootJunction="true">
- <tc:treeNode id="node" expanded="true">
+ <tc:treeNode id="node" expanded="true" marked="#{node.userObject.selected}">
<tc:treeIndent/>
- <tc:treeCommand label="#{node.userObject.name}" action="#{node.userObject.action}"/>
+ <tc:treeCommand label="#{node.userObject.name}"/>
</tc:treeNode>
</tc:tree>
Added: myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-without-model.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-without-model.xhtml?rev=1241503&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-without-model.xhtml (added)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-marked-without-model.xhtml Tue Feb 7 15:53:38 2012
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<f:view
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <tc:page id="page">
+ <tc:gridLayoutConstraint width="600px" height="300px"/>
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto;*"/>
+ </f:facet>
+
+ <tc:out value="Tree with a marked node which should be stored tempotarily in the view:"/>
+
+ <tc:tree id="tree" value="#{tree.tree}" var="node" showRoot="true" showRootJunction="true">
+ <tc:treeNode id="node" expanded="true">
+ <tc:treeIndent/>
+ <tc:treeCommand label="#{node.userObject.name}"/>
+ </tc:treeNode>
+ </tc:tree>
+
+ </tc:page>
+</f:view>
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java?rev=1241503&r1=1241502&r2=1241503&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java Tue Feb 7 15:53:38 2012
@@ -85,10 +85,9 @@ public class TreeNodeRenderer extends La
}
// marked
- String marked
- = (String) requestParameterMap.get(treeId + ComponentUtils.SUB_SEPARATOR + AbstractUITree.SUFFIX_MARKED);
+ Integer marked = data.getSubmittedMarked();
if (marked != null) {
- boolean markedValue = marked.equals("" + rowIndex);
+ boolean markedValue = marked.equals(rowIndex);
if (node.isMarked() != markedValue) {
new TreeMarkedEvent(node, node.isMarked(), markedValue).queue();
}
@@ -102,7 +101,7 @@ public class TreeNodeRenderer extends La
super.prepareRender(facesContext, component);
final UITreeNode node = (UITreeNode) component;
- if (node.isMarked()) {
+ if (isMarked(node)) {
node.setCurrentMarkup(Markup.MARKED.add(node.getCurrentMarkup()));
}
if (node.isFolder()) {
@@ -112,6 +111,15 @@ public class TreeNodeRenderer extends La
}
}
}
+
+ private boolean isMarked(UITreeNode node) {
+ final AbstractUIData data = ComponentUtils.findAncestor(node, AbstractUIData.class);
+ final Integer submittedMarked = data.getSubmittedMarked();
+ if (submittedMarked != null && submittedMarked.equals(data.getRowIndex())) {
+ return true;
+ }
+ return node.isMarked();
+ }
@Override
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java?rev=1241503&r1=1241502&r2=1241503&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java (original)
+++ myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeRenderer.java Tue Feb 7 15:53:38 2012
@@ -43,6 +43,17 @@ public class TreeRenderer extends Layout
@Override
public void decode(FacesContext facesContext, UIComponent component) {
final AbstractUITree tree = (AbstractUITree) component;
+
+ // marked
+ String marked = (String) facesContext.getExternalContext().getRequestParameterMap()
+ .get(tree.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + AbstractUITree.SUFFIX_MARKED);
+ try {
+ tree.setSubmittedMarked(Integer.parseInt(marked));
+ } catch (NumberFormatException e) {
+ LOG.warn("marked: + " + marked + "'", e);
+ }
+
+ // children
final int last = tree.hasRows() ? tree.getFirst() + tree.getRows() : Integer.MAX_VALUE;
for (int rowIndex = tree.getFirst(); rowIndex < last; rowIndex++) {
tree.setRowIndex(rowIndex);
@@ -92,7 +103,8 @@ public class TreeRenderer extends Layout
writer.writeNameAttribute(markedId);
writer.writeIdAttribute(markedId);
writer.writeClassAttribute(Classes.create(tree, AbstractUITree.SUFFIX_MARKED));
- writer.writeAttribute(HtmlAttributes.VALUE, "", false);
+ final Integer value = tree.getSubmittedMarked();
+ writer.writeAttribute(HtmlAttributes.VALUE, value != null ? Integer.toString(value) : "", false);
writer.endElement(HtmlElements.INPUT);
final int last = tree.hasRows() ? tree.getFirst() + tree.getRows() : Integer.MAX_VALUE;