简体   繁体   English

Rich Faces AjaxValidator 是否与 selectOneMenu 一起使用

[英]Does Rich Faces AjaxValidator work with selectOneMenu

Folks,伙计们,

This is a JSF question, specifically for Rich Faces 3.3.3.Final这是一个 JSF 问题,专门针对 Rich Faces 3.3.3.Final

I am trying to get the Rich Faces Ajax Validator (rich:ajaxValidator) to work with a standard JSF drop down menu (h:selectOneMenu) but I'm failing miserably.我正在尝试让 Rich Faces Ajax Validator (rich:ajaxValidator) 与标准 JSF 下拉菜单 (h:selectOneMenu) 一起使用,但我失败了。

Basically I want AJAX validation to happen when the drop down loses focus or an item in the drop down is selected.基本上我希望 AJAX 验证在下拉列表失去焦点或选择下拉列表中的项目时发生。 Below is code for the last thing I tried:以下是我尝试的最后一件事的代码:

<h:selectOneMenu id="sector" value="#{thing.sector}">  
  <f:selectItems value="#{selectItemMap['sectors']}"  
                 var="sector"  
                 itemLabel="#{msg[sector.itemLabel]}"  
                 itemValue="#{sector.itemValue}" />  
    <rich:ajaxValidator event="onblur"/>  
</h:selectOneMenu>  

But I've also tried:但我也试过:

<rich:ajaxValidator event="oninputblur"/>  

and

<rich:ajaxValidator event="onchange"/>  

and

<rich:ajaxValidator event="onchanged"/>  

and

     <rich:ajaxValidator event="onblur"/>  
<rich:ajaxValidator event="onchanged"/>

and

<rich:ajaxValidator event="onblur"/>  
<rich:ajaxValidator event="onchange"/>  

and

<rich:ajaxValidator event="oninputblur"/>  
<rich:ajaxValidator event="onchange"/>  

and

<rich:ajaxValidator event="oninputblur"/>  
<rich:ajaxValidator event="onchanged"/> 

However, none of these work.但是,这些都不起作用。 By which I mean that I can't see anything happening, although I can see events being handled in my log console for other fields like h:inputText, standard HTML input and rich:calendar.我的意思是我看不到任何事情发生,尽管我可以看到在我的日志控制台中处理其他字段(如 h:inputText、标准 HTML 输入和rich:calendar)的事件。

Has anyone managed to get Rich Faces AJAX validation working for the selectOneMenu field and how did you it?有没有人设法让 Rich Faces AJAX 验证适用于 selectOneMenu 字段,你是怎么做到的? Oh and for what version of Rich Faces?哦,对于什么版本的 Rich Faces?

Thanks.谢谢。

Here is a sample from my old app using Richfaces 3.3:这是我使用 Richfaces 3.3 的旧应用程序的示例:

<h:selectOneMenu
    id="users"
    value="#{userBean.user}"
    required="true"
    requiredMessage="Selected user is required."
    converter="selectItemConverter">
    <rich:ajaxValidator ajaxSingle="true" event="onchange" />
    <f:validator validatorId="isValidValidator" />
    <t:selectItems 
        value="#{userBean.users}"
        var="user" 
        itemLabel="#{user.name}"
        itemValue="#{user}" />
</h:selectOneMenu>
<rich:message for="users" errorClass="error"/>

Doh!嗬!

The following DOES work:以下确实有效:

<h:selectOneMenu id="subSector" value="#{registerContracts.currentContract.subSector}">
  <f:selectItems value="#{selectItemMap['RctSectorTypes']}" var="subSector" itemLabel="#{msg[subSector.itemLabel]}" itemValue="#{subSector.itemValue}" />
  <rich:ajaxValidator event="onblur"/>
  <rich:ajaxValidator event="onchange"/>
</h:selectOneMenu>

I obviously wasn't diligent enough in testing out the above-mentioned options.在测试上述选项时,我显然不够勤奋。

Sorry about that.对于那个很抱歉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM