Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL twister  RSS feed

 
John Hyde
Greenhorn
Posts: 10
Java Oracle Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have N number of lists of a certain type of object with three attributes (value, description, priority),
pseudo code:


These lists are available to my JSP, where I have to write a html table using them where each list is a column in the html table, with priority being treated as row order. The entries which share the same description in both the lists will be put on the same row, if their priorities don't match max of their priorities will be taken.



To implement this I have an intermediate java method which stitches all the lists into a map like Map<String,Fields[]>
description1 -> [field1 , field2, null , field4]
description2 -> [ null , field2, field3 , field4]


Then I use JSTL to loop through the map to write the table. Though this works, this method does not feel clean. Is there anyway I can use JSTL loops and other JSTL features only to achieve the above functionality without calling an intermediate method to rearrange the data?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I think you are using the right approach. Moving complexity into the JSP would be a step in the wrong direction, in my opinion. I always make sure that the data is in a format that is easily and simply digestible by the JSP in order to keep the JSPs as "dumb" as possible.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And here I was thinking that "JSTL Twister" was going to be a fun new game.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!