You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Rui Pacheco <ru...@gmail.com> on 2006/05/23 15:26:38 UTC

Connecting Table to ResultSet

Hi all

I'm trying to create a table from the contrib package.

I have the html on my page as this:

<table jwcid="table@contrib:Table" source="ognl:dataItems"
columns="RegimeID, Description" pageSize="10">
<th>ID</th>
<th>Nome</th>
<th>&nbsp;</th>
</table>

I have setup my component to fill dataItems like this:

public void pageBeginRender(PageEvent event){

        list = new ArrayList();
        setModel(model);

        MySQLDAO mysql = new MySQLDAO(this.getDataSource(), model);
        ResultSet rs = mysql.selectRegime();

        if(rs != null){

            try{
                while(rs.next()){
                    list.add(rs.getInt("RegimeID"), rs.getString
("Description"));
                }
            }catch(Exception e){
                System.err.println(e.getMessage());
            }
        }

        setDataItems(list);
    }


The problem is, whenever I load my page, I can't see a thing. What is the
best way to connect my Table to my ResultSet?

-- 
Cumprimentos,
Rui Pacheco

Re: Connecting Table to ResultSet

Posted by Rui Pacheco <ru...@gmail.com>.
I did both of those. But for some reason I still can't get to my data.

I've created an inner class inside the class that mirrors my page, I made it
implement Serializable and I created getters and setters for the fields.
Now, I create an instance of that class for every row, stuff it inside my
List and put that list inside the setDataItems().

The only problem is, I am now seeing Serialization errors, as in, it can't
send the data from the bean to the page.


Btw, I am basing this code on this tutorial:
http://weblogs.java.net/blog/johnreynolds/archive/2004/10/learn_by_teachi_1.html

On 5/23/06, Barry Books <tr...@gmail.com> wrote:
>
> Most likely you did not specify your page implements
> PageBeginRenderListener
> (sp), but I think it's better just to declare a method public List
> getDataItems and put you query code in there.
>
>


-- 
Cumprimentos,
Rui Pacheco

Re: Connecting Table to ResultSet

Posted by Barry Books <tr...@gmail.com>.
Most likely you did not specify your page implements PageBeginRenderListener
(sp), but I think it's better just to declare a method public List
getDataItems and put you query code in there.