• Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying the fields using Comparator

 
Rithanya Laxmi
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Map mapTest = new HashMap();
mapTest.put("100", new CustomerVO(new BigInteger("1000000"), "CustomerName", 1);
mapTest.put("200", new CustomerVO(new BigInteger("2000000"), "Address",3);
mapTest.put("300", new CustomerVO(new BigInteger("3000000"), "Contact", 2);
mapTest.put("400", new CustomerVO(new BigInteger("3000000"), "State", 5);
mapTest.put("500", new CustomerVO(new BigInteger("3000000"), "City", 4);

Here I need to display the Labels in the JSP based on the order which is 1,3,2,5 or 4.

In the CustomerVO , the fields are:-

Id, Label and Order.

In this case the Labels should be displayed in the JSP as:-

CustomerName
Contact
Address
City
State

How to display as above for the "Order" values that is passed using Java Comparator, please shed some light into this?

thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65529
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your map is ill-suited to this task. Why is it constructed the way that it is? Why the 100, 200, etc if they are not used as keys?

If you need to key off certain data, that's what should be used for your map keys.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!