My legacy code has a class that has a method returning an html table.
I would like to create a method that returns rows to give me more
flexability. One row each time I invoke the method. Should I implement an
Iterator interface or something similar? I don't know which 'design
pattern' to follow. Any tips to the right direction would help.
Thanks in advance.
J
Andrea Desole - 10 Jan 2006 16:08 GMT
> My legacy code has a class that has a method returning an html table.
> I would like to create a method that returns rows to give me more
[quoted text clipped - 5 lines]
>
> J
Your description is not really clear. Assuming that you want to iterate
over a collection of objects in a web application, you should check out
the forEach tag in JSTL
Oliver Wong - 10 Jan 2006 16:22 GMT
> My legacy code has a class that has a method returning an html table.
> I would like to create a method that returns rows to give me more
> flexability. One row each time I invoke the method. Should I implement an
> Iterator interface or something similar? I don't know which 'design
> pattern' to follow. Any tips to the right direction would help.
My undestanding is that your method previously returned a string which
contained the HTML representation of a table, and you now wish to return
several strings, each of which is a row in the table. With the information
you've given so far, iterator sounds like a decent fit, though it means you
may have to do something special to get the opening and closing "<table>",
"</table>" tags, since those aren't actually rows. Another possibility is to
just return a list of strings.
- Oliver