Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving Primefaces layout state

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.

like image 399
Aditya Avatar asked Aug 12 '11 09:08

Aditya


1 Answers

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.

like image 100
rags Avatar answered Oct 11 '22 07:10

rags