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/08 10:59:04 UTC
svn commit: r1241840 - in /myfaces/tobago/branches/tobago-tree-table:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/stand...
Author: lofwyr
Date: Wed Feb 8 09:59:04 2012
New Revision: 1241840
URL: http://svn.apache.org/viewvc?rev=1241840&view=rev
Log:
TOBAGO-1049: Tree inside of the Sheet (aka TreeTable)
- working on the "expanded" hidden field(s):
- cleanup
- apply last changes to MenuNode
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-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.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=1241840&r1=1241839&r2=1241840&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 Wed Feb 8 09:59:04 2012
@@ -92,7 +92,8 @@ public class AbstractUIData extends java
/**
* Returns every time the real client id of the tree without the row id.
*/
- public String getTreeClientId(FacesContext facesContext) {
+ // XXX delete it?
+ private String getTreeClientId(FacesContext facesContext) {
final String clientId = getClientId(facesContext);
final int rowIndex = getRowIndex();
if (rowIndex == -1) {
Modified: myfaces/tobago/branches/tobago-tree-table/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.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/TreeMenuNodeRenderer.java?rev=1241840&r1=1241839&r2=1241840&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/TreeMenuNodeRenderer.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/TreeMenuNodeRenderer.java Wed Feb 8 09:59:04 2012
@@ -25,7 +25,6 @@ import org.apache.myfaces.tobago.context
import org.apache.myfaces.tobago.event.TreeExpansionEvent;
import org.apache.myfaces.tobago.event.TreeMarkedEvent;
import org.apache.myfaces.tobago.internal.component.AbstractUIData;
-import org.apache.myfaces.tobago.internal.component.AbstractUITree;
import org.apache.myfaces.tobago.layout.Display;
import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -33,7 +32,6 @@ import org.apache.myfaces.tobago.renderk
import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
-import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
import org.apache.myfaces.tobago.util.VariableResolverUtils;
@@ -44,7 +42,7 @@ import org.slf4j.LoggerFactory;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import java.io.IOException;
-import java.util.Map;
+import java.util.List;
public class TreeMenuNodeRenderer extends LayoutComponentRendererBase {
@@ -63,26 +61,20 @@ public class TreeMenuNodeRenderer extend
final AbstractUIData data = ComponentUtils.findAncestor(node, AbstractUIData.class);
// we need the client id without the iterated row index here
- final String treeId = data.getTreeClientId(facesContext);
final int rowIndex = data.getRowIndex();
- final Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
- final String id = node.getClientId(facesContext);
- final boolean folder = node.isFolder();
- // expand state
+ // expanded
// if (folder) { XXX this value seems to be not restored...
- boolean expanded = Boolean.parseBoolean(
- requestParameterMap.get(id + ComponentUtils.SUB_SEPARATOR + AbstractUITree.SUFFIX_EXPANDED));
- if (node.isExpanded() != expanded) {
- new TreeExpansionEvent(node, node.isExpanded(), expanded).queue();
+ final List<Integer> submittedExpanded = data.getSubmittedExpanded();
+ if (submittedExpanded != null && submittedExpanded.contains(rowIndex) != node.isExpanded()) {
+ new TreeExpansionEvent(node, node.isExpanded(), submittedExpanded.contains(rowIndex)).queue();
}
// }
// 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();
}
@@ -96,12 +88,12 @@ public class TreeMenuNodeRenderer extend
super.prepareRender(facesContext, component);
final UITreeNode node = (UITreeNode) component;
- if (node.isMarked()) {
+ if (node.isMarkedWithTemporaryState()) {
node.setCurrentMarkup(Markup.MARKED.add(node.getCurrentMarkup()));
}
if (node.isFolder()) {
node.setCurrentMarkup(Markup.FOLDER.add(node.getCurrentMarkup()));
- if (node.isExpanded()) {
+ if (node.isExpandedWithTemporaryState()) {
node.setCurrentMarkup(Markup.EXPANDED.add(node.getCurrentMarkup()));
}
}
@@ -122,7 +114,6 @@ public class TreeMenuNodeRenderer extend
final boolean showRoot = data instanceof UITree && ((UITree) data).isShowRoot();
final boolean ie6
= VariableResolverUtils.resolveClientProperties(facesContext).getUserAgent().equals(UserAgent.MSIE_6_0);
- final boolean expanded = folder && node.isExpanded() || level == 0;
final String parentId = data.getRowParentClientId();
final boolean visible = root ? showRoot : data.isRowVisible();
@@ -142,9 +133,6 @@ public class TreeMenuNodeRenderer extend
writer.writeStyleAttribute(style);
}
- if (folder) {
- encodeExpandedHidden(writer, node, clientId, expanded);
- }
if (!folder && ie6) { // XXX IE6: without this hack, we can't click beside the label text. Why?
final String src = ResourceManagerUtils.getImageWithPath(facesContext, "image/1x1.gif");
@@ -162,7 +150,7 @@ public class TreeMenuNodeRenderer extend
final UITreeNode node = (UITreeNode) component;
final int level = node.getLevel();
final boolean folder = node.isFolder();
- final boolean expanded = folder && node.isExpanded() || level == 0;
+ final boolean expanded = folder && node.isExpandedWithTemporaryState() || level == 0;
final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
@@ -172,16 +160,6 @@ public class TreeMenuNodeRenderer extend
writer.endElement(HtmlElements.DIV);
}
- private void encodeExpandedHidden(
- TobagoResponseWriter writer, UITreeNode node, String clientId, boolean expanded) throws IOException {
- writer.startElement(HtmlElements.INPUT, node);
- writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
- writer.writeClassAttribute(Classes.create(node, AbstractUITree.SUFFIX_EXPANDED, Markup.NULL));
- writer.writeNameAttribute(clientId + ComponentUtils.SUB_SEPARATOR + AbstractUITree.SUFFIX_EXPANDED);
- writer.writeAttribute(HtmlAttributes.VALUE, Boolean.toString(expanded), false);
- writer.endElement(HtmlElements.INPUT);
- }
-
private void encodeIcon(FacesContext facesContext, TobagoResponseWriter writer, boolean expanded, UITreeNode node)
throws IOException {
final String srcOpen = ResourceManagerUtils.getImageWithPath(facesContext, "image/treeMenuOpen.gif");
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=1241840&r1=1241839&r2=1241840&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 Wed Feb 8 09:59:04 2012
@@ -41,7 +41,6 @@ import javax.faces.component.UIComponent
import javax.faces.context.FacesContext;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
public class TreeNodeRenderer extends LayoutComponentRendererBase {
@@ -67,10 +66,7 @@ public class TreeNodeRenderer extends La
final AbstractUIData data = ComponentUtils.findAncestor(node, AbstractUIData.class);
// we need the client id without the iterated row index here
- final String treeId = data.getTreeClientId(facesContext);
final int rowIndex = data.getRowIndex();
- final Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
- final String id = node.getClientId(facesContext);
final boolean folder = node.isFolder();
// expanded
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=1241840&r1=1241839&r2=1241840&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 Wed Feb 8 09:59:04 2012
@@ -50,7 +50,7 @@ public class TreeRenderer extends Layout
String marked = (String) facesContext.getExternalContext().getRequestParameterMap()
.get(tree.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + AbstractUITree.SUFFIX_MARKED);
try {
- tree.setSubmittedMarked(Integer.parseInt(marked));
+ tree.setSubmittedMarked(org.apache.commons.lang.StringUtils.isNotBlank(marked) ? Integer.parseInt(marked) : null);
} catch (NumberFormatException e) {
// should not happen
LOG.warn("Can't parse marked: + " + marked + "'", e);
@@ -60,8 +60,8 @@ public class TreeRenderer extends Layout
String expanded = (String) facesContext.getExternalContext().getRequestParameterMap()
.get(tree.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + AbstractUITree.SUFFIX_EXPANDED);
try {
- tree.setSubmittedExpanded(StringUtils.parseIntegerList(expanded));
- } catch (Exception e) {
+ tree.setSubmittedExpanded(expanded != null ? StringUtils.parseIntegerList(expanded) : null);
+ } catch (NumberFormatException e) {
// should not happen
LOG.warn("Can't parse expanded: + " + expanded + "'", e);
}