java - primefaces creating a dynamic dashboard -
following example @ http://www.wobblycogs.co.uk/index.php/computing/jee/49-dynamic-dashboard-with-primefaces im trying create dynamic dashboard.
copying code works 100% perfeclty, im trying use own implementation.
when load index page dosnt show panels or dashboard @ all. when navigate differet page, , come elements appear!
i have no idea why dashboard not displayed on initial page load.
im working jboss 5.1, ejb 3.0, jsf 2.0 , primefaces 3.4.
this top of controller class:
@model @viewcontroller(viewid = "/pages/index.xhtml") public class monitorcontroller implements serializable, viewinitializer, viewfinalizer { @inject private transient monitorservice monitorservice; @inject private transient monitoruserservice monitoruserservice; @inject private transient monitorview view; @inject private transient conversation conversation; @override public void initializeview() { if (conversation.istransient()) { conversation.settimeout(1800000); conversation.begin(); } monitoruser user = monitoruserservice.findorcreateuser(); view.setuser(user); list<monitorelement> elements = monitorservice.findmonitorelementsbyuser(); view.setelements(elements); view.setusersmonitorelements(elements); createdashboard(); }
this method creating dashboard, adding panels , setting column widgets:
public void createdashboard() { final int default_column_count = 3; int columncount = default_column_count; dashboard dashboard; facescontext fc = facescontext.getcurrentinstance(); application application = fc.getapplication(); dashboard = (dashboard) application.createcomponent(fc, "org.primefaces.component.dashboard", "org.primefaces.component.dashboardrenderer"); dashboard.setid("dashboard"); dashboardmodel model = new defaultdashboardmodel(); for( int = 0; < columncount; i++ ) { dashboardcolumn column = new defaultdashboardcolumn(); model.addcolumn(column); } dashboard.setmodel(model); view.setmodel(dashboard.getmodel()); view.setdashboard(dashboard); int index = 0; for( monitorelement : view.getusersmonitorelements()) { panel panel = (panel) application.createcomponent(fc, "org.primefaces.component.panel", "org.primefaces.component.panelrenderer"); panel.setid("id" + i.getid()); panel.setheader("dashboard component " + i.getapplicationname()); panel.setclosable(true); panel.settoggleable(true); dashboard.getchildren().add(panel); dashboardcolumn column2 = model.getcolumn(index%columncount); column2.addwidget(panel.getid()); htmloutputtext text = new htmloutputtext(); text.setvalue(i.getcount() + "" ); panel.getchildren().add(text); index++; } view.setmodel(dashboard.getmodel()); view.setdashboard(dashboard); }
i implementing dashboard on index page using:
<p:dashboard id="dynamic_dashboard3" binding="#{monitorview.dashboard}"> </p:dashboard>
Comments
Post a Comment