From: Ken on
With a multitude of options out there I wonder what the best way to do
something...

I have several java.util.Lists that I need to merge together and
display on a static web page. The two lists will become one html
table.

My choices (so far as I know) are to merge the lists into a new
container (probably a ArrayList) and then display it with Struts 2 tag
library... or just perform the logic in the JSP, as I see the JSP as
the View. I think keeping as much logic out of JSP's looks nicer...
So are there tags that can display the contents of containers to into
tables and if so what are they?

This will be implemented shortly but am new to Struts 2 and want to do
it the _right_ way, or at least not a terrible way.





From: markspace on
Ken wrote:

> I have several java.util.Lists that I need to merge together and
> display on a static web page. The two lists will become one html
> table.


I don't use Struts, but I think the right way to do this is to use a
Servlet as a controller and assemble your list there, whether it's two
separate lists or twelve.

Then dispatch to the JSP, which should only display the one table. JSPs
should be concerned as much as possible with display only, don't do any
processing here, just display what someone else has set in the
appropriate context (probably Request context but could be a Session or
Application context too, if appropriate).
From: Lew on
Ken wrote:
>> I have several java.util.Lists that I need to merge together and
>> display on a static web page. The two lists will become one html
>> table.

markspace wrote:
> I don't use Struts, but I think the right way to do this is to use a
> Servlet as a controller and assemble your list there, whether it's two
> separate lists or twelve.

Or even more hyper-correctly, have the servlet call an "action" or "logic"
class that in turn knows how to retrieve from however many data sources into a
single data model.

> Then dispatch to the JSP, which should only display the one table. JSPs
> should be concerned as much as possible with display only, don't do any
> processing here, just display what someone else has set in the
> appropriate context (probably Request context but could be a Session or
> Application context too, if appropriate).

You say you don't use Struts, but you show more wisdom about it than a dozen
programmers I worked with who did use Struts.

For the archives: markspace (an RTTY term, not his real name) just
demonstrated what makes a real programmer and not just a library memorizer.

He is what you should be.

--
Lew
From: Gilbert on
Ken wrote:

> With a multitude of options out there I wonder what the
best way to do
> something...
>
> I have several java.util.Lists that I need to merge
together and
> display on a static web page. The two lists will become
one html
> table.
>
> My choices (so far as I know) are to merge the lists into a
new
> container (probably a ArrayList) and then display it with
Struts 2 tag
> library... or just perform the logic in the JSP, as I see
the JSP as
> the View. I think keeping as much logic out of JSP's looks
nicer...
> So are there tags that can display the contents of
containers to into
> tables and if so what are they?
>
> This will be implemented shortly but am new to Struts 2 and
want to do
> it the _right_ way, or at least not a terrible way.

Create your single list/map/collection in your action code
and then pass the result to your jsp. To actually display the
data you could look at
http://displaytag.sourceforge.net/10/tagreference-
displaytag-12.html

If you want an ajax approach, you should look at the Struts
JQuery plugin and the grid tags.

You may also find it useful to subscribe to the Struts User
mailing list at user(a)struts.apache.org

Regards