【问题标题】:Primefaces Form with 2 buttons dont update带有 2 个按钮的 Primefaces 表单不更新
【发布时间】:2017-06-14 18:22:59
【问题描述】:

我有一个输入文本的表单,操作员在其中输入 clientid 并单击“搜索”,当搜索完成后,表单中的其他字段被正确填充。

然后我有按钮“新记录”,它调用创建另一个对象(不是客户)并需要持久化它的过程,当在 bean 中创建另一个对象时,它会从表单中获取除时间戳之外的每个字段.

当对象被持久化时,只有时间戳在数据库中,所有的表单值都设置为空。

<h:form id="myForm">
    <h:outputText value="Customer number" /> 
    <h:inputText id="cIdentidad" value="#{custBean.custID}" />
    <p:commandButton  process="@all" update="@all"  action="#{custBean.populateFields(custBean.custID)}" value="Search" />               
    <p:growl />

    <h:panelGrid id="newCust" columns="2" style="margin-top: 15px">
        <h:outputText value="Name" /> 
        <h:inputText id="name" value="#{custBean.name}" disabled="true"/>
        <h:outputText value="more fields" /> 
        <h:inputText id="nroAgenda" value="#{custBean.morefields}" disabled="true"/>
    </h:panelGrid>

    <p:commandButton  process="@all" update="@all"  action="#{custBean.newRecord()}" value="New record" />
</h:form>

【问题讨论】:

  • bean 是 sessionscoped

标签: forms jsf primefaces


【解决方案1】:

h:inputText 被禁用,因此该值不会提交给服务器。也许你正在寻找readonly="true"

我也不会在任何地方使用@all,而是使用@formupdate="@all" 有一个特殊的meaning

另请参阅this 答案。

【讨论】:

    猜你喜欢
    • 2018-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-08
    • 2014-05-10
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多