aspose file tools
The moose likes Java in General and the fly likes Apache Velocity --How to access data from ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Apache Velocity --How to access data from ArrayList " Watch "Apache Velocity --How to access data from ArrayList " New topic
Author

Apache Velocity --How to access data from ArrayList

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2231

Hi

I am having a query in displaying data from the ArrayList using Apache Velocity Framework.

Here is a sample code :

I am setting data inside the ArrayList as shown .


Now my requiremnt is that i need to display the TXNID and its related data as shown :

TXNID001 89891898989889899
TXNID002 89891898989889800
TXNID003 89891898989889899


I started this way , but please help me to complete the whole thing



Please share your views .

Thanks in advance .







Save India From Corruption - Anna Hazare.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 26710
You have posted in the wrong forum, so I shall move your thread.

Why are you not parameterising the List?
Write down on paper what the 6 elements are in your List. Write how you intend to recover them and how to use the printf method to display them. Also check that you are entering them in the order you want.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2231

Hi , Campbell thanks for the answer , actually the business logic is developed by someone else , and i am suppoused to display the contents of the ArrayList only as per the explained scenario .

So any ideas .
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 26710
Write down the logic of how you intend to display those values. Are the TXN and 89 strings related or paired in any way in the List? How are you ordering them in the List? Should you be using a Map instead?
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2231

Thanks Campbell

They are added to the ArrayList as

while(rs.next())
{

list.add(rs.getString(1)); // This belongs to the Txn Ids
list.add(rs.getString(2));This belongs to the Txn data
}

Thank you .
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

But some of the entries are being added in the middle of the list for no apparent reason. It's bad enough that somebody decided to use a list to hold pairs of entries, but looking at that code I couldn't even predict what order the entries will end up in.
 
 
subject: Apache Velocity --How to access data from ArrayList
 
Threads others viewed
generics code mixed with legacy collection
Implementing a HashMap with multiple values for 1 key
Will explicitly making an Object null ,makes any difference in terms of performance or memory
help needed in copying an Array
listview with checkbox problem
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture