在更改selectOneMenu时重置inputtext

时间:2014-01-14 09:55:58

标签: jsf-2

当用户在selectOneMenu中选择“选择国家/地区管理员”时,我想清除inputText,我可以通过更改itemValue =“”来执行此操作,但是对于提交时的required =“true”条件,它失败了

<h:selectOneMenu id="eidx" value="#{countryBean.selectedEid}" required="#{!countryBean.isEditMode}" 
        requiredMessage="#{msg['country.label.validation.select.countryadmin']}" >
                <f:selectItem  itemLabel="Select Country Admin" itemValue="#{null}"/>
                <f:selectItem itemLabel="Add New User" itemValue="1"/>
                <f:selectItems value="#{countryBean.allUserDetails}" var="user" itemLabel="#{user.lastName}, #{user.firstName} | (#{user.eid})" itemValue="#{user.eid}"/>
              <p:ajax listener="#{countryBean.getUserDetail}"  process="@this" update="userDetailPanel" onstart="statusDialog.show();" oncomplete="statusDialog.hide();"/>
        </h:selectOneMenu>
    </div>
    <h:panelGroup id="userDetailPanel">
    <div class="clear">&nbsp;</div>
      <div class="form-label">
        <label title="EID" for="EID">#{msg['country.label.EID']}</label>
         </div>
         <div class="form-field" >
         <h:inputText id="eidPX" value="#{countryBean.usersDetailsDTO.eid}"  disabled="#{not(countryBean.selectedEid eq '1')}" resetValues="true">
         <f:validator validatorId="regexVal"/>
        </h:inputText>
    </div>
    <div class="clear">&nbsp;</div>
    <div class="form-label">
        <label title="EID" for="EID">#{msg['country.label.FirstName']}</label>
    </div>
    <div class="form-field" >
         <h:inputText validatorMessage="#{msg['country.label.validation.select.first.name']}" required="#{(countryBean.selectedEid eq '1')}" requiredMessage="Enter first Name" value="#{countryBean.usersDetailsDTO.firstName}" id="empFName" disabled="#{not(countryBean.selectedEid eq '1')}">
        <f:validator  validatorId="nameValidation" />
        </h:inputText>
    </div>
    <div class="clear">&nbsp;</div>
    <div class="form-label">
        <label title="EID" for="EID">#{msg['country.label.lastname']}</label>
    </div>

1 个答案:

答案 0 :(得分:0)

我是通过使用javascript

完成的
document.getElementById("eidx").value="";