Thanks a lot. I think that it could be something like that:

    public static List dataTableAsList(HtmlDataTable dataTable) {
        List rows = new ArrayList();
        List columns;
        for (int i = 0; i < dataTable.getRowCount(); i++) {
            dataTable.setRowIndex(i);            
            columns = new ArrayList();
            Iterator iter = dataTable.getChildren().iterator();
            while (iter.hasNext()) {
                UIComponent column = (UIComponent) iter.next();
                Iterator columnChildren = column.getChildren().iterator();
                while (columnChildren.hasNext()) {
                    UIComponent child = (UIComponent) columnChildren.next();
                    if (child instanceof HtmlOutputText) {
                        columns.add(((HtmlOutputText) child).getValue());
                    }
                }
            }
            rows.add(columns);
        }    
        return rows;
    }


PK 

-----Original Message-----
From: Mike Kienenberger [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 17, 2005 4:38 PM
To: MyFaces Discussion
Subject: Re: How to get cell value from HtmlDataTable?

You can iterate over the rows using HtmlDataTable.setRowIndex(rowIndex).
To iterate over the columns, you'd have to provide your own custom logic, or
you would have to wander through the children and facets of the table
looking for appropriate components (like h:column and t:column and then
somehow pick out your data from the children of those column components).

If it were me, I'd use a single t:columns (with an 's') component instead of
groups of h:column or t:column components to represent all
of your columns.   columns is a UIData component just like
HtmlDataTable, and you can use it to iterate through your columns in the
same way that you iterate through your rows (setRowIndex() is really
setColumnIndex() for t:columns).

-Mike

On 8/17/05, Kołoszko Paweł <[EMAIL PROTECTED]> wrote:
> I would like to iterate over HtmlDataTable and get value stored in 
> each cell. How can I do this?
> 
> Paweł Kołoszko
>

Reply via email to