myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject [myfaces-tobago] branch master updated: tobago-tree: custom elements
Date Thu, 17 Oct 2019 09:50:54 GMT
This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 8fd3932  tobago-tree: custom elements
8fd3932 is described below

commit 8fd39323799d58c68d6ede13f2c20e3843daebfc
Author: Henning Noeth <hnoeth@apache.org>
AuthorDate: Thu Oct 17 11:37:40 2019 +0200

    tobago-tree: custom elements
    
    Execute tree to make sure every node updates the model.
    This is important for e.g. Selectable.single. In this case the node
    which is now selected must be updated and the node which is now
    deselected must be also updated.
    
    issue: TOBAGO-1633: TS refactoring
---
 .../internal/renderkit/renderer/TreeSelectRenderer.java     | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java
index 6c6321b..ad60083 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java
@@ -19,11 +19,15 @@
 
 package org.apache.myfaces.tobago.internal.renderkit.renderer;
 
+import org.apache.myfaces.tobago.component.ClientBehaviors;
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.internal.component.AbstractUIData;
+import org.apache.myfaces.tobago.internal.component.AbstractUITree;
 import org.apache.myfaces.tobago.internal.component.AbstractUITreeListbox;
 import org.apache.myfaces.tobago.internal.component.AbstractUITreeNodeBase;
 import org.apache.myfaces.tobago.internal.component.AbstractUITreeSelect;
+import org.apache.myfaces.tobago.internal.renderkit.Command;
+import org.apache.myfaces.tobago.internal.renderkit.CommandMap;
 import org.apache.myfaces.tobago.internal.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.internal.util.StringUtils;
 import org.apache.myfaces.tobago.model.Selectable;
@@ -50,9 +54,6 @@ public class TreeSelectRenderer extends RendererBase {
 
   @Override
   public void decode(final FacesContext facesContext, final UIComponent component) {
-
-    // TODO do we need this?
-
     final AbstractUITreeSelect select = (AbstractUITreeSelect) component;
     final AbstractUITreeNodeBase node = ComponentUtils.findAncestor(select, AbstractUITreeNodeBase.class);
     final AbstractUIData data = ComponentUtils.findAncestor(node, AbstractUIData.class);
@@ -85,6 +86,7 @@ public class TreeSelectRenderer extends RendererBase {
   public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws
IOException {
 
     final AbstractUITreeSelect treeSelect = (AbstractUITreeSelect) component;
+    final AbstractUITree tree = ComponentUtils.findAncestor(treeSelect, AbstractUITree.class);
     final AbstractUITreeNodeBase node = ComponentUtils.findAncestor(treeSelect, AbstractUITreeNodeBase.class);
     final AbstractUIData data = ComponentUtils.findAncestor(node, AbstractUIData.class);
 
@@ -133,7 +135,10 @@ public class TreeSelectRenderer extends RendererBase {
 
       writer.endElement(HtmlElements.INPUT);
 
-      encodeBehavior(writer, facesContext, treeSelect);
+      final CommandMap behaviorCommands = getBehaviorCommands(facesContext, treeSelect);
+      Command change = behaviorCommands.getOther().get(ClientBehaviors.change);
+      change.setExecute(change.getExecute() + " " + tree.getClientId(facesContext));
+      encodeBehavior(writer, behaviorCommands);
     }
 
     // label


Mime
View raw message