aspose file tools*
The moose likes Other Open Source Projects and the fly likes Dynamic table not displaying. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Dynamic table not displaying." Watch "Dynamic table not displaying." New topic
Author

Dynamic table not displaying.

Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

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?


Learning and Learning!-- Java all the way!
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

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.


Time is what we want the most, but what we use the worst. -- William Penn
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

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

Joined: Sep 10, 2008
Posts: 270

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

Joined: Jan 05, 2011
Posts: 477

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

Joined: Sep 10, 2008
Posts: 270

this Link

and this Link might help you...


Also go through Bear's Article Here
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

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

Joined: Sep 10, 2008
Posts: 270

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

Joined: Jan 05, 2011
Posts: 477

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

Joined: Sep 10, 2008
Posts: 270

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

Joined: Jan 05, 2011
Posts: 477

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

Joined: Sep 10, 2008
Posts: 270

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

Joined: Jan 05, 2011
Posts: 477

I tried that too , werent you suggesting something like this?

However , there is no change
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

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

Joined: Jan 05, 2011
Posts: 477

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

Joined: Sep 10, 2008
Posts: 270

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

Joined: Jan 05, 2011
Posts: 477

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

Joined: Jan 05, 2011
Posts: 477

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
 
 
subject: Dynamic table not displaying.