2016-11-21 88 views
1

我有一个流程定义是提交正确的数据豆绑定不是Ajax调用工作

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

要在用户输入获取根据一些数据,我在视图中使用Ajax调用的绑定属性String id帮手以这样的方式

<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> 

但是,当阿贾克斯在那里放置identifyCustomer只执行领域(String id)被更新。其余的字段都填入默认值。

LOG TRACE

[21/11/16 17:10:12:508 CET] 0000007a SystemOut O调试[Web容器:0:8610ff45-f4c5-4faf-A370-efa36701bc01] - 的ContactForm [名称=,=姓氏,NIF = 46713535Y]

的为什么会这样的一些想法?

+0

这个例子中只有一个字段... [mcve]请(你是否尝试过'p:ajax'?) – Kukeltje

+2

阅读本文http://stackoverflow.com/questions/25339056/understanding-primefaces- process-update-and-jsf-fajax-execute-render-attributes回答你的问题,我想 – Kukeltje

回答

1

我已经找到了解决方案使用由逗号分隔@this和领域process

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

希望它可以帮助别人。