• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Datatable Question

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JSF datatable that has its value backed to an arraylist on my backing bean. Normally, the method to retrieve the value from my backing bean gets called during two different phases. Is there anyway to prevent this from hitting the database during the APPLY_REQUEST_VALUES phase? This seems like a performance nightmare. I am using request scoped beans and don't want to switch to session scoped beans.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Getters are there to return bean properties and not to do some business/database logic. Getters can be called more than once in bean's life. Move the data loading logic to the constructor or initialization block of the bean. Or if you really, really want to do it in the getter, then introduce lazy loading.
 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I initially was doing the lazy loading solution, but I ran into a problem when my other business logic threw an error and the page containing the datatable was reloaded to show the FacesMessages. When this happened, the call to the database retrieved the wrong data because it was first run during the APPLY_REQUEST_VALUES phase before the query request parameters were applied to the proper bean. When the getter was called again in the RENDER_RESPONSE phase, the lazy load prevented the database from being queried with the correct parameters, which had now been populated on the proper bean.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic