2

单击提交按钮后,它没有命中我的托管 bean,但也没有显示验证消息。我觉得这很简单,不知道为什么它不起作用。

<h:form prependId="false">
  <table class="contactForm">
    <tr>
      <td>Name: </td>
      <td><p:inputText size="20" id="name" value="#{contactManagedBean.name}" required="true" requiredMessage="Name is required" /></td>
      <td><p:message for="name" /></td>
    </tr>
    <tr>
      <td>Email: </td>
      <td><p:inputText size="20" id="email" value="#{contactManagedBean.email}" required="true" requiredMessage="Email is required" /></td>
      <td><p:message for="email" /></td>
    </tr>
    <tr>
      <td>Phone (###-###-####) (Optional): </td>
      <td><p:inputText size="20" id="phone" maxlength="12" value="#{contactManagedBean.phone}"/></td>
      <td><p:message for="phone" /></td>
    </tr>
    <tr>
      <td>Comments: </td>
      <td><p:inputTextarea rows="5" cols="30" id="comments" value="#{contactManagedBean.comments}" required="true" requiredMessage="Please enter some comments"></p:inputTextarea></td>
      <td><p:message for="comments" /></td>
    </tr>
    <tr>
      <td colspan="3" style="text-align: center;"><p:commandButton value="Submit" actionListener="#{contactManagedBean.submitComment()}" /></td>
    </tr>
  </table>
</h:form>
4

1 回答 1

6

将 id 添加到 h:form 并将更新属性添加到按钮。前任:

<h:form id="form">
...
<p:commandButton value="Submit" update="form" actionListener="#{contactManagedBean.submitComment()}" />
</h:form>
于 2013-11-13T01:23:31.360 回答