Reputation: 886
I have dashboard and 3 widgets added to it.
<ui:define name="mainContent">
<h:form id="dashboard" styleClass="main-page-dashboard">
<p:dashboard id="board" model="#{serviceDashboardController.model}">
<p:ajax event="reorder"
listener="#{serviceDashboardController.handleReorder}" />
<p:panel id="calendar" header="#{msg.day_agenda}"
styleClass="calendar-dashboard dashboard-inner">
<ui:insert name="registry">
<ui:include src="/html/services/day_agenda_dashboard.xhtml" />
</ui:insert>
</p:panel>
<p:panel id="notary_tasks" header="#{msg.tasks}" styleClass="task-dashboard dashboard-inner">
<ui:insert name="notary_registry">
<ui:include src="/html/services/inboxMessages.xhtml" />
</ui:insert>
<p:link outcome="/html/services/inbox"
value="#{msg.more_not_tasks}" styleClass="enot-more-link" />
</p:panel>
<p:panel id="registry" header="#{msg.notary_registry}"
styleClass="registry-dashboard dashboard-inner">
<ui:insert name="registry">
<ui:include src="/html/services/notary_registry_dashboard.xhtml" />
</ui:insert>
</p:panel>
</p:dashboard>
</h:form>
</ui:define>
So.. User can reorder all 3 widgets.
What I need to do is, to save the state(position) of reordered widgets.
Now I know how to check the possition of every widget by event.getWidgetId()
,event.getColumnIndex()
but I am looking for all dashboard arrangement, if there is something like that.
So after user reorder it, I could save it, so user after reconnecting would see dashboard as he left before, not by default set-up.
EDIT: just now thought that all columns we add widgets to, is added to model.
model.addColumn(column1);
model.addColumn(column2);
model.addColumn(column3);
column1.addWidget("calendar");
column1.addWidget("notary_tasks");
column1.addWidget("notary_registry");
So I imagine, I should dig deeper into model
..
So if anyone has more ideas, feel free to.. :)
tomcat 7, Primefaces 5.1, Mojarra 2.2
Upvotes: 1
Views: 971
Reputation: 886
So, the answer was kinda easy, just needed to read some documentation ofcourse. ! :)
So, state of the dasboard can be saved with JSF method getColumns();
List<DashboardColumn> dashboardList = model.getColumns();
And then all you need is to pick format you saving it, for my example it's Json
beeing saved on alfresco Share.
public String getModelWidgets() {
List<DashboardColumn> dashboardList = model.getColumns();
Gson gson = new Gson();
String toJson = gson.toJson(dashboardList);
return toJson;
}
Upvotes: 2