Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

JSF Dropdown Perfomance Issues

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a h:selectOneMenu dropdown which performs CRUD operation.
The dropdown list has a value "New" which allows the users to enter new values into other form fields thereby performing Create/Insert operation
When users pick other values from the dropdown list it dynamically populates other fields in the form thereby facilitating Update/Delete operation. The problem is whenever i pick a different value from the dropdown list the database call happens twice.

Here is the dropdown
Code:


<h:selectOneMenu id="manufList" value="#{manufacturerBean.selectedManufacturer}" >
<f:selectItem itemLabel="New" itemValue="New" />
<f:selectItems value="#{manufacturerBean.manufacturerList}" />
<a4j:support action="#{manufacturerBean.loadManufacturerDetails}" event="onchange" reRender="manufName,manufDescription,manufSource,btnSave,btnDelete" />
</h:selectOneMenu>
</h:panelGrid>




Here is the sequence of method calls whenever i pick a value from the dropdown list
- First time the method in f:selectItems gets called which results in a database call
<f:selectItems value="#{manufacturerBean.manufacturerList}" />
- Second time Ajax4JSF onchange event action method gets called .
<a4j:support action="#{manufacturerBean.loadManufacturerDetails}" event="onchange" reRender="manufName,manufDescription,manufSource,btnSave,btnDelete" />
- Third time again the method in f:selectItems gets called which results in a database call
<f:selectItems value="#{manufacturerBean.manufacturerList}" />

Here are my concerns
- Just picking a value from the dropdown shouldn't result in a call to database especially when there are no changes made to database

- I expect the calls to database happens ONLY in case of users click Save/Update/Delete buttons i.e. dropdown dynamically refreshes with database values

Here are the snippets from log file which substantiates that whenever i pick a value from dropdown
database call occurs twice
Code:

********** FIRST METHOD CALL ***************************
2007-05-07 16:46:46,002 INFO [com.boeing.nmt.nams.view.bean.ManufacturerBean] - < *** In getManufacturerList Backing Bean*** >
2007-05-07 16:46:46,002 INFO [com.boeing.nmt.nams.service.impl.ManufacturerManagerImpl] - < *** In getManufacturerList Spring*** >
Hibernate: select namsmanufa0_.ID as ID60_, namsmanufa0_.CHANGE_USER as CHANGE2_60_, namsmanufa0_.NA
ME as NAME60_, namsmanufa0_.DESCRIPTION as DESCRIPT4_60_, namsmanufa0_.SOURCE as SOURCE60_, namsmanu
fa0_.STATUS as STATUS60_, namsmanufa0_.CHANGE_DATE as CHANGE7_60_ from NAMS_MANUFACTURER namsmanufa0
_

********** SECOND METHOD CALL ***************************
2007-05-07 16:46:46,237 INFO [com.boeing.nmt.nams.view.bean.ManufacturerBean] - < *** In loadManufacturerDetails method *** >
Hibernate: select namsmanufa0_.ID as ID60_0_, namsmanufa0_.CHANGE_USER as CHANGE2_60_0_, namsmanufa0
_.NAME as NAME60_0_, namsmanufa0_.DESCRIPTION as DESCRIPT4_60_0_, namsmanufa0_.SOURCE as SOURCE60_0_
, namsmanufa0_.STATUS as STATUS60_0_, namsmanufa0_.CHANGE_DATE as CHANGE7_60_0_ from NAMS_MANUFACTUR
ER namsmanufa0_ where namsmanufa0_.ID=?

********** THIRD METHOD CALL ***************************
2007-05-07 16:46:46,565 INFO [com.boeing.nmt.nams.view.bean.ManufacturerBean] - < *** In getManufacturerList Backing Bean*** >
2007-05-07 16:46:46,565 INFO [com.boeing.nmt.nams.service.impl.ManufacturerManagerImpl] - < *** In getManufacturerList Spring*** >
Hibernate: select namsmanufa0_.ID as ID60_, namsmanufa0_.CHANGE_USER as CHANGE2_60_, namsmanufa0_.NA
ME as NAME60_, namsmanufa0_.DESCRIPTION as DESCRIPT4_60_, namsmanufa0_.SOURCE as SOURCE60_, namsmanu
fa0_.STATUS as STATUS60_, namsmanufa0_.CHANGE_DATE as CHANGE7_60_ from NAMS_MANUFACTURER namsmanufa0
_



I do have Managed Bean in Session scope

Regards
Bansi
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic