myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r955086 - in /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller: AbstractHtmlDataScroller.java HtmlDataScrollerRenderer.java
Date Tue, 15 Jun 2010 23:32:00 GMT
Author: lu4242
Date: Tue Jun 15 23:32:00 2010
New Revision: 955086

URL: http://svn.apache.org/viewvc?rev=955086&view=rev
Log:
TOMAHAWK-769 Datascroller - context sensitive previous, next links and TOMAHAWK-1426 Next
and Previous facets

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/AbstractHtmlDataScroller.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/AbstractHtmlDataScroller.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/AbstractHtmlDataScroller.java?rev=955086&r1=955085&r2=955086&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/AbstractHtmlDataScroller.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/AbstractHtmlDataScroller.java
Tue Jun 15 23:32:00 2010
@@ -869,4 +869,40 @@ public abstract class AbstractHtmlDataSc
      */
     public abstract boolean isImmediate();
 
+    /**
+     * If the dataScroller is on the first page (index is at 1), links for
+     * first, prev and fastprev are disabled. Default is false.
+     * 
+     * @JSFProperty
+     *   defaultValue="false"
+     */
+    public abstract boolean isDisableFacetLinksIfFirstPage();
+
+    /**
+     * If the dataScroller is on the last page (index is at pagecount), links for
+     * last, next and fastnext are disabled. Default is false.
+     * 
+     * @JSFProperty
+     *   defaultValue="false"
+     */
+    public abstract boolean isDisableFacetLinksIfLastPage();
+
+    /**
+     * If the dataScroller is on the first page (index is at 1), links for
+     * first, prev and fastprev are rendered. Default is true.
+     * 
+     * @JSFProperty
+     *   defaultValue="true"
+     */
+    public abstract boolean isRenderFacetLinksIfFirstPage();
+
+    /**
+     * If the dataScroller is on the last page (index is at pagecount), links for
+     * last, next and fastnext are rendered. Default is true.
+     * 
+     * @JSFProperty
+     *   defaultValue="true"
+     */
+    public abstract boolean isRenderFacetLinksIfLastPage();
+    
 }

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java?rev=955086&r1=955085&r2=955086&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
Tue Jun 15 23:32:00 2010
@@ -238,12 +238,17 @@ public class HtmlDataScrollerRenderer ex
         }
         writeScrollerRowStart(writer, scroller);
 
+        boolean startActive = (scroller.getPageIndex() != 1);
+
+        boolean endActive = (scroller.getPageIndex() != scroller.getPageCount());
+        
         UIComponent facetComp = scroller.getFirst();
         if (facetComp != null)
         {
             writeScrollerElementStart(writer, scroller);
             writeStyleClass("firstStyleClass", scroller.getFirstStyleClass(), writer);
-            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FIRST);
+            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FIRST,
startActive,
+                    scroller.isRenderFacetLinksIfFirstPage(), scroller.isDisableFacetLinksIfFirstPage());
             writeScrollerElementEnd(writer, scroller);
         }
         facetComp = scroller.getFastRewind();
@@ -251,7 +256,8 @@ public class HtmlDataScrollerRenderer ex
         {
             writeScrollerElementStart(writer, scroller);
             writeStyleClass("fastrStyleClass", scroller.getFastrStyleClass(), writer);
-            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FAST_REWIND);
+            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FAST_REWIND,
startActive,
+                    scroller.isRenderFacetLinksIfFirstPage(), scroller.isDisableFacetLinksIfFirstPage());
             writeScrollerElementEnd(writer, scroller);
         }
         facetComp = scroller.getPrevious();
@@ -259,7 +265,8 @@ public class HtmlDataScrollerRenderer ex
         {
             writeScrollerElementStart(writer, scroller);
             writeStyleClass("previous", scroller.getPreviousStyleClass(), writer);
-            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_PREVIOUS);
+            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_PREVIOUS,
startActive,
+                    scroller.isRenderFacetLinksIfFirstPage(), scroller.isDisableFacetLinksIfFirstPage());
             writeScrollerElementEnd(writer, scroller);
         }
         if (scroller.isPaginator())
@@ -279,7 +286,8 @@ public class HtmlDataScrollerRenderer ex
         {
             writeScrollerElementStart(writer, scroller);
             writeStyleClass("next", scroller.getNextStyleClass(), writer);
-            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_NEXT);
+            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_NEXT, endActive,
+                    scroller.isRenderFacetLinksIfLastPage(), scroller.isDisableFacetLinksIfLastPage());
             writeScrollerElementEnd(writer, scroller);
         }
         facetComp = scroller.getFastForward();
@@ -287,7 +295,8 @@ public class HtmlDataScrollerRenderer ex
         {
             writeScrollerElementStart(writer, scroller);
             writeStyleClass("fastf", scroller.getFastfStyleClass(), writer);
-            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FAST_FORWARD);
+            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FAST_FORWARD,
endActive,
+                    scroller.isRenderFacetLinksIfLastPage(), scroller.isDisableFacetLinksIfLastPage());
             writeScrollerElementEnd(writer, scroller);
         }
         facetComp = scroller.getLast();
@@ -295,7 +304,8 @@ public class HtmlDataScrollerRenderer ex
         {
             writeScrollerElementStart(writer, scroller);
             writeStyleClass("last", scroller.getLastStyleClass(), writer);
-            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_LAST);
+            renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_LAST, endActive,
+                    scroller.isRenderFacetLinksIfLastPage(), scroller.isDisableFacetLinksIfLastPage());
             writeScrollerElementEnd(writer, scroller);
         }
 
@@ -339,25 +349,47 @@ public class HtmlDataScrollerRenderer ex
     }
 
     protected void renderFacet(FacesContext facesContext, HtmlDataScroller scroller,
-                               UIComponent facetComp, String facetName) throws IOException
+                               UIComponent facetComp, String facetName, boolean active, boolean
renderLinks, boolean disableLinks) throws IOException
     {
         String onclick = scroller.getOnclick();
         String ondblclick = scroller.getOndblclick();
 
         HtmlCommandLink link = getLink(facesContext, scroller, facetName);
+
         if(onclick != null){
             link.setOnclick(onclick);
         }
+
         if(ondblclick != null){
             link.setOndblclick(ondblclick);
         }
 
-        link.encodeBegin(facesContext);
+        if (active) {
+            if (disableLinks && link.isDisabled())
+            {
+                //Enable because the facet is active
+                link.setDisabled(false);
+            }
+            link.encodeBegin(facesContext);
+        }
+        else if (renderLinks)
+        {
+            if (disableLinks && !link.isDisabled())
+            {
+                //Disable because the facet is not active
+                link.setDisabled(true);
+            }
+            link.encodeBegin(facesContext);
+        }
+
         facetComp.encodeBegin(facesContext);
         if (!facetComp.getRendersChildren())
             facetComp.encodeChildren(facesContext);
         facetComp.encodeEnd(facesContext);
-        link.encodeEnd(facesContext);
+
+        if (active || renderLinks) {
+            link.encodeEnd(facesContext);
+        }
     }
 
     /**



Mime
View raw message