You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jakob Korherr <ja...@gmail.com> on 2010/01/27 11:17:13 UTC

Re: Re: Re: Customizing scroller by using t:dataTable with t:dataScroller

Take a look at the tomahawk example
http://example.irian.at/example-simple-2010012702/pagedSortTable.jsf

you can use the binding attribute of the t:dataTable to get a reference to
the component in your managed bean like this: binding="#{myBean.uidata}".
Then you can use UIData.getFirst() to get the index of the first element on
the page, but I guess you already know that.

Futhermore you can set an actionListener on the t:commandSortHeader:
actionListener="#{myBean.actionListener}" with the method in the managed
bean:

    public void actionListener(ActionEvent e)
    {
        int first = uidata.getFirst();
        List<SimpleCar> list = (List<SimpleCar>) uidata.getValue();
        SimpleCar firstItemOnPage = list.get(first);
    }

Now you have your first displayed item on the page.

I hope this helps!

Regards,
Jakob

2010/1/27 Klaus SCHUSTER <sc...@racon-linz.at>

> yes right, I am using sortColumn attribute together with
> t:commandSortHeader.
> maybe a chance to use the setter of the sortColumn attribute... but in
> this case I can't use the UIData.getFirst(), I have to calculate the right
> index of the collection for myself.
>
>
>
>
> Jakob Korherr <ja...@gmail.com>
> Gesendet von: sethfromaustria@gmail.com
> 27.01.2010 10:37
> Bitte antworten an
> "MyFaces Discussion" <us...@myfaces.apache.org>
>
>
> An
> MyFaces Discussion <us...@myfaces.apache.org>
> Kopie
>
> Thema
> Re: Re: Customizing scroller by using t:dataTable with t:dataScroller
>
>
>
>
>
>
> Ok, and how are you sorting your t:dataTable? Are you using sortColumn and
> t:commandSortHeader or another hack?
>
> Regards,
> Jakob
>
> 2010/1/27 Klaus SCHUSTER <sc...@racon-linz.at>
>
> > Hi jakob,
> > thanks for the reply.
> > I need the index of the collection, of the first shown element on the
> > page.
> > If I navigate to the 3rd page of the dataTable, the UIData.getFirst()
> > gives me the index of the first shown item in the Collection from the
> 3rd
> > page.
> > This works well, but I can sort the table by klicking on the header of
> the
> > rows. If I click on sorting, the whole collection is sorted, and
> splittet
> > to the shown pages.
> > UIData.getFirst() gives me the same results, as I had before without
> > sorting.
> > Thanks,
> > Klaus
> >
> >
> >
> >
> > Jakob Korherr <ja...@gmail.com>
> > Gesendet von: sethfromaustria@gmail.com
> > 26.01.2010 22:06
> > Bitte antworten an
> > "MyFaces Discussion" <us...@myfaces.apache.org>
> >
> >
> > An
> > MyFaces Discussion <us...@myfaces.apache.org>
> > Kopie
> >
> > Thema
> > Re: Customizing scroller by using t:dataTable with t:dataScroller
> >
> >
> >
> >
> >
> >
> > Hi Klaus,
> >
> > I'm not sure if I understand your problem. What index do you need? The
> > index
> > of the first item, which is currently displayed?
> >
> > Please provide a little bit more information about the problem, maybe
> also
> > a
> > JSP snippet.
> >
> > Regards,
> > Jakob
> >
> > 2010/1/26 Klaus SCHUSTER <sc...@racon-linz.at>
> >
> > > I tried to get the UIData.getFirst() for the first index. this is ok,
> > but
> > > there is no chance to get the right index of the collection if the
> data
> > is
> > > sorted again.
> > > Is there any action event on clicking the row subject for sorting?
> > >
> > >
> > >
> > >
> > > Klaus SCHUSTER <sc...@racon-linz.at>
> > > 22.01.2010 07:27
> > > Bitte antworten an
> > > "MyFaces Discussion" <us...@myfaces.apache.org>
> > >
> > >
> > > An
> > > users@myfaces.apache.org
> > > Kopie
> > >
> > > Thema
> > > Customizing scroller by using t:dataTable with t:dataScroller
> > >
> > >
> > >
> > >
> > >
> > >
> > > Hello,
> > >
> > > I'm using a t:dataTable attached to a t:dataScroller. Currently, the
> > > t:dataScroller shows the navigation buttons and a list of page numbers
> > > (e.g.: first, previous 1 2 3 etc).
> > > I am using a collection in my t:dataTable by the attribute value=...
> > > The Scroller shows me only 10 items of the full Collection.
> > > My question is: How can I have access to the 10 shown items ? I only
> > have
> > > my whole list in the backing bean.
> > >
> > > The second question is, what happens if I sort the elements, can I get
> > the
> > >
> > > shown items also in a sorted way?
> > > Thanks,
> > >
> > > Klaus
> > >
> > >
> > >
> > >
> > > Der Austausch von Nachrichten mit o.a. Absender via e-mail dient
> > > ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen
> > dürfen
> > > über dieses Medium nicht ausgetauscht werden.
> > >
> > > Correspondence with a.m. sender via e-mail is only for information
> > > purposes. This medium is not to be used for the exchange of
> > > legally-binding communications.
> > >
> > >
> > >
> > >
> > >
> > > Der Austausch von Nachrichten mit o.a. Absender via e-mail dient
> > > ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen
> > dürfen
> > > über dieses Medium nicht ausgetauscht werden.
> > >
> > > Correspondence with a.m. sender via e-mail is only for information
> > > purposes. This medium is not to be used for the exchange of
> > legally-binding
> > > communications.
> > >
> >
> >
> >
> >
> >
> > Der Austausch von Nachrichten mit o.a. Absender via e-mail dient
> > ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen
> dürfen
> > über dieses Medium nicht ausgetauscht werden.
> >
> > Correspondence with a.m. sender via e-mail is only for information
> > purposes. This medium is not to be used for the exchange of
> legally-binding
> > communications.
> >
>
>
>
>
>
> Der Austausch von Nachrichten mit o.a. Absender via e-mail dient
> ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen dürfen
> über dieses Medium nicht ausgetauscht werden.
>
> Correspondence with a.m. sender via e-mail is only for information
> purposes. This medium is not to be used for the exchange of legally-binding
> communications.
>

