Thanks Andrew & David
I am finally able to get Cache the data & avoid unnecessary database calls .
This is what i have done

Spring Manager Bean
getManufacturerList(){
 return manufacturerCache which is Map and gets populated from the database
in init method of the bean 
} 
So everytime JSF Backing Bean calls getManufacturerList in Spring the data
is returned from the Cache.
The limitations of this approach are
- Stale data in the Cache. Any pointers/suggestions on how to refresh the
Cache will be highly appreciated
- The Cache i.e. Map datastructure has to store 1640 records which hangs the
application
 
Regards
Bansi

Andrew Robinson-5 wrote:
> 
> List<SelectItem> manufacturerList =
> (List<SelectItem>)reqMap.get(manufacturerList_KEY);
>  System.out.println("manufacturerList="+manufacturerList.size());
> 
> The println statement will throw a null pointer exception as you are
> calling "size()" on null the first time the function is called.
> 
> On 5/23/07, bansi <[EMAIL PROTECTED]> wrote:
>>
>> Thanks David . Somehow i overlooked the setXXX method . It fixed the
>> error
>> but still it results in unnecessary database calls . Infact it results in
>> one more additional database call thereby making the total to 4. Out of
>> which only 1 is desirable the other 3 occur due to getManufacturerList()
>> I tried changing the saveState from client to server in web.xml but that
>> didnt help
>>
>> So i will appreciate if either you or Andrew could look into my snippet
>> code
>> of getManufacturerList() method in earlier posting. I am using RequestMap
>> but it results in Null pointer Exception
>>
>> Thanks for your time in advance
>> Regards
>> Bansi
>>
>>
>>
>> David Delbecq-2 wrote:
>> >
>> > You need a void setManufacturerList(List l) so saveState can restore
>> the
>> > state.
>> >
>> > bansi a écrit :
>> >> Thanks Andrew. As suggested i have placed the snippet right above
>> >> <h:form>
>> >> <f:view>
>> >>   <t:saveState id="save1" 
>> value="#{manufacturerBean.manufacturerList}"
>> >> />
>> >>   <h:form id="manufacturerForm">
>> >>
>> >> It results in following exception
>> >> javax.faces.el.PropertyNotFoundException: /manufacturerForm.xhtml
>> @23,75
>> >> value="#{manufacturerBean.manufacturerList}": Bean:
>> >> com.boeing.nmt.nams.view.bean.ManufacturerBean, property:
>> >> manufacturerList
>> >> (no write method for property!)
>> >>
>> >> I didnt understood what does it mean by "no write method for
>> property!" .
>> >> I
>> >> do have getManufacturerList in backing bean
>> >>
>> >> Regards
>> >> Bansi
>> >>
>> >>
>> >>
>> >> Andrew Robinson-5 wrote:
>> >>
>> >>> How about <t:saveState value="#{manufacturerBean.manufacturerList}"
>> >>> />? If you are using a4j:region, you will need to make sure the save
>> >>> state tag in in the region (BTW - I haven't tested this).
>> >>>
>> >>> On 5/23/07, bansi <[EMAIL PROTECTED]> wrote:
>> >>>
>> >>>> I have  following dropdown
>> >>>>
>> >>>> Code:
>> >>>>
>> >>>> <h:panelGrid columns="3" styleClass="detail" columnClasses="label">
>> >>>>           <h:outputText value="Manufacturer" />
>> >>>>
>> >>>>           <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>
>> >>>>
>> >>>>
>> >>>> The perfomance issue is Whenever i pick a  value from the dropdown
>> it
>> >>>> results in 3 datbase calls
>> >>>> Here is the sequence of method calls
>> >>>> - First time the method in f:selectItems gets called which results
>> in a
>> >>>> database call
>> >>>> <f:selectItems value="#{manufacturerBean.manufacturerList}" />
>> >>>> - Second time as expected/desired 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}" />
>> >>>>
>> >>>> I understand its due to JSF Lifcycle.
>> >>>>
>> >>>>
>> >>>> Any pointers/suggestion on how to Cache the method
>> >>>> getManufacturerList()
>> >>>> to
>> >>>> avoid unnecessary database calls will be highly appreciated
>> >>>>
>> >>>> Regards
>> >>>> Bansi
>> >>>>
>> >>>> --
>> >>>> View this message in context:
>> >>>>
>> http://www.nabble.com/Caching-JSF-Dropdown-Results-tf3805830.html#a10770409
>> >>>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>>>
>> >>>>
>> >>>>
>> >>>
>> >>
>> >>
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Caching-JSF-Dropdown-Results-tf3805830.html#a10772815
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Caching-JSF-Dropdown-Results-tf3805830.html#a10777319
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to