[Solve] Dashboard Panels from Bean?

UI Components for JSF
Post Reply
User avatar
wasaaa
Posts: 16
Joined: 26 Oct 2010, 17:26

27 Oct 2010, 07:49

Hello Community!

I really like this component, however i can't do the next thing: I want to iterate (maybe with "ui:repeat"?) and add panels to the first column of the dashboard... is it possible? 'Cause I only find, like showcase example, the method with and "static id"... and "id" can't be replicated of course...

Cheers!
Last edited by wasaaa on 27 Oct 2010, 23:26, edited 1 time in total.
Netbeans 6.9.1 + Glassfish v3 + PrimeFaces 2.2.RC2

User avatar
wasaaa
Posts: 16
Joined: 26 Oct 2010, 17:26

27 Oct 2010, 23:25

Okey, I've resolve watching others posts and finally binding Dashboard component. The solution is similarly to the next one:

CrearHojaDeRutaController.java (It's important, when binding components to back beans, keeping the RequestScoped...)

Code: Select all

@Named(value = "crearHojaDeRutaController")
@RequestScoped
public class CrearHojaDeRutaController {

    private Dashboard dashboard;

    public CrearHojaDeRutaController() {
        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();
        DashboardColumn column1 = new DefaultDashboardColumn();
        DashboardColumn column2 = new DefaultDashboardColumn();
        model.addColumn(column1);
        model.addColumn(column2);
        dashboard.setModel(model);

        List<String> actividades = new ArrayList<String>();
        for (int i = 0; i < 5; i++) {
            actividades.add("Task" + i);
        }

        for (String act : actividades) {
            Panel panel = (Panel) application.createComponent(fc, "org.primefaces.component.Panel", "org.primefaces.component.PanelRenderer");
            panel.setId(act);
            panel.setHeader("Actividad");
            panel.setClosable(true);
            panel.setToggleable(true);

            dashboard.getChildren().add(panel);
            column1.addWidget(panel.getId());
            HtmlOutputText text = new HtmlOutputText();
            text.setId("t"+act);
            text.setValue("Contenido de la Actividad ");

            panel.getChildren().add(text);
        }

    }

//Getters / Setters
HojaRuta.xhtml

Code: Select all

<h:form>
                     <p:dashboard id="board" binding="#{crearHojaDeRutaController.dashboard}">

                        </p:dashboard>
</h:form>
Cheers!
Netbeans 6.9.1 + Glassfish v3 + PrimeFaces 2.2.RC2

Tuvshin09
Posts: 93
Joined: 19 Feb 2010, 11:59

24 Nov 2010, 14:52

great... Thanks a lot for post.
Tuvshin

alfmateos
Posts: 5
Joined: 26 Mar 2014, 18:14

25 Mar 2015, 14:37

Thanks a lot! It was really useful for me!

Zardo
Posts: 56
Joined: 29 Jul 2015, 15:41

03 Aug 2015, 14:13

Very useful, thx a lot!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 23 guests