监听器未被调用

I have a problem with listener not being invoked in the below selectOneMenu

<h:selectOneMenu id="Country" value="#{bean.country}">
   <f:ajax render="inputId" listener="#{backingBean.clearMethod}" />
     <f:selectItem itemLabel="-Select One-" itemValue="_" noSelectionOption="true"/>
     <f:selectItems value="#{optionValues['countryList']}" />
</h:selectOneMenu>
<h:inputText id="inputId" value="#{bean.city}"/>

The optionValues resolver is used to resolve a country list options from an xml file. It has USA, Canada and Mexico. My problem is when I change the option from USA to Canada or Select One to USA, the clearMethod is invoked. But When I change the option from USA to Select One, the clearMethod is not invoked.

Any help would be appreciated.

I think the problem is the itemValue attribute in the noSelectionOption. It will problably cause a validation error and therefore the listener is not called.

Try to remove the itemValue attribute.

(Btw: in your code the value attribute of selectOneMenu is not bound to a backing bean field. Or is it a typo?)