users@javaserverfaces.java.net

Re: Optimisation of MenuRender

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Mon, 12 Nov 2007 14:16:11 -0800

mjdenham wrote:
> I am considering putting some dynamic intelligence into the formation of
> SelectItem lists in my application which would also unfortunately slow down
> the return of SelectItem lists.
>
> I have observed that the request to RenderKitUtils.getSelectItems() seems to
> be called twice during each render in MenuRenderer.renderOptions() and
> MenuRenderer.getOptionNumber. Both these methods are called from
> MenuRenderer.renderSelect().
>
> Could I suggest it might be more efficient to call getSelectItems() once
> each render from renderSelect(), to remember the returned list, and pass the
> list into renderOptions() and renderSelect().
>
> This is fairly important to me because I am considering implementing dynamic
> lists of items which vary according to other selected values and I am
> reluctant to execute the logic twice each rendering because of the
> performance overhead.
>
Yep, you're right. Please log an issue[1] and we'll address it for 1.2_06.

[1] https://javaserverfaces.dev.java.net/issues
> Here are stack traces of the method calls:
> Call 1:
> at
> com.edfenergy.eecalc.presentation.framework.DomainMap.get(DomainMap.java:9)
> at javax.el.MapELResolver.getValue(MapELResolver.java:164)
> at
> javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
> at
> com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:73)
> at com.sun.el.parser.AstValue.getValue(AstValue.java:118)
> at
> com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
> at
> com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
> at
> javax.faces.component.UISelectItems.getValue(UISelectItems.java:141)
> at
> com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:303)
> at
> com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:647)
> at
> com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:763)
>
> Call 2:
> at
> com.edfenergy.eecalc.presentation.framework.DomainMap.get(DomainMap.java:9)
> at javax.el.MapELResolver.getValue(MapELResolver.java:164)
> at
> javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
> at
> com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:73)
> at com.sun.el.parser.AstValue.getValue(AstValue.java:118)
> at
> com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
> at
> com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
> at
> javax.faces.component.UISelectItems.getValue(UISelectItems.java:141)
> at
> com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:303)
> at
> com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:711)
> at
> com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:780)
>
> I am using jsf ri 1.2_05.
>
> Regards
>
> Martin
>