混合Ajax和全面的要求在JSF 2.0全面、Ajax、JSF

2023-09-10 20:09:13 作者:浪荡少女心

在JSF code这是给我的问题是这样的:

The JSF code which is giving me problems is the following:

<h:panelGrid columns="3">
          <!-- Minimum Password Length -->
          <h:outputText value="#{i18n['xxx']}:" />
                        <h:inputText id="minLength"
                                     value="#{passwordPolicies.minLength.paramValue}"
                                     required="true">
                            <f:validateLongRange minimum="1"/>
                            <f:ajax event="valueChange"
                                    render="@this minLengthMessage"
                                    listener="passwordPolicies.testListener"/>
                        </h:inputText>
                        <h:message id="minLengthMessage"
                                   for="minLength"
                                   errorClass="error"
                                   tooltip="true"/-->
                <!-- Many other validation fields -->
<h:panelGrid/>

首先,我有一个非常类似的问题,因为: F:阿贾克斯听众从来没有发射 。我必须结合Ajax和全面的要求对我的JSF页面。 吉姆·德里斯科尔@ java.net 说,为了让这2个工作,一个Ajax错误监听必须设置?这是非常diferent比的监听器的财产的 AJAX 的标签?

Firstly, I am having a very similar issue as: f:ajax listener never fired . I must combine Ajax and full requests on my JSF page. Jim Driscoll @ java.net says that in order for these 2 to work, an Ajax error listener must be set up? Is this very much diferent than the listener property of the ajax tag?

现在,我知道我可以尝试Primefaces号码:inputText的和p:AJAX标签,但这些都需要我为我所有的字段进行验证个别的收听。有没有办法来解决这个F:Ajax错误的倾听者,才能被触发,并没有得到讨厌的:

Now, I know I could try Primefaces p:inputText and p:ajax tags, but these would require me individual listeners for all my fields that are validated. Is there a way to fix the f:ajax error listener, in order to be triggered and dont get the nasty:

感谢任何投入!

推荐答案

您需要让你的命令按钮来触发一个Ajax请求,而不是。

You need to make your command button to fire an ajax request instead.

<h:commandButton value="Submit" action="#{bean.submit}">
    <f:ajax execute="@form" render="@form" />
</h:commandButton>

这些&LT; F:AJAX&GT; 听众都不是强制性的。他们只是用作吉姆的文章来说明竞争条件的一个例子。其中被调用第一?很明显,你想先调用监听器。

Those <f:ajax> listeners are not mandatory. They were just used as an example in Jim's article to illustrate the race condition. Which get invoked first? Obviously you'd like to invoke the listeners first.

几乎相同种类的形式的一个实际例子可以在中的本教程。只有模糊是被用来代替 valueChange ,因为 valueChange 如果模糊了一个 =需要真正的字段,保持为空,导致了价值需要将不会被调用消息绝不会就这么展现出来场。

A practical example of almost the same kind of form can be found in this chapter of this tutorial. Only blur is been used instead of valueChange, because the valueChange won't be invoked when you blur a required="true" field which is kept empty which causes that the "Value is required" message will never show up on such a field.