I am writing an application using JSF 2.0.
For one of the pages there is a section of the page that takes a lot of time.
To improve the user interface, I'm going to load the page first, and then automatically make an Ajax call to the JSF control bean after the page loads successfully after the first load.
I am thinking of using f: event with a postAddView type.
<h:outputText id="dummyId">
<f:event type="postAddToView" listener="#{mngBean.doSomething}" />
</h:outputText>
However, it seems that the f: postAddToView event is still being processed before the page is displayed for the first time.
Other options I'm learning is to create a hidden button and run javascript. It works, however, I'm just wondering if there is a good JSF component / event that can do this, instead of using a java script.
Thank you for your help.
<h:commandButton id="dmyButton"
value = "# {mngBean.getSomething}" ActionListener = "# {mngBean.doSomething}" style = "display: none" type = "send">
Java script
<script language="JavaScript">
$(document).ready(function() {
if (document.getElementById('form:dmyButton').value == 'true') {
document.getElementById('form:dmyButton').click();
}
});
</script>
Thanks for your help in advance.
source
share