Hi,

I would like to ask for an opinion on how to pass a large    amount of
varied information from ActionServlet / Action (Command) classes to the
resulting JSP.

For instance, on one page customer enters his bank account number on JSP1
and on the following page he should get back account details such as
HTML table 1 containing Past Transactions (amount, date, resulting balance)
HTML table 2 containing Pending Transactions
HTML table 3 containing Bank fees and for what they were imposed (lets
assume here this is a bad bank)
HTML table 4 containing predefined payees
String containing account status (active, closed, whatever)
etc.
Lets say all these tables need to be placed into one resulting HTML (JSP).
I have of course a different task at hand than online banking but the idea
is the same.
I was thinking along the lines of creating a "large" bean named
AccountDetails , with containment relation to 4 ArrayList classes, which in
turn contain concrete classes like AccountDetailEntry,with functions like
getDate(), getDescription(), etc.
I.e.
class AccountDetails {
        ArrayList pendingTransactions;
        ArrayList completedTransactions;
        ArrayList fees;
        ArrayList payess;
        String status;
        double currentBalance;
}

class PendingTransaction {
        String date;
        String amount;
        Payee payee;
        // mutators and accessors
}
...
with AccountDetails.pendingTransactions is as set of PendingTransactions,
etc.

JSP logic would look like:
- get AccountDetails bean
- for each ArrayList in the bean, iterate through it and output into HTML
table
- for various non-table data (like today account balance, status) just place
it in proper place in HTML.

I have the following doubts/questions:
1. Is there a better approach to handling this situation.  JSP code becomes
full of Java which we would like to avoid when possible.
2. Do I really need AccountDetails main class to be a bean? Since I am not
using bean properties in classic sense but rather retrieving collections
like ArrayList as Java methods of AccountDetails and then iterating through
them and calling various methods to populate tables I am not sure bean is
needed.
3. When iterating through ArrayList, is it worth in my case to replace "for"
loop iteration:
for (int index=0; index< pendingTransactions.size();index++) {
with tag of the like:
<x:iterate...>
My perception is that such a tag would be beneficial only  when ytou try to
hide Java code in your JSP page, thus making it more transparent for SGML
background Web designer. If my JSP page is so full of Java code anyway
(extracting ArrayLists, calling various methods of classes stored in
ArrayList), does it make any sense to replace 'for' command with iteration
tag.

Vadim Shun
NEW Corp
Dulles, VA

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to