How to pass array of array (list of list) to view in play framework 2.x?

92 views
Skip to first unread message

Akshay Bhatt

unread,
Oct 14, 2013, 7:18:00 AM10/14/13
to play-fr...@googlegroups.com

I have been trying it for sometime and I have to create view for complex frontend application. This looks like I am able to send array list like:

In Controller :

ArrayList<String> cname = new ArrayList<>();
cname.add("akshay");
cname.add("david");

And in View :

@(cname: List[String])

But, now I have to create an array of this array. This could be other data structure as well like List, but for now I have to pass an array of array, which looks like :

ArrayList<ArrayList<String>> arr = new ArrayList<>();

What type should be view then ? Below is not working :

@(cname : List[List[String]])

Any reference to tutorial/guide for such arrays for future reference would be much helpful.

Edit :

I need to pass ArrayList of ArrayList. The program in question is :

while(rs.next())
        {
            cname = rs.getString("customername");
            cmobile = rs.getString("customermobile");
            amount = rs.getString("billamount");

            namearr.add(cname);
            mobilearr.add(cmobile);
            amountarr.add(amount);

        }
        rowsArray.add(mobilearr);
        rowsArray.add(namearr);
        rowsArray.add(amountarr);

And I have to send rowsArray to front. I know using this kind of queries is abuse of Play Framework, but in this case, I had to go as native as possible. Is there any otherway I can send such data to frontend except JPA ? Is it possible that I create a class with these arrays and then in my controller create array of objects and send it to view ?

Reply all
Reply to author
Forward
0 new messages