Search in sources :

Example 1 with ServerPushTemplate

use of org.adempiere.webui.util.ServerPushTemplate in project adempiere by adempiere.

the class DashboardRunnable method refreshDashboard.

/**
	 * Refresh dashboard content
	 */
public void refreshDashboard() {
    ServerPushTemplate template = new ServerPushTemplate(desktop);
    for (int i = 0; i < dashboardPanels.size(); i++) {
        //make sure context is correct
        Properties ctx = (Properties) template.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
        if (ctx != null) {
            ServerContext serverContext = ServerContext.getCurrentInstance();
            if (serverContext == null) {
                serverContext = ServerContext.newInstance();
                serverContext.putAll(ctx);
            } else {
                String id = ctx.getProperty(SessionContextListener.SERVLET_SESSION_ID);
                if (id == null || !id.equals(serverContext.getProperty(SessionContextListener.SERVLET_SESSION_ID))) {
                    serverContext.clear();
                    serverContext.putAll(ctx);
                }
            }
        }
        dashboardPanels.get(i).refresh(template);
    }
    //make sure context is correct
    Properties ctx = (Properties) template.getDesktop().getSession().getAttribute(SessionContextListener.SESSION_CTX);
    if (ctx != null) {
        ServerContext serverContext = ServerContext.getCurrentInstance();
        if (serverContext == null) {
            serverContext = ServerContext.newInstance();
            serverContext.putAll(ctx);
        } else {
            String id = ctx.getProperty(SessionContextListener.SERVLET_SESSION_ID);
            if (id == null || !id.equals(serverContext.getProperty(SessionContextListener.SERVLET_SESSION_ID))) {
                serverContext.clear();
                serverContext.putAll(ctx);
            }
        }
    }
    appDesktop.onServerPush(template);
}
Also used : ServerContext(org.adempiere.webui.session.ServerContext) ServerPushTemplate(org.adempiere.webui.util.ServerPushTemplate) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)1 ServerContext (org.adempiere.webui.session.ServerContext)1 ServerPushTemplate (org.adempiere.webui.util.ServerPushTemplate)1