reRender delayed on click of a4j:commandButton
its_me Nov 28, 2011 11:08 PMHello,
I have a search application with a number of search criteria on the top of the screen. Once the user enters the search, the screen does a small validation and then hits a hidden a4j:commandButton. The results are displayed in the bottom. The reRender works fine when the number of search results are low. But when the number is high, it takes a bit longer for display, which confuses the users. The code is given below:
ScreenButton:
<a4j:commandButton
id="submitButton" value="Submit"
onclick="submitSearch();" >
Script:
function submitSearch(){
var selAttOperator = document
.getElementById("mySearch:selDD")[document
.getElementById("mySearch:selDD").selectedIndex].value;
var proceed = true;
if ("ABC" == selAttOperator){
if (null== fromv ||''== fromv){
alert("Please enter Value 1");
proceed = false;
}
if (null== tov ||''== tov){
alert("Please enter Value 2");
proceed = false;
}
}
if (proceed){
document.getElementById("mySearch:submitButton").disabled=true;
document.getElementById("imageLoading").style.visibility = "visible";
document.getElementById("mySearch:hdnSubmitButton").click();
}
}
Hidden Button:
<a4j:commandButton id="hdnSubmitButton" style="visibility: hidden" action="#{myBean.executeQuery}"
styleClass="submit-button" reRender="val1,val2,val3,val4,val5,resultList,val6,val7,val8"
onclick="document.getElementById('imageLoading').style.visibility = 'visible';document.getElementById('mySearch:resultList').style.visibility='hidden';"
oncomplete="document.getElementById('mySearch:submitButton').disabled=false;document.getElementById('imageLoading').style.visibility = 'hidden';
document.getElementById('mySearch:resultList').style.visibility='visible';"/>
Search Results are displayed in a rich:dataTable with an id of resultList.
As it is shown above, we have tried all options of hiding the submit button, displaying a "Loading" image and the hiding the results until the new results come in place, but even then the problem occurs quite frequently. Kindly advice.
Regards,
Nid............