Daniel
Daniel

Reputation: 77

Play Framework list vector

How do I list a vector? How can I access the first key and the rest?

i can see the results

#{list vectorUser, as:'vu'}
       ${vu.key.name}</br>
        <li>${vu.????}</li>
#{/list}

Result

Group1
 Group1[17]=[User1 - User1, id - 13]
Group2
 Group2[14]=[User2 - User2, id - 15]

To show

TreeMap<Group,Vector<User>> g2u = getAll();
render(g2u);

Class User

public class name

Class Group

public class name

@ManyToManny
Public List<User> listUsers

Upvotes: 0

Views: 279

Answers (3)

F3rr31r4
F3rr31r4

Reputation: 268

<ul>
#{list groupList, as:'group'}
       ${group.key.name}

        #{list group.value, as:'listVector'}
             <br><li>${listVector.name}</li></br>
       #{/list}
#{/list}
</ul>

For the treemap

http://docs.oracle.com/javase/1.5.0/docs/api/java/util/TreeMap.html

For the vector

http://docs.oracle.com/javase/7/docs/api/java/util/Vector.html

Upvotes: 1

F3rr31r4
F3rr31r4

Reputation: 268

Try like this:

<ul>
#{list groupList, as:'group'}
       ${group.key.name}
        <li>${group.value.name}</li>
#{/list}
</ul>

Upvotes: 1

Bogdan
Bogdan

Reputation: 5406

I'm doing some wild guesses here since it's note very clear what you got there.

I'll just assume you've got a list of groups with child lists of users:

List<Group> groupList = YourModel.getAllGroups():

render(groupList);

I'll assume you want to list all groups with all users in each group.

You need to do something like this

<ul>
#{list items: groupList, as:'group'}
       <li>${group.name}
         <ul>
         #{list items: group.listUsers, as:'user'}
           <li> user.name </li>
         #{/list}
         </ul>
       </li>

#{/list}
</ul>

Upvotes: 0

Related Questions