I added this functionality to the HtmlDataScrollerRenderer.
In order to keep the layout and positions up I used blind images.

<f:facet name="first">
   <h:panelGroup>
      <t:graphicImage url="/images/start.gif"
                      rendered="#{pageIndex gt 1}"/>
      <t:graphicImage url="/images/clear_19.gif"
rendered="#{pageIndex eq 1}"/>
   </h:panelGroup>
</f:facet>


The blind images are still linked.
So I overwrote HtmlDataScrollerRenderer to disable these links:
(BTW I added also onclick/ondblclick attributes)


protected void renderFacet(FacesContext facesContext, HtmlDataScroller
scroller, UIComponent facetComp, String facetName)
        throws IOException
    {
        HtmlCommandLink link=null;
        String onclick = scroller.getOnclick();
        String ondblclick = scroller.getOndblclick();

        boolean isLinkDisabled=false;
                        if ( scroller.getPageIndex()==1 &&
(facetName.equals("first") || facetName.equals("previous"))
          || (scroller.getPageIndex()==scroller.getPageCount()&&
(facetName.equals("last") || facetName.equals("next")))) {
                isLinkDisabled=true;
        }
        
        if (!isLinkDisabled) {
                link = getLink(facesContext, scroller, facetName);
                if(onclick != null){
                        link.setOnclick(onclick);
                }
                if(ondblclick != null){
                        link.setOndblclick(ondblclick);
                }
                link.encodeBegin(facesContext);
        }

        facetComp.encodeBegin(facesContext);
        if(facetComp.getRendersChildren())
            facetComp.encodeChildren(facesContext);
        facetComp.encodeEnd(facesContext);

        if (!isLinkDisabled) {
           link.encodeEnd(facesContext);
        }
    }
-----Original Message-----
From: Mike Kienenberger [mailto:[EMAIL PROTECTED] 
Sent: Donnerstag, 13. Juli 2006 22:51
To: MyFaces Discussion
Subject: Re: datascroller problems

On 7/13/06, Anitha Suraj <[EMAIL PROTECTED]> wrote:
> Has anybody made a patch to disable next and previous buttons on
dataScroller
> on the last and first pages? If not, if any of you have already made
this
> change, can you please give us some pointers on what was done? Thanks.

I add rendered tags to remove them.   You could create disabled images
and render those with the negated conditions if you wanted to show
them as disabled.

Feel free to add this to the MyFaces wiki if you found it to be
helpful as the question has been asked before.


<t:dataScroller id="scroll_controls"
                                  for="searchResultsDataTable"
                                  fastStep="10"
                                  pageCountVar="pageCount"
                                  pageIndexVar="pageIndex"
                                  styleClass="scroller"
                                  paginator="#{true}"
                                  paginatorMaxPages="9"
                                  paginatorTableClass="paginator"
        
paginatorActiveColumnStyle="font-weight:bold;"
                                  >
          <f:facet name="first">
                  <h:graphicImage
                          rendered="#{pageIndex gt 1}"
                          url="/images/arrow-first.gif"/>
          </f:facet>
          <f:facet name="fastrewind">
                  <h:graphicImage
                          rendered="#{pageIndex gt 1}"
                          url="/images/arrow-fr.gif"/>
          </f:facet>
          <f:facet name="previous">
                  <h:graphicImage
                          rendered="#{pageIndex gt 1}"
                          url="/images/arrow-previous.gif"/>
          </f:facet>
          <f:facet name="next">
                  <h:graphicImage
                          rendered="#{pageIndex lt pageCount}"
                          url="/images/arrow-next.gif"/>
          </f:facet>
          <f:facet name="fastforward">
                  <h:graphicImage
                          rendered="#{pageIndex lt pageCount}"
                          url="/images/arrow-ff.gif"/>
          </f:facet>
          <f:facet name="last">
                  <h:graphicImage
                          rendered="#{pageIndex lt pageCount}"
                          url="/images/arrow-last.gif"/>
          </f:facet>
</t:dataScroller>




Reply via email to