You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Hans Sowa <ha...@gmail.com> on 2006/03/27 15:29:28 UTC

missing row attribute in a datatable using a datascroller causes by zero exception

Hi

Is there a possibility to enhance the code of this method? My Problem is if
there the row attribute is missing in the datatable (using datascroller) you
will always get an "by zero" exception because of the line "if (
uiData.getFirst() % rows > 0)". It would be very helpfull to have a more
specific Exception.

Many thanks in advance.

class: HtmlDataScroller
/**
     * @return the page index of the uidata
     */
    public int getPageIndex()
    {
        UIData uiData = getUIData();
        int rows = uiData.getRows();
        int pageIndex;
        if (rows > 0)
        {
            pageIndex = uiData.getFirst() / rows + 1;
        }
        else
        {
            log.warn("DataTable " + uiData.getClientId(
FacesContext.getCurrentInstance())
                            + " has invalid rows attribute.");
            pageIndex = 0;
        }
        if (uiData.getFirst() % rows > 0)
        {
            pageIndex++;
        }
        return pageIndex;
    }


--
mfg Hans Sowa
mailto:hanssowa@gmail.com

Re: missing row attribute in a datatable using a datascroller causes by zero exception

Posted by Hans Sowa <ha...@gmail.com>.
Ah, super, thanks a lot. This is really helpfull.

2006/3/28, Mike Kienenberger <mk...@gmail.com>:
>
> Fixed as of March 1st.
>
> http://issues.apache.org/jira/browse/TOMAHAWK-104
>
> On 3/27/06, Hans Sowa <ha...@gmail.com> wrote:
> > Hi
> >
> > Is there a possibility to enhance the code of this method? My Problem is
> if
> > there the row attribute is missing in the datatable (using datascroller)
> you
> > will always get an "by zero" exception because of the line "if (
> > uiData.getFirst() % rows > 0)". It would be very helpfull to have a more
> > specific Exception.
> >
> > Many thanks in advance.
> >
> > class: HtmlDataScroller
> > /**
> >      * @return the page index of the uidata
> >      */
> >     public int getPageIndex()
> >     {
> >         UIData uiData = getUIData();
> >         int rows = uiData.getRows();
> >         int pageIndex;
> >         if (rows > 0)
> >         {
> >             pageIndex = uiData.getFirst () / rows + 1;
> >         }
> >         else
> >         {
> >             log.warn("DataTable " +
> > uiData.getClientId(FacesContext.getCurrentInstance())
> >                             + " has invalid rows attribute.");
> >             pageIndex = 0;
> >         }
> >         if (uiData.getFirst() % rows > 0)
> >         {
> >             pageIndex++;
> >         }
> >         return pageIndex;
> >     }
> >
> >
> > --
> > mfg Hans Sowa
> > mailto:hanssowa@gmail.com
>



--
mfg Hans Sowa
mailto:hanssowa@gmail.com

Re: missing row attribute in a datatable using a datascroller causes by zero exception

Posted by Mike Kienenberger <mk...@gmail.com>.
Fixed as of March 1st.

http://issues.apache.org/jira/browse/TOMAHAWK-104

On 3/27/06, Hans Sowa <ha...@gmail.com> wrote:
> Hi
>
> Is there a possibility to enhance the code of this method? My Problem is if
> there the row attribute is missing in the datatable (using datascroller) you
> will always get an "by zero" exception because of the line "if (
> uiData.getFirst() % rows > 0)". It would be very helpfull to have a more
> specific Exception.
>
> Many thanks in advance.
>
> class: HtmlDataScroller
> /**
>      * @return the page index of the uidata
>      */
>     public int getPageIndex()
>     {
>         UIData uiData = getUIData();
>         int rows = uiData.getRows();
>         int pageIndex;
>         if (rows > 0)
>         {
>             pageIndex = uiData.getFirst () / rows + 1;
>         }
>         else
>         {
>             log.warn("DataTable " +
> uiData.getClientId(FacesContext.getCurrentInstance())
>                             + " has invalid rows attribute.");
>             pageIndex = 0;
>         }
>         if (uiData.getFirst() % rows > 0)
>         {
>             pageIndex++;
>         }
>         return pageIndex;
>     }
>
>
> --
> mfg Hans Sowa
> mailto:hanssowa@gmail.com