This example shows how to load dialog's content lazily. To achieve that, we need to use dynamic="true" attribute of the <p:dialog />. In this case the dialog fetches its content just before it is displayed rather than initial page load. This is a useful feature to speed up the page initial load time.
@ManagedBean
@ViewScoped
public class ExampleBean {
public String getTime() {
return LocalTime.now().toString();
}
}
To try examples, run embedded tomcat (configured in pom.xml of example project below):
mvn tomcat7:run-war
Output
Note that, only first invocation of the dialog will load it's content, the subsequent invocations won't update the dialog content dynamically. For dynamic content update check out the next example.
Example Project
Dependencies and Technologies Used:
primefaces 6.1 primefaces
jsf-api 2.2.14:
This is the master POM file for Oracle's Implementation of the JSF 2.2 Specification.
jsf-impl 2.2.14:
This is the master POM file for Oracle's Implementation of the JSF 2.2 Specification.