Antwort: Re: Re: Re: Customizing scroller by using t:dataTable with t:dataScroller

Posted by Klaus SCHUSTER <sc...@racon-linz.at>.
Hi,
Thanks, for the actionListener tip in the t:commandSortHeader.
The only question I have: where do you get the uidata in the 
actionListener from?
Because the only uidata I have stored is from the HTMLDataTable, and this 
index (by using getFirst()) is again, the index of the whole unsorted 
collection.
Is there any other binding necessary, from where I get another uidata with 
the info of the first sorted element of the collection?
thanks,
Klaus





Jakob Korherr <ja...@gmail.com> 
Gesendet von: sethfromaustria@gmail.com
27.01.2010 11:17
Bitte antworten an
"MyFaces Discussion" <us...@myfaces.apache.org>


An
MyFaces Discussion <us...@myfaces.apache.org>
Kopie

Thema
Re: Re: Re: Customizing scroller by using t:dataTable with t:dataScroller






Take a look at the tomahawk example
http://example.irian.at/example-simple-2010012702/pagedSortTable.jsf

you can use the binding attribute of the t:dataTable to get a reference to
the component in your managed bean like this: binding="#{myBean.uidata}".
Then you can use UIData.getFirst() to get the index of the first element 
on
the page, but I guess you already know that.

Futhermore you can set an actionListener on the t:commandSortHeader:
actionListener="#{myBean.actionListener}" with the method in the managed
bean:

    public void actionListener(ActionEvent e)
    {
        int first = uidata.getFirst();
        List<SimpleCar> list = (List<SimpleCar>) uidata.getValue();
        SimpleCar firstItemOnPage = list.get(first);
    }

Now you have your first displayed item on the page.

I hope this helps!

Regards,
Jakob

2010/1/27 Klaus SCHUSTER <sc...@racon-linz.at>

