Thanks Andrew for quick response. As i am newbie to JSF i would appreciate
code snippet on how to cache the data pre-request as you correctly guessed
the data is constructed inside a get method .
Here is my method in backing bean
public List getManufacturerList(){
logger.info(" *** In getManufacturerList Backing Bean*** ");
List<NamsManufacturer> models = new ArrayList<NamsManufacturer>();
List<SelectItem> manufacturers = new ArrayList<SelectItem>();
models = manufManager.getManufacturerList(); //// Calls
Hibernate/Spring
i.e. database call to retrieve List of Manufacturers
// Iterating thru Loop to wrap into instances of SelectItem so that it
can
be rendered as dropdown
for (int i=0; i< models.size(); i++) {
NamsManufacturer namsManufacturer = (NamsManufacturer)
models.get(i);
Long manufId = namsManufacturer.getId();
String manufName = namsManufacturer.getName();
manufacturers.add(new SelectItem(manufId.toString(),manufName));
}
return manufacturers;
}
Also i would highly appreciate code snippet on how to use the requestMap
from the external context to cache data for
the request to avoid calling twice
Any pointers/suggestions where i can obtain more info will be highly
appreciated
Regards
Bansi
Andrew Robinson-5 wrote:
>
> UIComponents are free to call their value bindings as many times as
> they want, so you should make sure you cache that data pre-request if
> you are constructing data in a get method (like select items, maps,
> etc).
>
> In your case, it is being called twice because of the two phases it is
> needed. (1) During validation to ensure the value the user submit is a
> valid value (contained in a value of one of the select items) and (2)
> when re-rendering during an encodeXxx method.
>
> You can use the requestMap from the external context to cache data for
> the request that will be left for the GC after the request is
> completed.
>
>
> On 5/4/07, bansi <[EMAIL PROTECTED]> wrote:
>>
>> Here is the situation
>>
>> I have the following dropdown defined with ajax4jsf event onchange
>>
>> 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 different value from the dropdown, i expect only
>> ajax4jsf
>> action method is called i.e.
>>
>> <a4j:support action="#{manufacturerBean.loadManufacturerDetails}"
>> event="onchange"
>> reRender="manufName,manufDescription,manufSource,btnSave,btnDelete" />
>>
>> BUT why is the method defined in f:selectItems is getting called
>> twice as seen in log file
>> <f:selectItems value="#{manufacturerBean.manufacturerList}" />
>>
>> Logs:
>> 2007-05-04 14:16:31,694 INFO
>> [com.boeing.nmt.nams.view.bean.ManufacturerBean] - < *** In
>> getManufacturerList Backing Bean*** >
>> Any pointers/suggestions will be highly appreciated
>>
>> Regards
>> Bansi
>> --
>> View this message in context:
>> http://www.nabble.com/Perfomance-Issues-with-JSF-dropdown-tf3694314.html#a10330594
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Perfomance-Issues-with-JSF-dropdown-tf3694314.html#a10332531
Sent from the MyFaces - Users mailing list archive at Nabble.com.