• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Dynamic table not displaying.

 
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all ,
Im trying to dynamically populate a list of tables based on the selection in a dropdown .Im using a list of beans to store the values that I obtain from the database.However, no matter what selection I make , in the dropdown the the display only shows that there are no records to display> im also using a displaytag library here , to aid with the formatting of my table . Im pasting the code from my jsp that I use below to generate the table.

The servlet code ie. used to fetch the records.Im being able to see the records through logging here though.

Any pointers as to where i could be going wrong?
 
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you say that the dao.domList is fetched from the database and is populated. so now remove all the code from the jsp and put a c:forEach tag and see the contents of the ${dao.domList}, if that is okay.. then display tag should not give you that error message.
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Robin,
Thanks for replying. as you suggested i did try the following code snippet To replace the display table tag

However, there was no change in the situation , the records are being fetched in the DAO , but not being displayed in the front end/jsp . Also, the condition is the same even if the c:if test is removed .Any pointers to what i could be missing??
Thanks.
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vic Hood wrote:
However, there was no change in the situation , the records are being fetched in the DAO , but not being displayed in the front end/jsp . Also, the condition is the same even if the c:if test is removed .Any pointers to what i could be missing??



so you have the answer... the dao object is not being set to the request. put an else tag in the page.. if it enters that, then its null !
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Robin ,
Thanks for replying !Yes you are right , the dao object is not being set , any ideas on how i could go about in fixing this?
EDIT: I did try the else part using an other if , and it executed .
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this Link

and this Link might help you...


Also go through Bear's Article Here
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Robin! However, im not using a session here , the dao and domain objects are set only in the request . I dont want to use a session here , are you saying that its not possible to retrieve the contents using the request scope ?
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, since you are not using any frameworks like struts/struts2 which make the action forms / bean properties automatically available to the jsp page, you have to set it 'somewhere'. Decide for yourself which scope to use. Use request.setAttribute to pass objects.. Set the object in the request if you dont want to use the session scope... but do retrieve them in your jsp's using EL tags and NOT scriptlets !!
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying John!
Im using a list of beans to populate the table , are you suggesting that i set this list-'domList' in the request? The reason I ask is , im using another list of beans to generate the drop down , but it works fine without being set in the request.

EDIT- Tried setting it in the request, but doesnt work:(.also , i ve used only EL tags and no scriptlets
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how are you setting it ? use proper getters and setters for getting objects "case and spelling" matters a lot.

paste some code.
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay , well if you mean the DAO class , im using a getter and setter of the following nature ..

In my bean class , DomainBean .java

 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have in your servlet code ->


and later in your code in getters and setters ->



just try changing that to "domList = new ArrayList<DomainBean>(); // set it to instance variable.
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried that too , werent you suggesting something like this?

However , there is no change
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as I have asked before, how are you setting it to the request ? the dao object ? or are you setting specific variables... ?
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep that was the right question! I was overseeing something simple , I guess i tried accessing the bean through a dao object dao.domList however when I changed that to plain domList , it showed a corresponding list of records.(I wonder why this is happening because I use a dao object to generate another list dtList for a dropdown of the form dao.dtList , then wonder why the same doesnt apply here? )
However , here too when i try to implement pagination using the display tag , only the records in the first page are displayed , when i click on the next page it returns an empty result . Ive tried changing the no. of records in the page however only the ones in the first page are displayed and not the rest. Any clues as to where I could be going wrong?
Thanks for replying.
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vic Hood wrote:.....
However , here too when i try to implement pagination using the display tag , only the records in the first page are displayed , when i click on the next page it returns an empty result . Ive tried changing the no. of records in the page however only the ones in the first page are displayed and not the rest. Any clues as to where I could be going wrong?
Thanks for replying.



well that should be handled by display tag ( pagination, sorting etc. ), so give the entire list to the tag at one go and it will do all the pagination on its own. If you dont want the tag to do it then it also allows you to use your customized comparators / decorators etc... have a look at the library reference page at sourceforge for further details on those topics.
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well robin , if it were only the problem of pagination then the submit action, that was working would still work? . Why isnt that working then?
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vic Hood wrote:Well robin , if it were only the problem of pagination then the submit action, that was working would still work? . Why isnt that working then?


I meant that 'was' working..Sorry for the typo
 
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic