Dashboard usando <p:knob>
La pagina index.xhtml
- usamos <p:knob> colocamos el value y el max con el mismo valor.
CĆ³digo
<b:column span="4">
<h3><p:outputLabel value="#{msg['label.totalarticulo']}"/></h3>
<div class="knob-container ui-corner-all">
<p:knob value="#{dashboardIndexController.totalarticulos}" max="#{dashboardIndexController.totalarticulos}"
disabled="true"
foregroundColor="red" backgroundColor="#00000"
/>
</div>
</b:column>
<h3><p:outputLabel value="#{msg['label.totalarticulo']}"/></h3>
<div class="knob-container ui-corner-all">
<p:knob value="#{dashboardIndexController.totalarticulos}" max="#{dashboardIndexController.totalarticulos}"
disabled="true"
foregroundColor="red" backgroundColor="#00000"
/>
</div>
</b:column>
Controller
@Named
@ViewScoped
public class DashboardIndexController implements Serializable {
// <editor-fold defaultstate="collapsed" desc="fields">
private static final long serialVersionUID = 1L;
@Inject
ClienteRepository clienteRepository;
@Inject
AlmacenRepository almacenRepository;
@Inject
ArticuloRepository articuloRepository;
@Inject
OrdenRepository ordenRepository;
@Inject
ResourcesFiles rf;
Integer totalarticulos;
Integer totalclientes;
Integer totalordenes;
// </editor-fold>
/**
* Creates a new instance of DashboardController
*/
public DashboardIndexController() {
}
// <editor-fold defaultstate="collapsed" desc="init">
@PostConstruct
public void init() {
calcularTotales();
} // </editor-fold>
public Integer getTotalordenes() {
return totalordenes;
}
public void setTotalordenes(Integer totalordenes) {
this.totalordenes = totalordenes;
}
public Integer getTotalclientes() {
return totalclientes;
}
public void setTotalclientes(Integer totalclientes) {
this.totalclientes = totalclientes;
}
public Integer getTotalarticulos() {
return totalarticulos;
}
public void setTotalarticulos(Integer totalarticulos) {
this.totalarticulos = totalarticulos;
}
// <editor-fold defaultstate="collapsed" desc="metodo()">
public void calcularTotales(){
try {
totalarticulos = articuloRepository.count(new Document("activo","si"));
totalclientes = clienteRepository.count(new Document("activo","si"));
totalordenes =ordenRepository.count(new Document("activo","si"));
} catch (Exception e) {
JsfUtil.errorMessage("calcularTotales() "+e.getLocalizedMessage());
}
}
// </editor-fold>
}
Comments