tags:

views:

141

answers:

4

when we are performing any reRender action to particular part of the page. Display of the page is fine but for displaying the particular portion the remaining page actions are called Twice and the queries in those BackingBeans are firing (Mean to say all the queries are firing twice for displaying some part of the page). This is decreasing the Application Performance. Can any Help on this how to increase the performance by using reRender and how we can make the queries execution less number of times?

A: 

Is your code in getters? JSF does not guarantee that getters are called exactly once so expensive code should not go in getters.

shipmaster
A: 

Do you have any Seam page actions? These get called (annoyingly) with every Ajax request.

Damo
+1  A: 

JSF getter methods are not guaranteed to be only called once. You should do you queries in a method called called from the constructor to avoid this.

public class Test {
    private String value;

    public Test() {
       this.doQuery();
    }

    private void doQuery() {
       //do query
       this.value = "query result";
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
Mark Robinson
A: 

This is a known bug. No workarounds, except to query the data only if explicit desired by setting a custom boolean (lets call it queryData) from the form where desired.

java:

    public String getValue() {
    if (queryData) {
        return doQuery();
    } else {
        return cachedValue;
    }
}

xhtml:

<h:form onsubmit="this.firstChild.value=true;">
<h:inputHidden id="queryData" value="#{backing.queryData}"/>
cobaasta