开发者

Does Rich Faces AjaxValidator work with selectOneMenu

Folks,

This is a JSF question, specifically for 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.

Basically I want AJAX validation to happen when the drop down loses focus or an item in the drop down is selected. Below is code for the last thing I tried:

<h:selectOneMenu id="sector" value="#{thing.s开发者_C百科ector}">  
  <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.

Has anyone managed to get Rich Faces AJAX validation working for the selectOneMenu field and how did you it? Oh and for what version of Rich Faces?

Thanks.


Here is a sample from my old app using 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