日期:2014-05-16  浏览次数:20314 次

Ajax4jsf 和 <h:message>结合

  Ajax4jsf 和 <h:message> 一起使用时候的问题2008-12-31 15:52     如果在页面中使用了<a4j:commandButton>来提交表单,并且使用<h:message for="componentid">来显示一些组件的报错信息,比如:
<h:inputSecret id="password" value="#{userBean.user.password}" size="11" required="true">
     <f:validateLength minimum="6" maximum="30" />
</h:inputSecret>

<h:message for="password" showSummary="true" showDetail="false" />

<a4j:commandButton value="#{msg['common.create']}" action="#{userBean.saveUser}"/>

    如果输入密码不够六位,应该会在页面中显示报错信息,但是实际上却没有,只是在控制台打印出来了这样的消息:

WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.

    实际上在这种情况下,只需要用<a4j:outputPanel>来和<h:message>配合使用即可解决问题,如下所示:

<a4j:outputPanel ajaxRendered="true">
     <h:message for="password" showSummary="true" showDetail="false" />