I understand that Primefaces Layout and Dashboard have state which can be saved.
Could someone help me with snippet code (or some tutorial / how to ) site on how to save Primefaces layout (fullpage) into some persistent database or file.
In this case, I want to enable user to save their own preferences regarding size of the layoutUnit, which layoutUnit is minimized and closed and such whenever they login.
Thank you
ps: I am using Primefaces 2.2 running on Tomcat - essentially the same configuration as downloadable showcase.
You just respond to the events and save the state. User manual gives the details.
<p:layout closeListener="#{layoutBean.handleClose}" toggleListener="#{layoutBean.handleToggle}" resizeListener="#layoutBean.handleResize}"/>
public void handleClose(CloseEvent event) {
LayoutUnit closedUnit = event.getComponent(); //now get all the info related to closedUnit
}
public void handleResize(ResizeEvent event) {
LayoutUnit resizedUnit = event.getComponent(); //now get all the info related to resizedUnit
}
public void handleToggle(ToggleEvent event) {
LayoutUnit toggledUnit = event.getComponent(); //now get all the info related to toggledUnit
Visibility status = event.getVisibility();
}
Now the state can be saved in database and to reproduce the saved state, attributes of the layout units can be set as per the state saved earlier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With