You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by bansi <ma...@yahoo.com> on 2007/05/04 23:19:58 UTC
Perfomance Issues with JSF dropdown
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.
Re: Perfomance Issues with JSF dropdown
Posted by Andrew Robinson <an...@gmail.com>.
I didn't check my code, I just typed it into the email, so there may
be compilation problems and such.
As for the null pointer, can you tell us which line is 271?
On 5/7/07, bansi <ma...@yahoo.com> wrote:
>
> Thank you so much Andrew. Based on your recommendation i tried something like
> this which results in NullPointerException.
> public List getManufacturerList()
> {
> Map reqMap =
> FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
> // Note : I am not able to get DefaultContext as you mentioned in the
> posting . Its giving error hence i end using getCurrentInstance of
> FacesContext
>
> List<SelectItem> manufacturerList =
> (List<SelectItem>)reqMap.get(manufacturerList_KEY);
> List<Manufacturer> manufResultSet = new ArrayList<Manufacturer>();
> if (manufacturerList == null)
> {
> // TODO: load it
>
> manufResultSet = manufManager.getManufacturerList(); //get data from
> Database
> for (int i=0; i< manufResultSet.size(); i++) {
> Manufacturer namsManufacturer = (Manufacturer) manufResultSet.get(i);
> Long manufId = namsManufacturer.getId();
> String manufName = namsManufacturer.getName();
> manufacturerList.add(new SelectItem(manufId.toString(),manufName));
> }
> reqMap.put(manufacturerList_KEY, manufacturerList);
> }
> return manufacturerList;
> }
>
> I know i am doing something wrong or maybe i didn't understood your posting
> correctly.
> Caused by: java.lang.NullPointerException
> at
> com.boeing.nmt.nams.view.bean.ManufacturerBean.getManufacturerList(ManufacturerBean.java:271)
>
> Any pointers/suggestions to help me fix my code will be highly appreciated
> Regards
> Bansi
>
> Andrew Robinson-5 wrote:
> >
> > private final static String LARGE_STUFF_KEY = "largestuff";
> > @SuppressWarnings("unchecked")
> > public List<Stuff> getLargeStuff()
> > {
> > Map reqMap = FacesContext.getDefaultInstance()
> > .getExternalContext().getRequestMap();
> > List<Stuff> list = (List<Stuff>)reqMap.get(LARGE_STUFF_KEY);
> > if (list == null)
> > {
> > // TODO: load it
> > reqMap.put(LARGE_STUFF_KEY, list);
> > }
> > return list;
> > }
> >
> > The request map will be thrown out at the end of the request. So the
> > "large stuff" will only be loaded once per request.
> >
> > On 5/4/07, bansi <ma...@yahoo.com> wrote:
> >>
> >> 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 <ma...@yahoo.com> 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.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Perfomance-Issues-with-JSF-dropdown-tf3694314.html#a10367087
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>
Re: Perfomance Issues with JSF dropdown
Posted by bansi <ma...@yahoo.com>.
Thank you so much Andrew. Based on your recommendation i tried something like
this which results in NullPointerException.
public List getManufacturerList()
{
Map reqMap =
FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
// Note : I am not able to get DefaultContext as you mentioned in the
posting . Its giving error hence i end using getCurrentInstance of
FacesContext
List<SelectItem> manufacturerList =
(List<SelectItem>)reqMap.get(manufacturerList_KEY);
List<Manufacturer> manufResultSet = new ArrayList<Manufacturer>();
if (manufacturerList == null)
{
// TODO: load it
manufResultSet = manufManager.getManufacturerList(); //get data from
Database
for (int i=0; i< manufResultSet.size(); i++) {
Manufacturer namsManufacturer = (Manufacturer) manufResultSet.get(i);
Long manufId = namsManufacturer.getId();
String manufName = namsManufacturer.getName();
manufacturerList.add(new SelectItem(manufId.toString(),manufName));
}
reqMap.put(manufacturerList_KEY, manufacturerList);
}
return manufacturerList;
}
I know i am doing something wrong or maybe i didn't understood your posting
correctly.
Caused by: java.lang.NullPointerException
at
com.boeing.nmt.nams.view.bean.ManufacturerBean.getManufacturerList(ManufacturerBean.java:271)
Any pointers/suggestions to help me fix my code will be highly appreciated
Regards
Bansi
Andrew Robinson-5 wrote:
>
> private final static String LARGE_STUFF_KEY = "largestuff";
> @SuppressWarnings("unchecked")
> public List<Stuff> getLargeStuff()
> {
> Map reqMap = FacesContext.getDefaultInstance()
> .getExternalContext().getRequestMap();
> List<Stuff> list = (List<Stuff>)reqMap.get(LARGE_STUFF_KEY);
> if (list == null)
> {
> // TODO: load it
> reqMap.put(LARGE_STUFF_KEY, list);
> }
> return list;
> }
>
> The request map will be thrown out at the end of the request. So the
> "large stuff" will only be loaded once per request.
>
> On 5/4/07, bansi <ma...@yahoo.com> wrote:
>>
>> 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 <ma...@yahoo.com> 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.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Perfomance-Issues-with-JSF-dropdown-tf3694314.html#a10367087
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: Perfomance Issues with JSF dropdown
Posted by Andrew Robinson <an...@gmail.com>.
private final static String LARGE_STUFF_KEY = "largestuff";
@SuppressWarnings("unchecked")
public List<Stuff> getLargeStuff()
{
Map reqMap = FacesContext.getDefaultInstance()
.getExternalContext().getRequestMap();
List<Stuff> list = (List<Stuff>)reqMap.get(LARGE_STUFF_KEY);
if (list == null)
{
// TODO: load it
reqMap.put(LARGE_STUFF_KEY, list);
}
return list;
}
The request map will be thrown out at the end of the request. So the
"large stuff" will only be loaded once per request.
On 5/4/07, bansi <ma...@yahoo.com> wrote:
>
> 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 <ma...@yahoo.com> 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.
>
>
Re: Perfomance Issues with JSF dropdown
Posted by bansi <ma...@yahoo.com>.
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 <ma...@yahoo.com> 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.
Re: Perfomance Issues with JSF dropdown
Posted by Andrew Robinson <an...@gmail.com>.
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 <ma...@yahoo.com> 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.
>
>