Hi Thufir,

the TD instances of course have to get added to the tr instance, not to the table, so something like the following should bring the requested result:

for (SyndEntry syndEntry : rows) {
    TR row = new TR();
    row.setPrettyPrint(isPretty);
    table.addElement(row);

    TD title = new TD();
    title.setPrettyPrint(isPretty);
    title.addElement(syndEntry.getTitle());
    row.addElement(title);

    TD link = new TD();
    link.setPrettyPrint(isPretty);
    link.addElement(syndEntry.getLink());
    row.addElement(link);
}

doc.appendBody(table);

Greetings,

Martin



Thufir schrieb:
Possibly it's a weakness with HTML, but I can't seem to get results which make sense. What I want to do is something like:

get a bean, representing a row

each bean attribute corresponds to a TD instance?
Loop through the List of attributes and:

add each TD instance to TR, right now I'm adding directly to the table.

add the TR to the table

go to the next element in the list



if my Java is weak, or generics are wrong, please let that go. I'm just trying to generate a table at the moment (in a servlet).



code snippet:


        for (SyndEntry syndEntry : rows) {
            TR row = new TR();
            row.setPrettyPrint(isPretty);  //need to set props file
            TD title = new TD();
            title.setPrettyPrint(isPretty);
            TD link = new TD();
            link.setPrettyPrint(isPretty);
            List<TD> tds = new ArrayList<TD>();

            title.addElement(syndEntry.getTitle());
            link.addElement(syndEntry.getLink());
            tds.add(link);
            tds.add(title);

            table.addElement(row);  //why doesn't this go last?
                                    //why not add the TD obj's
                                    //to the row?
for(TD td : tds){
                td.setPrettyPrint(isPretty);
                table.addElement(td);       //this seems wrong
            }
        }


        doc.appendBody(table);




the above works, but it seems clumsy. Of course, I'm mixing the view in with everything else at the moment, but ignoring that for now, pls.


thanks,

Thufir


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to