users@woodstock.java.net

How to Extract Data From CachedRowSetXImpl

From: Thomas Moorer <tcm527_at_yahoo.com>
Date: Tue, 4 Mar 2008 06:17:20 -0800 (PST)

Hi All,

I am new to the project Woodstock, but I really like what I see so far. I am experimenting in Netbeans 6.0.1 with the visual web components. I am currently most interested in the Data Table component. I have it bound to an oracle table just fine and I can sort and page without an issue. My question is I am working on application that will also need to export the table to either CSV or an Excel format. I already have a solution for exporting, but I am curious if I can extract the data from the table without having to go back to the database for the export. Preferably, I would also like to export it in the same sort order as it is currently being displayed.

In looking at the Netbeans generated code, I see in the init() block of the backing SessionBean it does,

    private void _init() throws Exception {
        petsRowSet.setDataSourceName("java:comp/env/jdbc/DB75401_Oracle");
        petsRowSet.setCommand("SELECT * FROM DB75401.PETS");
        petsRowSet.setTableName("PETS");
    }
    private CachedRowSetXImpl petsRowSet = new CachedRowSetXImpl();

In my export code, I can get the SessionBean,

        SessionBean1 petsBean = (SessionBean1)session.getAttribute("SessionBean1");
        CachedRowSetXImpl petsRowSet = petsBean.getPetsRowSet();

and then loop through it using either of the techniques below, but neither maintain the sort order as it appears in the table being displayed.

        //original result set
        ResultSet rs = petsRowSet.getOriginal();
        
        //loop through current pages
        while (petsRowSet.nextPage()) {
            while (petsRowSet.next()) {
                
            }
        }

Is it possible to do what I want?

Thanks,
Thomas
 
Thomas C. Moorer, Jr.
email: tcm527_at_yahoo.com




      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