You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Tom Butler <to...@adelphia.net> on 2005/12/28 22:27:36 UTC

Tomahawk DataTable Sort Question - where/how is Sort Coded?

Can someone please help me to understand how to configure or code a column
sort for a Tomahawk datatable?  Specifically, I'm not clear on how or what
sort method is called?  Do the Tomahawk components take care of the sort for
me, or do I need to code the sort myself (and if so where)?

 

I think I have the JSP coded correctly:

<t:dataTable id="data" styleClass="scrollerTable"

var="providers" 

value="#{searchproviders_bean.arrlist_providers}" 

preserveDataModel="false" 

rows="20"

sortColumn="#{searchproviders_bean.sortcolumn}"

sortAscending="#{searchproviders_bean.sortascending}"

preserveSort="true">                                  

 


<h:column>

<f:facet name="header">

      <t:commandSortHeader columnName="id" arrow="true" immediate="false">

            h:outputText value="#{messages['sort_id']}" />

      </t:commandSortHeader>

</f:facet>

<h:outputText value="#{providers.id}" />

</h:column>

<h:column>

<f:facet name="header">

      <t:commandSortHeader columnName="category" arrow="true"
immediate="false">

            <h:outputText value="#{messages['sort_category']}" />

      </t:commandSortHeader>

</f:facet>

<h:outputText value="#{providers.category}" />

</h:column>

</t:dataTable>

 

'searchproviders_bean'  is the backing bean, and 'arrlist_providers' is an
ArrayList.  The ArrayList is initially sorted when it is retrieved from the
database.  After the data is retrieved, I disconnect from the database.  The
data in the ArrayList will be read-only (will contain search results list -
the data is not updateable.)   When the data is displayed to the user, I
want them to be able to sort the data by clicking on the column headings.  

 

I have also added the 'sortcolumn' and 'sortascending' properties to the
backing bean as strings with the appropriate getter/setter methods:

 

public class searchproviders_bean {

    private ArrayList arrlist_providers;

    private String sortcol;

