-1
I am trying to add the values added in the column "Value", IE, to each entry of a recipe the total field below needs to update doing the sum of the values in the column value, however I am with the type Bigdecimal, so I can’t do the sum and in the view no result appears, only the outputLabel value="Total REVENUE" which is the string.
Model:
@NotNull
@DecimalMin("0")
@Column(precision = 10, scale = 2, nullable = false)
private BigDecimal valor;
get e set
This method is in the Lancamento class (model)
@Transient
public void valorTotal(Lancamento lancamento) {
BigDecimal total = BigDecimal.ZERO;
total = total.add(this.getValor());
this.setValor(total);
}
Enum
RECEITA("Receita"),
DESPESA("Despesa");
get e set
Na View:
<p:dataTable value="#{consultaLancamentosBean.lancamentos}" var="lancamento">
<p:column>
<p:outputLabel value="Total RECEITA:" style="font-weight: bold; text-align: right; font-size: 1.1em" />
<h:outputText id="totalReceita" value="#{lancamento.valorTotal(lancamento)}">
<f:convertNumber type="currency" />
</h:outputText>
</p:column>
Another problem:
Exibi.
<p:outputLabel value="Total RECEITA: />
Não exibi o valorTotal
<h:outputText value="#{lancamento.valorTotal(lancamento)}" />
With this method the value is not being added to each insertion, it is only taking value that is already in the value column, without adding values.
– Frederico Queiroz