joc joc - 15 days ago 6
Ajax Question

Bean binding not working in ajax call

I have a flow defining a helper that submits correctly the data

<var name="contactForm" class="my.package.bean.ContactFormHelper"/>


To get some data based on user input I use in the view an ajax call on the binded attribute
String id
in this way:

<h:panelGroup >
<p:outputLabel for="id" value="ID" />
<p:inputText id="id" required="true" value="#{contactForm.id}" label="ID">
<f:ajax
event="change"
listener="#{contactController.identifyCustomer(contactForm)}"
render="anotherPanel"
/>
<p:clientValidator/>
</p:inputText>
<p:message for="id" />
</h:panelGroup>


But when
identifyCustomer
is executed only the field where ajax is placed (
String id
) is updated. The rest of fields are filled with default values.

LOG TRACE


[21/11/16 17:10:12:508 CET] 0000007a SystemOut O DEBUG [WebContainer : 0 : 8610ff45-f4c5-4faf-a370-efa36701bc01] - ContactForm[name=, surnames= , nif=46713535Y]


Some idea of why is this happening?

joc joc
Answer

I've found a solution with process using @this and fields sepparated by commas:

<p:ajax 
    event="change" 
    listener="#contactController.identifyCustomer(contactForm)}"
    <!-- add process with the fields to bind -->
    process="@this name,surname1,surname2"
    update="newCustomerPanel" 
/>

Hope it help to others.