Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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 ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Dynamic table based on if statement  RSS feed

 
Rancher
Posts: 317
6
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to make a dynamic table to fill with the values of a list.
It suposed to keep a count and if the count mod 3 = 0 it should add a new row else it should add a new column.
The code compiles, I get no errors, but the values aren't displayed, I simply get a blank page.
If I remove the if statement it works fine, so the problem isn't getting the list...

jsppage:



Any tips on how to handle this?
 
Saloon Keeper
Posts: 4744
117
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way to build tables in JSPs is the http://www.displaytag.org/1.2/ library, IMO. Hasn't been released in a long time, but it works just fine. (There's also a newer version at https://github.com/hazendaz/displaytag/releases, but it's not really required IMO.)
 
Daniel Demesmaecker
Rancher
Posts: 317
6
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is actualy pretty helpfull, but I can't seem to acces the list returned by the ModelAndView.
I changed the could for the moment to:


It  works but your way seems better, so if you could fill me in on how to acces the list, I would be greatfull
 
Tim Moores
Saloon Keeper
Posts: 4744
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See http://www.displaytag.org/1.2/tut_basic.html. That's JSP-based so it has a


You would have this in your servlet:
 
Daniel Demesmaecker
Rancher
Posts: 317
6
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That I red to, but what I'm trying to do is something like this:

Controller:


jsp:


But when I call the page, there simply is a line nothing to display
 
Tim Moores
Saloon Keeper
Posts: 4744
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to define some columns, like that example shows.
 
Daniel Demesmaecker
Rancher
Posts: 317
6
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that already, no result
 
Tim Moores
Saloon Keeper
Posts: 4744
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without knowing exactly what you tried we can't speculate on what might be going wrong.

Did you get the example to work? Maybe it's easier to work your way from running code towards solving your case.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!