【问题标题】:Bean binding not working in ajax call [duplicate]Bean绑定在ajax调用中不起作用[重复]
【发布时间】:2017-04-05 02:22:25
【问题描述】:

我有一个流程定义了一个可以正确提交数据的助手

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

为了根据用户输入获取一些数据,我在视图中以这种方式对绑定属性String id 使用了ajax 调用:

<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被执行时,只有放置ajax的字段(String id)被更新。其余字段使用默认值填充。

记录跟踪

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

了解为什么会发生这种情况?

【问题讨论】:

标签: ajax jsf primefaces


【解决方案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" 
/>

希望对其他人有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-19
    • 1970-01-01
    相关资源
    最近更新 更多