myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r1759172 - in /myfaces/tobago/trunk: tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/30-event/ tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag...
Date Sun, 04 Sep 2016 11:34:16 GMT
Author: weber
Date: Sun Sep  4 11:34:16 2016
New Revision: 1759172

URL: http://svn.apache.org/viewvc?rev=1759172&view=rev
Log:
TOBAGO-1524: Use standard AJAX mechanism: fix ColumnEvent

Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/30-event/sheet-column-event.xhtml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/30-event/sheet-column-event.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/30-event/sheet-column-event.xhtml?rev=1759172&r1=1759171&r2=1759172&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/30-event/sheet-column-event.xhtml
(original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/080-sheet/30-event/sheet-column-event.xhtml
Sun Sep  4 11:34:16 2016
@@ -40,7 +40,7 @@
           <tc:columnEvent event="click">
             <tc:command actionListener="#{sheetController.selectSolarObject}" immediate="true">
               <tc:resetInputActionListener/>
-              <f:ajax render=":page:detail"/>
+              <f:ajax render=":::detail"/>
             </tc:command>
           </tc:columnEvent>
         </tc:sheet>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1759172&r1=1759171&r2=1759172&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
Sun Sep  4 11:34:16 2016
@@ -61,8 +61,6 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.css.Style;
 import org.apache.myfaces.tobago.renderkit.css.TobagoClass;
 import org.apache.myfaces.tobago.renderkit.html.Arias;
-import org.apache.myfaces.tobago.renderkit.html.Command;
-import org.apache.myfaces.tobago.renderkit.html.CommandMap;
 import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlButtonTypes;
@@ -223,7 +221,7 @@ public class SheetRenderer extends Rende
     final UISheet sheet = (UISheet) uiComponent;
     final TobagoResponseWriter writer = getResponseWriter(facesContext);
 
-    final boolean rowAction = renderSheetCommands(sheet, facesContext, writer);
+    final String rowActionId = renderSheetCommands(sheet, facesContext, writer);
     final String sheetId = sheet.getClientId(facesContext);
     final Selectable selectable = sheet.getSelectable();
     final Application application = facesContext.getApplication();
@@ -391,6 +389,12 @@ public class SheetRenderer extends Rende
         // if rowRendered attribute is set we need the rowIndex on the client
         writer.writeAttribute(DataAttributes.ROW_INDEX, rowIndex);
       }
+
+      if (rowActionId != null) {
+        // dirty hack: we need this id in the dom to allow ajax action on columnEvent
+        writer.writeIdAttribute(sheetId + ":" + sheet.getRowIndex() + ":" + rowActionId);
+      }
+
       final boolean selected = selectedRows.contains(rowIndex);
       final String[] rowMarkups = (String[]) sheet.getAttributes().get("rowMarkup");
       Markup rowMarkup = Markup.NULL;
@@ -418,7 +422,7 @@ public class SheetRenderer extends Rende
           if (markup == null) {
             markup = Markup.NULL;
           }
-          if (rowAction) {
+          if (rowActionId != null) {
             markup = markup.add(Markup.CLICKABLE);
           }
           if (isPure(column)) {
@@ -1169,28 +1173,27 @@ public class SheetRenderer extends Rende
     }
   }
 
-  private static boolean renderSheetCommands(
+  private static String renderSheetCommands(
       final UISheet sheet, final FacesContext facesContext, final TobagoResponseWriter writer)
throws IOException {
-    CommandMap commandMap = null;
+    // TODO: TOBAGO-1572
+    String commands = null;
+    String rowActionId = null;
     for (final UIComponent child : sheet.getChildren()) {
       if (child instanceof UIColumnEvent && child.isRendered()) {
         final UIColumnEvent columnEvent = (UIColumnEvent) child;
-        final UIComponent selectionChild = child.getChildren().get(0);
-        if (selectionChild != null && selectionChild instanceof AbstractUICommand
&& selectionChild.isRendered()) {
-          // TODO: TOBAGO-1572
-          final UICommand action = (UICommand) selectionChild;
-          if (commandMap == null) {
-            commandMap = new CommandMap();
+        if (columnEvent.getChildCount() > 0) {
+          final UIComponent selectionChild = columnEvent.getChildren().get(0);
+          if (selectionChild != null && selectionChild instanceof AbstractUICommand
&& selectionChild.isRendered()) {
+            commands = RenderUtils.getBehaviorCommands(facesContext, (ClientBehaviorHolder)
selectionChild);
+            rowActionId = selectionChild.getId();
           }
-          commandMap.addCommand(columnEvent.getEvent(), new Command(facesContext, action,
(String) null));
         }
       }
     }
-    if (commandMap != null) {
-      writer.writeAttribute(DataAttributes.ROW_ACTION, JsonUtils.encode(commandMap), true);
-      return true;
+    if (commands != null) {
+      writer.writeAttribute(DataAttributes.ROW_ACTION, commands, true);
     }
-    return false;
+    return rowActionId;
   }
 
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1759172&r1=1759171&r2=1759172&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
Sun Sep  4 11:34:16 2016
@@ -407,7 +407,8 @@ Tobago.Sheet.setup2 = function (sheets)
             var commands = sheet.data("tobago-row-action");
             var click = commands ? commands.click : undefined;
             var clickActionId = click ? click.action : undefined;
-            var clickReloadComponentId = click ? click.partially : undefined;
+            var clickExecuteIds = click ? click.execute : undefined;
+            var clickRenderIds = click ? click.render : undefined;
 
             var id = $sheet.attr("id");
 
@@ -420,15 +421,15 @@ Tobago.Sheet.setup2 = function (sheets)
               } else {
                 action = id + ":" + rowIndex + ":" + clickActionId;
               }
-              if (clickReloadComponentId && clickReloadComponentId.length > 0)
{
+              if (clickExecuteIds && clickExecuteIds.length > 0) {
                 //Tobago.reloadComponent($target.get(0), clickReloadComponentId, action)
                 jsf.ajax.request(
                     action,
                     event,
                     {
                       //"javax.faces.behavior.event": "click",
-                      execute: clickReloadComponentId,
-                      render: clickReloadComponentId
+                      execute: clickExecuteIds,
+                      render: clickRenderIds
                     });
               } else {
                 Tobago.submitAction($target.get(0), action);



Mime
View raw message