You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Erik Jan de Wit <EJ...@iprofs.nl> on 2005/11/08 10:21:54 UTC

datascroller problems

Hi,

When I use the datascroller there are next and previous links even when =
there is no more data e.g. when I'm on the first page there is still a =
previous link. Is this a bug? I've fixed this by creating my own =
HtmlDataScrollerRenderer is this the proper way to fix this problem?

Thanks for any help

ERIK JAN DE WIT
M  +31 (0)6 - 41 915 800
IPROFS B.V.                                                                                           
GEBOUW "DE HOUTHOF"
CLAUS SLUTERWEG 125 B.0
2012 WS  HAARLEM
T +31 (0)23 - 547 63 69
F +31 (0)23 - 547 63 70
WWW.IPROFS.NL


RE: datascroller problems

Posted by Michael Heinen <mh...@recommind.com>.
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:mkienenb@gmail.com] 
Sent: Donnerstag, 13. Juli 2006 22:51
To: MyFaces Discussion
Subject: Re: datascroller problems

On 7/13/06, Anitha Suraj <as...@gmail.com> 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>





Re: datascroller problems

Posted by Mike Kienenberger <mk...@gmail.com>.
On 7/13/06, Anitha Suraj <as...@gmail.com> 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>

Re: datascroller problems

Posted by Anitha Suraj <as...@gmail.com>.
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.

-- 
View this message in context: http://www.nabble.com/datascroller-problems-tf509753.html#a5316334
Sent from the MyFaces - Users forum at Nabble.com.


Re: datascroller problems

Posted by Mathias Brökelmann <mb...@googlemail.com>.
it would be helpful to make these changes optional through attributes
if possible.

2005/11/8, gramani@intellicare.com <gr...@intellicare.com>:
>
> Mathias Brökelmann <mb...@googlemail.com> wrote on 11/08/2005
> 03:50:48 PM:
>
>  > I think this functionality would be really nice to have in
>  > t:datascroller. Care for making a patch?
>  >
>  > 2005/11/8, Erik Jan de Wit <EJ...@iprofs.nl>:
>  > >
>  > >
>  > > Hi,
>  > >
>  > >  When I use the datascroller there are next and previous links even
> when =
>  > >  there is no more data e.g. when I'm on the first page there is still a
> =
>  > >  previous link. Is this a bug? I've fixed this by creating my own =
>  > >  HtmlDataScrollerRenderer is this the proper way to fix this problem?
>
> I was looking for this functionality and was in fact thinking of making this
> change! :) In fact instead of not showing a Next/previous link I thought we
> could show a "disabled" image instead. On similar lines, if we are on page
> 1, then the link to Page 1 should not be active. Could you please post the
> code changes you have so i can use it too?
>
>  > --
>  > Mathias
>  >
>
> Many thanks!
> Geeta
>


--
Mathias

Re: datascroller problems

Posted by gr...@intellicare.com.
Mathias Brökelmann <mb...@googlemail.com> wrote on 11/08/2005 
03:50:48 PM:

> I think this functionality would be really nice to have in
> t:datascroller. Care for making a patch?
> 
> 2005/11/8, Erik Jan de Wit <EJ...@iprofs.nl>:
> >
> >
> > Hi,
> >
> >  When I use the datascroller there are next and previous links even 
when =
> >  there is no more data e.g. when I'm on the first page there is still 
a =
> >  previous link. Is this a bug? I've fixed this by creating my own =
> >  HtmlDataScrollerRenderer is this the proper way to fix this problem?

I was looking for this functionality and was in fact thinking of making 
this change! :) In fact instead of not showing a Next/previous link I 
thought we could show a "disabled" image instead. On similar lines, if we 
are on page 1, then the link to Page 1 should not be active. Could you 
please post the code changes you have so i can use it too? 

> --
> Mathias
> 

Many thanks!
Geeta

Re: datascroller problems

Posted by Mathias Brökelmann <mb...@googlemail.com>.
I think this functionality would be really nice to have in
t:datascroller. Care for making a patch?

2005/11/8, Erik Jan de Wit <EJ...@iprofs.nl>:
>
>
> Hi,
>
>  When I use the datascroller there are next and previous links even when =
>  there is no more data e.g. when I'm on the first page there is still a =
>  previous link. Is this a bug? I've fixed this by creating my own =
>  HtmlDataScrollerRenderer is this the proper way to fix this problem?
>
>  Thanks for any help
>
>  ERIK JAN DE WIT
>  M  +31 (0)6 - 41 915 800
>  IPROFS B.V.
>
>  GEBOUW "DE HOUTHOF"
>  CLAUS SLUTERWEG 125 B.0
>  2012 WS  HAARLEM
>  T +31 (0)23 - 547 63 69
>  F +31 (0)23 - 547 63 70
>  WWW.IPROFS.NL
>
>


--
Mathias