0

I've got a row of several h:inputText fields to receive numbers and an h:outputText field to display the total of those numbers. When one of the inputText values changes I want to update the underlying database record and then to re-render the total field at the end of the row. E.g. the ui elements are: rcvd0, rcvd1, rcvdTotal. I want all this to happen without submitting the form.

I've managed to capture the value changes and to update the underlying database record(s) by using a valueChangeListener. I'm using the p:ajax tag so I don't have to wait until the form is submiited. So far, so good.

What I can't achieve is re-rendering the total field. Here is the view code for my components:

<h:inputText id="rcvd0" value="#{shareoutSlip.receivedMember[0]}" size="7" valueChangeListener="#{orderFormBean.handleReceivedChange}">
    <f:converter converterId="bigDecimalPlainDisplay" />
    <p:ajax render="rcvdTotal" />
</h:inputText>

<h:inputText id="rcvd1" value="#{shareoutSlip.receivedMember[1]}" size="7" valueChangeListener="#{orderFormBean.handleReceivedChange}">
    <f:converter converterId="bigDecimalPlainDisplay" />
    <p:ajax render="rcvdTotal" />
</h:inputText>

<h:outputText id="rcvdTotal" value="#{shareoutSlip.receivedTotal}">
    <f:converter converterId="bigDecimalPlainDisplay" />
</h:outputText>

The valueChangeListener method is being called ok and it does the right things. The code doesn't seem to re-render the rcvdTotal field. I've tried all sorts of combinations of ajax attributes in the ajax tag, e.g. execute="rcvd0" render="rcvdTotal". I've also played around with @this, @form, @all as attribute values but to no avail.

I've got to say that I'm fairly pleased with JSF and PrimeFaces but I find the event model to be very confusing, partly due to the lack of a good text or course. If anyone can advise on a good resource covering the event model in particular then I'd be very grateful. It would seem that this is vital for an indepth understanding of JSF. Thank you.

tommccann
  • 123
  • 9

0 Answers0