Append Map

I have a list of accoundIds and from this i want to find the fullname of the users.

i.e. inputing:

<list>

<s>accountId of user1</s>

<s>accountId of user2</s>

<s>accountId of user3</s>

</list>

Basically, i have a while loop that loops through the list of user id and find the user fullname using:

<invoke name='getAttribute'>

<invoke name='getObject'>

<ref>:display.session</ref>

<s>User</s>

<ref>nameIdx</ref>

</invoke>

<s>fullname</s>

</invoke>

where nameIdx is the accoundId

As i'm inputing a list of accoundid, so i need to a way to append a hash map.

The result that i'm aiming for are:

<map>

<s>fullname of user1</s>

<s>accountId of user1</s>

<s>fullname of user2</s>

<s>accountId of user2</s>

<s>fullname of user3</s>

<s>accountId of user3</s>

</map>

How can this be done?

[1161 byte] By [R_L123] at [2007-11-26 11:19:54]
# 1

R_L123,

You can iterate over your list using <dolist> in XPRESS, and for each entry maybe call the put method on a predefined java.util.Map object. But wouldnt it be easier to use a nested list object? Something like:

<defvar name="userMap">

<list/>

</defvar>

<dolist name='entry'>

<!-- your list here; eg, <ref>targetUsers</ref> -->

<block>

<defvar name='tmp'>

<invoke name='getObject'>

<ref>:display.session</ref>

<s>User</s>

<ref>entry</ref>

</invoke>

</defvar>

<append name='userMap'>

<array>

<invoke name='getAttribute'>

<ref>tmp</ref>

<s>fullname</s>

</invoke>

<ref>entry</ref>

</array>

</append>

</block>

</dolist>

Which would give you a nested list structure in userMap such as

<list>

<list>

<s>fullname of user1</s>

<s>accountId of user1</s>

</list>

<list>

<s>fullname of user2</s>

<s>accountId of user2</s>

</list>

<list>

<s>fullname of user3</s>

<s>accountId of user3</s>

</list>

</list>

And you could then refer to each user's fullname as index position 0 in the list, accountId as index position 1.

Alternatively you could concatenate both values in a string using some delimiter, and the <split> on that delimiter later.

I confess I havent run the code above but it ought to work...

c732345 at 2007-7-7 3:35:13 > top of Java-index,Web & Directory Servers,Directory Servers...
# 2

Thank you for your reply and i'll soon try what you've suggested.

The reason that i am trying to construct a hash map is because i plan to present the user a 'select' list. The user will see a list of 'fullname'.

Once a particular option on the 'select' list has been selected and the submit button is pressed, i can then use the correspondin accountId to retrieve the selected user details.

R_L123 at 2007-7-7 3:35:13 > top of Java-index,Web & Directory Servers,Directory Servers...