webtier@glassfish.java.net

Re: [webtier] Re: serious performance bug with JSF2

From: Joel Weight <digitaljoel_at_gmail.com>
Date: Tue, 28 Sep 2010 14:49:55 -0600

I don't have an answer for you on why it is calling that code within a
component that isn't rendered, but I think you'll find that myBean.values is
evaluated once for each row in the datatable, plus a couple more times for
good measure. So, with 50 rows, it would be called just over 50 times.

This is a little tangential to your question, but for when you DO want to
render the datatable, what I am doing is using an f:event with the type
preRenderComponent and calling a method to populate the data list, then in
the 'value' of the datatable tag, we use a property that simply returns the
data list. Something like this...

[code]
<h:panelGroup id="p" rendered="#{myBean.shouldRenderTable}">

    <f:event listener="#{myBean.loadData(
possibleParametersHereThanksToNewEl )}" type="preRenderComponent" />

           <h:dataTable var="d" value="#{myBean.values}">
               <h:column>
                   <h:outputText value="#{d}"/>
               </h:column>
           </h:dataTable>
       </h:panelGroup>


Bean code
public void loadData( SomeObject myParameters )
{
    myDataList = someService.loadFilteredData( myParameters );
}

public List<MyObjects> getValues()
{
    return myDataList;
}
[/code]

That way, loadData is only called once, and the 50 calls to getValues is
cheap.

Joel

On Tue, Sep 28, 2010 at 2:45 PM, <webtier_at_javadesktop.org> wrote:

> Just to complement:
>
> MyBean code:
>
> [code]
> public class MyBean {
>
> /** Creates a new instance of MyBean */
> public MyBean() {
> }
>
> public List<Integer> getValues) {
> System.out.println("getValues called");
> List<Integer> lista = new ArrayList<Integer>();
>
> lista.add(45);
> lista.add(50);
>
> return lista;
> }
> }
>
> [/code]
>
> I'm running with Tomcat 6.0.26.
>
> As long as i understand, as dataTable component is inside a non rendered
> component (panelGroup in my example) the EL "#{myBean.values}" should not be
> evaluated. But, as I said in previous post, El expression is called 10 times
> if using JSF 2 (and zero times if using JSF1.2).
> [Message sent by forum member 'leandro_komosinski']
>
> http://forums.java.net/jive/thread.jspa?messageID=483867
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net
>
>