This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

showing values in table on basis of column header

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

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 ?

Ranch Hand
Posts: 450
IntelliJ IDE Spring Java
  • 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?

Posts: 1845
  • 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)

What's wrong? Where are you going? Stop! Read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!