You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ecs-user@jakarta.apache.org by Thufir <ha...@gmail.com> on 2009/02/22 07:56:22 UTC
learning API for table
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: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org
Re: learning API for table
Posted by "Zachary Mitchell, BCIS" <za...@internode.on.net>.
Mate,
IMHO, having a bean/java object
for something as trivial as an HTML
TD with text contents
really isn't worth the overhead
you'll incur for each row of your table.
Consider Having one bean for the entire table,
and something like a LinkedList,
with each node in that each td.
Just an opinon, unless
there's more going on with your program!
Zac, Australia.
----- Original Message -----
From: "Thufir" <ha...@gmail.com>
To: <ec...@jakarta.apache.org>
Sent: Sunday, February 22, 2009 5:26 PM
Subject: learning API for table
> 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: ecs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ecs-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org
Re: learning API for table
Posted by Martin Kurz <in...@martinkurz.com>.
Hi Thufir,
> The next thing I should work on are CRUD operations for a table. I
> notice mouse over event listeners and so forth in the API. ECS is not
> dissimilar from Swing?
the goal of ecs is, making the building of html in java code easier by
working with object instances instead of concatenating with lots of
Strings. If you're planning to build an CRUD webapp, maybe you should
have a look for JSF, ie the myfaces libs like tobago
(http://myfaces.apache.org/tobago/). There you'll find actions and
events without having to care about concrete html and javascript.
Greetings,
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org
Re: learning API for table
Posted by Thufir <ha...@gmail.com>.
On Sun, 22 Feb 2009 11:15:01 +0100, Martin Kurz wrote:
> 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:
>
I made a utility method which takes a List and returns a nice table. I
plan to make it more general by implementing generics better and
accepting a List<List>, but for now it's perfect.
I haven't really looked too closely at the Java, but the HTML produced is
much more common sense.
The next thing I should work on are CRUD operations for a table. I
notice mouse over event listeners and so forth in the API. ECS is not
dissimilar from Swing?
I suppose that as I make the table I should add listeners to each cell?
I'll google, as I expect that this isn't exactly virgin territory :)
thanks,
Thufir
---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org
Re: learning API for table
Posted by Martin Kurz <in...@martinkurz.com>.
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: ecs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: ecs-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ecs-user-help@jakarta.apache.org