• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic table based on if statement  RSS feed

 
Rancher
Posts: 300
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: 4562
115
  • 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: 300
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: 4562
115
  • 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: 300
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: 4562
115
  • 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: 300
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: 4562
115
  • 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.
 
a wee bit from the empire
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!