> yes right, I am using sortColumn attribute together with
> t:commandSortHeader.
> maybe a chance to use the setter of the sortColumn attribute... but in
> this case I can't use the UIData.getFirst(), I have to calculate the 
right
> index of the collection for myself.
>
>
>
>
> Jakob Korherr <ja...@gmail.com>
> Gesendet von: sethfromaustria@gmail.com
> 27.01.2010 10:37
> Bitte antworten an
> "MyFaces Discussion" <us...@myfaces.apache.org>
>
>
> An
> MyFaces Discussion <us...@myfaces.apache.org>
> Kopie
>
> Thema
> Re: Re: Customizing scroller by using t:dataTable with t:dataScroller
>
>
>
>
>
>
> Ok, and how are you sorting your t:dataTable? Are you using sortColumn 
and
> t:commandSortHeader or another hack?
>
> Regards,
> Jakob
>
> 2010/1/27 Klaus SCHUSTER <sc...@racon-linz.at>
>
> > Hi jakob,
> > thanks for the reply.
> > I need the index of the collection, of the first shown element on the
> > page.
> > If I navigate to the 3rd page of the dataTable, the UIData.getFirst()
> > gives me the index of the first shown item in the Collection from the
> 3rd
> > page.
> > This works well, but I can sort the table by klicking on the header of
> the
> > rows. If I click on sorting, the whole collection is sorted, and
> splittet
> > to the shown pages.
> > UIData.getFirst() gives me the same results, as I had before without
> > sorting.
> > Thanks,
> > Klaus
> >
> >
> >
> >
> > Jakob Korherr <ja...@gmail.com>
> > Gesendet von: sethfromaustria@gmail.com
> > 26.01.2010 22:06
> > Bitte antworten an
> > "MyFaces Discussion" <us...@myfaces.apache.org>
> >
> >
> > An
> > MyFaces Discussion <us...@myfaces.apache.org>
> > Kopie
> >
> > Thema
> > Re: Customizing scroller by using t:dataTable with t:dataScroller
> >
> >
> >
> >
> >
> >
> > Hi Klaus,
> >
> > I'm not sure if I understand your problem. What index do you need? The
> > index
> > of the first item, which is currently displayed?
> >
> > Please provide a little bit more information about the problem, maybe
> also
> > a
> > JSP snippet.
> >
> > Regards,
> > Jakob
> >
> > 2010/1/26 Klaus SCHUSTER <sc...@racon-linz.at>
> >
> > > I tried to get the UIData.getFirst() for the first index. this is 
ok,
> > but
> > > there is no chance to get the right index of the collection if the
> data
> > is
> > > sorted again.
> > > Is there any action event on clicking the row subject for sorting?
> > >
> > >
> > >
> > >
> > > Klaus SCHUSTER <sc...@racon-linz.at>
> > > 22.01.2010 07:27
> > > Bitte antworten an
> > > "MyFaces Discussion" <us...@myfaces.apache.org>
> > >
> > >
> > > An
> > > users@myfaces.apache.org
> > > Kopie
> > >
> > > Thema
> > > Customizing scroller by using t:dataTable with t:dataScroller
> > >
> > >
> > >
> > >
> > >
> > >
> > > Hello,
> > >
> > > I'm using a t:dataTable attached to a t:dataScroller. Currently, the
> > > t:dataScroller shows the navigation buttons and a list of page 
numbers
> > > (e.g.: first, previous 1 2 3 etc).
> > > I am using a collection in my t:dataTable by the attribute value=...
> > > The Scroller shows me only 10 items of the full Collection.
> > > My question is: How can I have access to the 10 shown items ? I only
> > have
> > > my whole list in the backing bean.
> > >
> > > The second question is, what happens if I sort the elements, can I 
get
> > the
> > >
> > > shown items also in a sorted way?
> > > Thanks,
> > >
> > > Klaus
> > >
> > >
> > >
> > >
> > > Der Austausch von Nachrichten mit o.a. Absender via e-mail dient
> > > ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen
> > dürfen
> > > über dieses Medium nicht ausgetauscht werden.
> > >
> > > Correspondence with a.m. sender via e-mail is only for information
> > > purposes. This medium is not to be used for the exchange of
> > > legally-binding communications.
> > >
> > >
> > >
> > >
> > >
> > > Der Austausch von Nachrichten mit o.a. Absender via e-mail dient
> > > ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen
> > dürfen
> > > über dieses Medium nicht ausgetauscht werden.
> > >
> > > Correspondence with a.m. sender via e-mail is only for information
> > > purposes. This medium is not to be used for the exchange of
> > legally-binding
> > > communications.
> > >
> >
> >
> >
> >
> >
> > Der Austausch von Nachrichten mit o.a. Absender via e-mail dient
> > ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen
> dürfen
> > über dieses Medium nicht ausgetauscht werden.
> >
> > Correspondence with a.m. sender via e-mail is only for information
> > purposes. This medium is not to be used for the exchange of
> legally-binding
> > communications.
> >
>
>
>
>
>
> Der Austausch von Nachrichten mit o.a. Absender via e-mail dient
> ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen 
dürfen
> über dieses Medium nicht ausgetauscht werden.
>
> Correspondence with a.m. sender via e-mail is only for information
> purposes. This medium is not to be used for the exchange of 
legally-binding
> communications.
>





Der Austausch von Nachrichten mit o.a. Absender via e-mail dient ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen dürfen über dieses Medium nicht ausgetauscht werden.

Correspondence with a.m. sender via e-mail is only for information purposes. This medium is not to be used for the exchange of legally-binding communications.