Iterate to give html row instead of table

T

Tasperian Jigs

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
 
A

Andrea Desole

Tasperian said:
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

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
 
O

Oliver Wong

Tasperian Jigs said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top