You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bort <sp...@rogers.com> on 2004/03/19 19:14:04 UTC

Iterating through a Hashtable of Vectors

Hi all

I've created a Hashtable, who's values are Vectors:

Vector a = new Vector();
a.add("something");
a.add("somethingelse");

Vector b = new Vector();
b.add("something");
b.add("somethingelse");

Hashtable ht = new Hashtable();
ht.put ("key", a);
ht.put ("anotherkey", b);

request.setAttribute("attrkey", ht);

What I want to be able to do is iterate through this Hashtable (in the JSP),
pull out a Vector, and iterate through it.  How would I do this?

tia
bort




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Iterating through a Hashtable of Vectors

Posted by bort <sp...@rogers.com>.
I'm going to add some more the my previous post, and put the whole thing
into an understandable context... please bear with me.

In addition to the Hashtable mentioned below, I have another Vector (let's
call this 'ACCVEC').  ACCVEC contains account numbers as Integer objects.
On my JSP page, I use <bean:iterate> to list these account numbers on the
screen.

The keys in the aforementioned Hashtable are also account numbers (as
Integers).  The corresponding value is a Vector (let's call this 'INVVEC')
of invoice numbers that are related to the account.  It should be noted that
not every account number in ACCVEC is not a key in the Hashtable.  That is,
there may be some accounts that have no invoices.

What I'd like to do is create a table (in my JSP) with a list of all account
numbers (as in ACCVEC), and an associated <html:select> of invoice numbers,
if they exist.

Essentially, what I want is:

for each account number in ACCVEC {
    display the account number
    attempt to retrieve a value from the Hashtable for this account number
    if there is a INVVEC {
        for each invoice number in INNVEC {
            create a select drop down box
        }
    }
}

How should this look using Struts?
bort


"bort" <sp...@rogers.com> wrote in message
news:c3fd79$spn$1@sea.gmane.org...
> Hi all
>
> I've created a Hashtable, who's values are Vectors:
>
> Vector a = new Vector();
> a.add("something");
> a.add("somethingelse");
>
> Vector b = new Vector();
> b.add("something");
> b.add("somethingelse");
>
> Hashtable ht = new Hashtable();
> ht.put ("key", a);
> ht.put ("anotherkey", b);
>
> request.setAttribute("attrkey", ht);
>
> What I want to be able to do is iterate through this Hashtable (in the
JSP),
> pull out a Vector, and iterate through it.  How would I do this?
>
> tia
> bort




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org