dev@woodstock.java.net

Re: Woodstock table with Seam ?

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Mon, 13 Aug 2007 11:11:19 -0400

Padraig Byrne wrote:
> Current situation is I have seam, richfaces & facelets with entity beans generated by seamgen but I like functionality of woodstock table (& some other components), which uses dataprovider as backend for table as far as I can see.
>
> seam gen generates beans which extend entityQuery beans & which I can directly connect woodstock table & perform sort functionailty out of the box but when I want to add filtering etc all the example use helper classes which are based on dataprovider ( eg filtercriteria ) I am trying to get a detailed understanding of this table & dataproviders & compatibility with entity beans
>

Although the Woodstock table makes use of DataProvider, it is a separate
jar created by the Netbeans Visual Web Pack
<http://www.netbeans.org/products/visualweb> folks. Go to that site and
click on the "contact" link and select Mailing List FAQ
<http://wiki.netbeans.info/wiki/view/NetBeansUserFAQ#section-NetBeansUserFAQ-MailingLists>.
Once there, you'll find a lot of information regarding database
connectivity; however, if that does not answer your questions, you can
direct DataProvoder queries to the VWP team by clicking the "contact us"
link.

Below is a snippet from an old FAQ which may be useful -- the pointer to
the APIs is particularly helpful. Note that you can also replace the
Table's default sort mechanism via the tableDataSorter tag
attribute/component property (i.e., if you want your database to do the
work). The TableDataSorter class is also found in the
com.sun.data.provider package.

   1.


              Can I use an SQL database as the data source for the Table
              component? I want to use data from an object of type
              java.sql.ResultSet. Back to top
              <http://lockhart.east/console/v3_0/docs/faq-jsf-components.html#top>

      Yes. You need to use the following classes:

          *

            |CachedRowSetDataProvider|, contained in the
            |dataprovider.jar| which is provided with the Sun Java Web
            UI component download. ||

          *

            |CachedRowSetImpl|, contained in |rowset.jar|, which is
            available in Sun Java Studio Creator, or can be downloaded
            from Sun Developer Network.
            <http://java.sun.com/products/jdbc/download.html#rowsetcobundle1_0>
            The |rowset.jar| has a dependency on |sqlx.jar| which is
            provided both in Creator and in the dependent jar download
            <http://lockhart.east/v3_0/download/braveheart/archive/SunJavaWebUserInterfaceComponents_DependentLibs.3.0-20051202.1816.jar>
            of external jars needed by the components.

      You can see the javadoc for the dataprovider API
      <http://developers.sun.com/prodtech/javatools/jscreator/reference/docs/apis/dataprovider/index.html>
      and javadoc for RowSet API
      <http://developers.sun.com/prodtech/javatools/jscreator/reference/docs/apis/rowset/index.html>
      on the Sun Developer Network.

      The <ui:tableRowGroup> tag's |sourceData| attribute can be bound
      to an object of type |com.sun.data.provider.TableDataProvider|.

      The| com.sun.data.provider.impl.CachedRowSetDataProvider|
      implements |TableDataProvider| interface. The
      |java.sql.ResultSet| object can be transformed into
      |CachedRowSetDataProvider|, using |com.sun.rowset.CachedRowSetImpl|.

      Sample code snippet:


            | //java.sql.ResultSet|
      | ResultSet rs;|
      | .. |
      | ..|
      | //com.sun.rowset.CachedRowSetImpl from rowset.jar|
      | CachedRowSetImpl rslh = new CachedRowSetImpl();|
      | rslh.populate(rs);|
      | |
      | //com.sun.data.provider.impl.CachedRowSetDataProvider
      from dataprovider.jar|
      | CachedRowSetDataProvider model = new
      CachedRowSetDataProvider(rslh);
      |

> On woodstock table, sorting etc is there any detailed document on how this works when filering sorting etc & what is the best forum to put
> these questions ?
>

Build the webui module of the Woodstock repository and view the TLD docs
for Table, TableRowGroup, and TableColumn. These TLD docs have several
examples each. In particular, you'll find information about sorting in
the TableCoulmn doc. Examples of advanced sorting and filtering can be
found in in the Table and TableRowGroup docs These examples can also be
found live at:

    https://woodstock.dev.java.net/Preview.htm

Dan