Win a copy of Hands On Software Engineering with Python this week in the Jython/Python 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Dynamic table based on if statement  RSS feed

 
Master Rancher
Posts: 884
17
Firefox Browser 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: 5130
135
  • 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
Master Rancher
Posts: 884
17
Firefox Browser 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: 5130
135
  • 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
Master Rancher
Posts: 884
17
Firefox Browser 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: 5130
135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to define some columns, like that example shows.
 
Daniel Demesmaecker
Master Rancher
Posts: 884
17
Firefox Browser 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: 5130
135
  • 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.
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!