    private String sortascending;

...

 

 

The part where I am confused is how to implement the sort method.  I know
that the ArrayList gets 'wrapped' by a DataModel object (though I only
understand this at a high-level), but I'm not sure how to configure or code
the sort?  Does the Tomahawk DataModel implement the sort or do I need to
code the sort?  If I need to code the sort, can someone please help me to
understand where to implement this method and provide any helpful code
examples?

 

BTW, currently, the datatable is displaying, but when I click on the column
headings, the data does not sort (but the arrows on the column header change
directions.)  Also, I do have a datascroller connected to the datatable that
is working correctly:

 

 

Thanks

Tom

 

 

 

 


Re: Tomahawk DataTable Sort Question - where/how is Sort Coded?

Posted by Thomas Spiegl <th...@gmail.com>.
No, that's not possible.

On 12/29/05, Sébastien Marin <th...@free.fr> wrote:
> I try to use the datatable sort.
> Is it possible to make the sort on client side (no access server)?
>
> Selon Thomas Spiegl <th...@gmail.com>:
>
> -> Sort your data in getArrlist_providers depending on the values of
> -> sortcol and sortascending.
> -> Collections.sort(arrlist_providers, YourComparator) may sort the list.
> ->
> -> Regards
> -> Thomas
> ->
> -> On 12/28/05, Tom Butler <to...@adelphia.net> wrote:
> -> >
> -> >
> -> >
> -> > Can someone please help me to understand how to configure or code a column
> -> > sort for a Tomahawk datatable?  Specifically, I'm not clear on how or what
> -> > sort method is called?  Do the Tomahawk components take care of the sort
> -> for
> -> > me, or do I need to code the sort myself (and if so where)?
> -> >
> -> >
> -> >
> -> > I think I have the JSP coded correctly:
> -> >
> -> > <t:dataTable id="data" styleClass="scrollerTable"
> -> >
> -> > var="providers"
> -> >
> -> > value="#{searchproviders_bean.arrlist_providers}"
> -> >
> -> > preserveDataModel="false"
> -> >
> -> > rows="20"
> -> >
> -> > sortColumn="#{searchproviders_bean.sortcolumn}"
> -> >
> -> > sortAscending="#{searchproviders_bean.sortascending}"
> -> >
> -> > preserveSort="true">
> -> >
> -> >
> -> >
> -> >
> -> > <h:column>
> -> >
> -> > <f:facet name="header">
> -> >
> -> >       <t:commandSortHeader columnName="id" arrow="true" immediate="false">
> -> >
> -> >             h:outputText value="#{messages['sort_id']}" />
> -> >
> -> >       </t:commandSortHeader>
> -> >
> -> > </f:facet>
> -> >
> -> > <h:outputText value="#{providers.id}" />
> -> >
> -> > </h:column>
> -> >
> -> > <h:column>
> -> >
> -> > <f:facet name="header">
> -> >
> -> >       <t:commandSortHeader columnName="category" arrow="true"
> -> > immediate="false">
> -> >
> -> >             <h:outputText value="#{messages['sort_category']}" />
> -> >
> -> >       </t:commandSortHeader>
> -> >
> -> > </f:facet>
> -> >
> -> > <h:outputText value="#{providers.category}" />
> -> >
> -> > </h:column>
> -> >
> -> > </t:dataTable>
> -> >
> -> >
> -> >
> -> > 'searchproviders_bean'  is the backing bean, and 'arrlist_providers' is an
> -> > ArrayList.  The ArrayList is initially sorted when it is retrieved from
> -> the
> -> > database.  After the data is retrieved, I disconnect from the database.
> -> The
> -> > data in the ArrayList will be read-only (will contain search results list
> -> –
> -> > the data is not updateable.)   When the data is displayed to the user, I
> -> > want them to be able to sort the data by clicking on the column headings.
> -> >
> -> >
> -> >
> -> > I have also added the 'sortcolumn' and 'sortascending' properties to the
> -> > backing bean as strings with the appropriate getter/setter methods:
> -> >
> -> >
> -> >
> -> > public class searchproviders_bean {
> -> >
> -> >     private ArrayList arrlist_providers;
> -> >
> -> >     private String sortcol;
> -> >
> -> >     private String sortascending;
> -> >
> -> > …..
> -> >
> -> >
> -> >
> -> >
> -> >
> -> > The part where I am confused is how to implement the sort method.  I know
> -> > that the ArrayList gets 'wrapped' by a DataModel object (though I only
> -> > understand this at a high-level), but I'm not sure how to configure or
> -> code
> -> > the sort?  Does the Tomahawk DataModel implement the sort or do I need to
> -> > code the sort?  If I need to code the sort, can someone please help me to
> -> > understand where to implement this method and provide any helpful code
> -> > examples?
> -> >
> -> >
> -> >
> -> > BTW, currently, the datatable is displaying, but when I click on the
> -> column
> -> > headings, the data does not sort (but the arrows on the column header
> -> change
> -> > directions.)  Also, I do have a datascroller connected to the datatable
> -> that
> -> > is working correctly:
> -> >
> -> >
> -> >
> -> >
> -> >
> -> > Thanks
> -> >
> -> > Tom
> -> >
> -> >
> -> >
> -> >
> -> >
> -> >
> -> >
> -> >
> ->
> ->
> -> --
> -> http://www.irian.at
> ->
> -> Your JSF powerhouse -
> -> JSF Consulting, Development and
> -> Courses in English and German
> ->
> -> Professional Support for Apache MyFaces
> ->
>
>
> |Cordialement, Sébastien MARIN.|
> |------------------------------|
> |->  http://www.marin-s.com  <-|
> |------------------------------|
>


--
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: Tomahawk DataTable Sort Question - where/how is Sort Coded?

Posted by Sébastien Marin <th...@free.fr>.
I try to use the datatable sort.
Is it possible to make the sort on client side (no access server)?

Selon Thomas Spiegl <th...@gmail.com>:

-> Sort your data in getArrlist_providers depending on the values of
-> sortcol and sortascending.
-> Collections.sort(arrlist_providers, YourComparator) may sort the list.
->
-> Regards
-> Thomas
->
-> On 12/28/05, Tom Butler <to...@adelphia.net> wrote:
-> >
-> >
-> >
-> > Can someone please help me to understand how to configure or code a column
-> > sort for a Tomahawk datatable?  Specifically, I'm not clear on how or what
-> > sort method is called?  Do the Tomahawk components take care of the sort
-> for
-> > me, or do I need to code the sort myself (and if so where)?
-> >
-> >
-> >
-> > I think I have the JSP coded correctly:
-> >
-> > <t:dataTable id="data" styleClass="scrollerTable"
-> >
-> > var="providers"
-> >
-> > value="#{searchproviders_bean.arrlist_providers}"
-> >
-> > preserveDataModel="false"
-> >
-> > rows="20"
-> >
-> > sortColumn="#{searchproviders_bean.sortcolumn}"
-> >
-> > sortAscending="#{searchproviders_bean.sortascending}"
-> >
-> > preserveSort="true">
-> >
-> >
-> >
-> >
-> > <h:column>
-> >
-> > <f:facet name="header">
-> >
-> >       <t:commandSortHeader columnName="id" arrow="true" immediate="false">
-> >
-> >             h:outputText value="#{messages['sort_id']}" />
-> >
-> >       </t:commandSortHeader>
-> >
-> > </f:facet>
-> >
-> > <h:outputText value="#{providers.id}" />
-> >
-> > </h:column>
-> >
-> > <h:column>
-> >
-> > <f:facet name="header">
-> >
-> >       <t:commandSortHeader columnName="category" arrow="true"
-> > immediate="false">
-> >
-> >             <h:outputText value="#{messages['sort_category']}" />
-> >
-> >       </t:commandSortHeader>
-> >
-> > </f:facet>
-> >
-> > <h:outputText value="#{providers.category}" />
-> >
-> > </h:column>
-> >
-> > </t:dataTable>
-> >
-> >
-> >
-> > 'searchproviders_bean'  is the backing bean, and 'arrlist_providers' is an
-> > ArrayList.  The ArrayList is initially sorted when it is retrieved from
-> the
-> > database.  After the data is retrieved, I disconnect from the database.
-> The
-> > data in the ArrayList will be read-only (will contain search results list
-> –
-> > the data is not updateable.)   When the data is displayed to the user, I
-> > want them to be able to sort the data by clicking on the column headings.
-> >
-> >
-> >
-> > I have also added the 'sortcolumn' and 'sortascending' properties to the
-> > backing bean as strings with the appropriate getter/setter methods:
-> >
-> >
-> >
-> > public class searchproviders_bean {
-> >
-> >     private ArrayList arrlist_providers;
-> >
-> >     private String sortcol;
-> >
-> >     private String sortascending;
-> >
-> > …..
-> >
-> >
-> >
-> >
-> >
-> > The part where I am confused is how to implement the sort method.  I know
-> > that the ArrayList gets 'wrapped' by a DataModel object (though I only
-> > understand this at a high-level), but I'm not sure how to configure or
-> code
-> > the sort?  Does the Tomahawk DataModel implement the sort or do I need to
-> > code the sort?  If I need to code the sort, can someone please help me to
-> > understand where to implement this method and provide any helpful code
-> > examples?
-> >
-> >
-> >
-> > BTW, currently, the datatable is displaying, but when I click on the
-> column
-> > headings, the data does not sort (but the arrows on the column header
-> change
-> > directions.)  Also, I do have a datascroller connected to the datatable
-> that
-> > is working correctly:
-> >
-> >
-> >
-> >
-> >
-> > Thanks
-> >
-> > Tom
-> >
-> >
-> >
-> >
-> >
-> >
-> >
-> >
->
->
-> --
-> http://www.irian.at
->
-> Your JSF powerhouse -
-> JSF Consulting, Development and
-> Courses in English and German
->
-> Professional Support for Apache MyFaces
->


|Cordialement, Sébastien MARIN.|
|------------------------------|
|->  http://www.marin-s.com  <-|
|------------------------------|

Re: Tomahawk DataTable Sort Question - where/how is Sort Coded?

Posted by Thomas Spiegl <th...@gmail.com>.
Sort your data in getArrlist_providers depending on the values of
sortcol and sortascending.
Collections.sort(arrlist_providers, YourComparator) may sort the list.

Regards
Thomas

On 12/28/05, Tom Butler <to...@adelphia.net> wrote:
>
>
>
> Can someone please help me to understand how to configure or code a column
> sort for a Tomahawk datatable?  Specifically, I'm not clear on how or what
> sort method is called?  Do the Tomahawk components take care of the sort for
> me, or do I need to code the sort myself (and if so where)?
>
>
>
> I think I have the JSP coded correctly:
>
> <t:dataTable id="data" styleClass="scrollerTable"
>
> var="providers"
>
> value="#{searchproviders_bean.arrlist_providers}"
>
> preserveDataModel="false"
>
> rows="20"
>
> sortColumn="#{searchproviders_bean.sortcolumn}"
>
> sortAscending="#{searchproviders_bean.sortascending}"
>
> preserveSort="true">
>
>
>
>
> <h:column>
>
> <f:facet name="header">
>
>       <t:commandSortHeader columnName="id" arrow="true" immediate="false">
>
>             h:outputText value="#{messages['sort_id']}" />
>
>       </t:commandSortHeader>
>
> </f:facet>
>
> <h:outputText value="#{providers.id}" />
>
> </h:column>
>
> <h:column>
>
> <f:facet name="header">
>
>       <t:commandSortHeader columnName="category" arrow="true"
> immediate="false">
>
>             <h:outputText value="#{messages['sort_category']}" />
>
>       </t:commandSortHeader>
>
> </f:facet>
>
> <h:outputText value="#{providers.category}" />
>
> </h:column>
>
> </t:dataTable>
>
>
>
> 'searchproviders_bean'  is the backing bean, and 'arrlist_providers' is an
> ArrayList.  The ArrayList is initially sorted when it is retrieved from the
> database.  After the data is retrieved, I disconnect from the database.  The
> data in the ArrayList will be read-only (will contain search results list –
> the data is not updateable.)   When the data is displayed to the user, I
> want them to be able to sort the data by clicking on the column headings.
>
>
>
> I have also added the 'sortcolumn' and 'sortascending' properties to the
> backing bean as strings with the appropriate getter/setter methods:
>
>
>
> public class searchproviders_bean {
>
>     private ArrayList arrlist_providers;
>
>     private String sortcol;
>
>     private String sortascending;
>
> …..
>
>
>
>
>
> The part where I am confused is how to implement the sort method.  I know
> that the ArrayList gets 'wrapped' by a DataModel object (though I only
> understand this at a high-level), but I'm not sure how to configure or code
> the sort?  Does the Tomahawk DataModel implement the sort or do I need to
> code the sort?  If I need to code the sort, can someone please help me to
> understand where to implement this method and provide any helpful code
> examples?
>
>
>
> BTW, currently, the datatable is displaying, but when I click on the column
> headings, the data does not sort (but the arrows on the column header change
> directions.)  Also, I do have a datascroller connected to the datatable that
> is working correctly:
>
>
>
>
>
> Thanks
>
> Tom
>
>
>
>
>
>
>
>


--
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces