DataTable + AJAX
lfelipeas Jun 27, 2011 2:39 PMI have a page that generates a datatable from a search filter choosed by the user. In this datatable, exists 2 fields: hour and value. Initially, their values come from the database. Hour is editable, and value isn't, but is calculated according to the number of hours provided.
So, when the user modify the value, my datatable is rerendered and the new value is calculated.
I'm trying to use AJAX to do this, but it isn't working.
Here are the codes:
My page.xml:
<rich:column> <f:facet name="header"> <h:outputText value="Horas"/> <ui:param name="entityList" value="#{pmnMedicaoGrupoProfissionalList.medicoesProfissionais}"/> <ui:param name="propertyPath" value="resultList.nuHoras"/> </f:facet> <h:inputText value="#{_resultList.nuHoras}" size="5" maxlength="5"> <a4j:support action="#{pmnMedicaoGrupoProfissionalList.calculeValorTotalAction()}" reRender="resultList" event="onblur" immediate="true" /> </h:inputText> </rich:column> <rich:column> <f:facet name="header"> <h:outputText value="Valor"/> <ui:param name="entityList" value="#{pmnMedicaoGrupoProfissionalList.medicoesProfissionais}"/> <ui:param name="propertyPath" value="resultList.vlMedicao"/> </f:facet> <h:outputText value="#{_resultList.vlMedicao eq null ? 0 : _resultList.vlMedicao}" id="valorTotal"> <f:convertNumber minFractionDigits="2" maxFractionDigits="2"></f:convertNumber> </h:outputText> </rich:column>
My bean:
@Begin(join=true) public String calculeValorTotalAction() { for (PmnMedicaoProfissional item : medicoesProfissionais) { if (item.getNuHoras() == null) item.setNuHoras(0); if (item.getNuHoras() > 0) { calculeValorTotal(item); } else { item.setVlMedicao(new BigDecimal(0)); } } return "calculated"; }