Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.calldesk.cqp.jsf;
- import javax.faces.bean.ManagedBean;
- import javax.faces.component.html.HtmlInputText;
- import javax.faces.component.html.HtmlOutputLabel;
- import javax.faces.component.html.HtmlPanelGrid;
- import javax.faces.context.FacesContext;
- import javax.faces.event.ActionEvent;
- import javax.faces.view.ViewScoped;
- import org.primefaces.component.dashboard.Dashboard;
- import org.primefaces.component.panel.Panel;
- import org.primefaces.event.CloseEvent;
- import org.primefaces.model.DashboardColumn;
- import org.primefaces.model.DashboardModel;
- import org.primefaces.model.DefaultDashboardColumn;
- import org.primefaces.model.DefaultDashboardModel;
- import com.calldesk.cqp.form.Form;
- import com.calldesk.cqp.form.FormItem;
- @ManagedBean
- @ViewScoped
- public class MonitoringFormDashboard {
- private Dashboard dashboard;
- private Form form;
- private FormItem newField;
- public MonitoringFormDashboard() {
- FacesContext fc = FacesContext.getCurrentInstance();
- dashboard = (Dashboard) fc.getApplication().createComponent(fc, "org.primefaces.component.Dashboard", "org.primefaces.component.DashboardRenderer");
- dashboard.setId("formDashboard");
- this.newField = new FormItem("", 0);
- /* TEST */
- form = new Form("TestForm");
- /* END TEST */
- }
- private void buildModel() {
- DashboardModel model = new DefaultDashboardModel();
- DashboardColumn column = new DefaultDashboardColumn();
- model.addColumn(column);
- FacesContext fc = FacesContext.getCurrentInstance();
- for(FormItem item : form) {
- Panel panel = (Panel) fc.getApplication().createComponent(fc, "org.primefaces.component.Panel", "org.primefaces.component.PanelRenderer");
- panel.setId("panel_"+item.hashCode());
- panel.setHeader(" * Clique e arraste para ordenar * ");
- panel.setClosable(true);
- this.dashboard.getChildren().add(panel);
- this.dashboard.getModel().getColumn(0).addWidget(panel.getId());
- HtmlPanelGrid grid = new HtmlPanelGrid();
- grid.setCellspacing("5");
- grid.setColumns(2);
- HtmlOutputLabel label = new HtmlOutputLabel();
- label.setValue(item.getName());
- label.setFor("inputText_" + item.hashCode());
- HtmlInputText inputText = new HtmlInputText();
- inputText.setId("inputText_" + item.hashCode());
- grid.getChildren().add(label);
- grid.getChildren().add(inputText);
- panel.getChildren().add(grid);
- }
- dashboard.setModel(model);
- }
- public void handleClose(CloseEvent event) {
- }
- public void addField(ActionEvent event) {
- this.form.addItem(new FormItem(newField.getName(), newField.getType()));
- newField.setName("");
- newField.setType(0);
- }
- public String getNewFieldName() {
- return this.newField.getName();
- }
- public String getNewFieldType() {
- return ""+this.newField.getType();
- }
- public void setNewFieldName(String name) {
- this.newField.setName(name);
- }
- public void setNewFieldType(String type) {
- this.newField.setType(Integer.parseInt(type));
- }
- public Dashboard getDashboard() {
- this.buildModel();
- return this.dashboard;
- }
- public void setDashboard(Dashboard dashboard) {
- this.dashboard = dashboard;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement