You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mc...@apache.org on 2010/05/28 22:55:12 UTC

svn commit: r949291 - in /myfaces/trinidad/branches/trinidad-1.2.x: src/site/xdoc/skin-selectors.xml trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java

Author: mcooper
Date: Fri May 28 20:55:11 2010
New Revision: 949291

URL: http://svn.apache.org/viewvc?rev=949291&view=rev
Log:
TRINIDAD-885  - Provide selector to show navigation bar on bottom of table

The old ADF Faces table had a skin property like:
af|table{ -ora-repeat-control-bar: true; }

but the Apache MyFaces Trinidad table did not expose an equivalent:
af|table { -tr-repeat-control-bar: true; }

While there was an existing variable for this skin property and some TableRenderer code to decide which bar to render, it wasn't actually functional or documented.

I've added documentation for the skin property and have enabled the TableRenderer to use this property to decide whether to repeat the control bar.
The default remains to not repeat the control bar and you can enable it by adding this rule in your skin:
af|table { -tr-repeat-control-bar: true; } 

Modified:
    myfaces/trinidad/branches/trinidad-1.2.x/src/site/xdoc/skin-selectors.xml
    myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java

Modified: myfaces/trinidad/branches/trinidad-1.2.x/src/site/xdoc/skin-selectors.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.2.x/src/site/xdoc/skin-selectors.xml?rev=949291&r1=949290&r2=949291&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.2.x/src/site/xdoc/skin-selectors.xml (original)
+++ myfaces/trinidad/branches/trinidad-1.2.x/src/site/xdoc/skin-selectors.xml Fri May 28 20:55:11 2010
@@ -3590,6 +3590,22 @@
         <table>
           <tr>
             <th colspan="2">
+              <i>Properties</i>
+            </th>
+          </tr>
+          <tr>
+            <th>Name</th>
+            <th>Description</th>
+          </tr>
+          <tr>
+            <td>-tr-repeat-control-bar</td>
+            <td>Boolean value that specifies whether the the table navigation bar appears on
+                both the bottom and top of the table.</td>
+          </tr>
+        </table>
+        <table>
+          <tr>
+            <th colspan="2">
               <i>Style Selectors</i>
             </th>
           </tr>

Modified: myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java?rev=949291&r1=949290&r2=949291&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java (original)
+++ myfaces/trinidad/branches/trinidad-1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/TableRenderer.java Fri May 28 20:55:11 2010
@@ -67,6 +67,8 @@ import org.apache.myfaces.trinidadintern
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableSelectManyRenderer;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableSelectOneRenderer;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TreeUtils;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SkinProperties;
+
 
 abstract public class TableRenderer extends XhtmlRenderer
 {
@@ -373,6 +375,12 @@ abstract public class TableRenderer exte
       // 2. render the table content
       renderTableContent(context, arc, tContext, component);
 
+      // 3. render the footer bars (controlbar) if applicable
+      if (_shouldRepeatControlBar(arc))
+      {
+        renderNavigationFooterBars(context, arc, tContext, component, bean);
+      }
+
       // end the outertable:
       rw.endElement(XhtmlConstants.TABLE_ELEMENT);
 
@@ -674,6 +682,35 @@ abstract public class TableRenderer exte
   }
 
   /**
+   * Render the navigation header bars, i.e. all the bars that appear above the
+   * actual data table. eg. title, controlbar and subcontrolbar
+   */
+  protected void renderNavigationFooterBars(
+    FacesContext          context,
+    RenderingContext      rc,
+    TableRenderingContext tContext,
+    UIComponent           component,
+    FacesBean             bean
+    ) throws IOException
+  {
+    // Render the lower control bar - must render tableActions even if table is empty.
+    _renderControlBar(context, rc, tContext, component, false); //isUpper
+  }
+
+  private boolean _shouldRepeatControlBar(RenderingContext rc)
+  {
+    Object propValue =
+      rc.getSkin().getProperty(SkinProperties.AF_TABLE_REPEAT_CONTROL_BAR);
+
+    if (propValue == null)
+    {
+      return DEFAULT_REPEAT_CONTROL_BAR;
+    }
+
+    return Boolean.TRUE.equals(propValue);
+  }
+
+  /**
    * @todo Decide if we really want to support "repeating" regions
    */
   private void _renderControlBar(
@@ -1023,6 +1060,12 @@ abstract public class TableRenderer exte
 
   private static final String _VALUE_FIELD_NAME      = "_value";
 
+  /**
+   * Whether the table should repeat its control bars above and below the table by default if not
+   * specified by the -tr-repeat-control-bar skin property.
+   */
+  public static final boolean DEFAULT_REPEAT_CONTROL_BAR = false;
+
   private final SpecialColumnRenderer _detailRenderer = new DetailColumnRenderer();
 
   private SpecialColumnRenderer _selectRenderer;