• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

showing values in table on basis of column header

 
Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I have a technical problem related to java html and jsp where I have to show a table. Table is such that it has headers on top of table and when page loads I should load the data in table depending on corresponding column header.


To be more specific- I would like to call a function on every "square-box" of column/rows and call a function with column header name as parameter in java which returns me the data and I need to show it in table.

Is it possible to do in jsp ?

thanks,
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Not clear what you are trying to achieve now.

The data to be displayed is probably generated dynamically and in that case you could take care of that in server side Java code. Now why would you want to have a separate Server call (I assume) each time a table column is rendered?

I feel you should have the logic for generation of the table headers/rows/columns in your server side code and JSP should be used for dynamic display purposes.

Could you please elaborate your requirement a little?

Cheers,
Raj.
 
Stefan Evans
Bartender
Posts: 1691
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing the data structure you are wanting is List<Map<String, Object>>
ie a List of Maps, each entry in the list representing one 'row' of the table, and the map being the values to display.
The key to the map being the 'column heading', and the value, the value to display in that column.
Its a fairly standard pattern for writing a 'generic' table that can display whatever you configure it to.

Personally I prefer defining the columns rather than having them be dynamic, and using a java bean with attributes rather than entries in a map, but it does work.
It goes something like this (untested)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic