In my home page(.xhtml),I’m having 4 h:inputText box and one serach button(h:commandButton)in JSF page
<h:inputText id="stlID" value="#{searchSettlementTransRequest.stlmtTransId}" name='stlmt'>
<h:inputText id="pmtID" value="#{searchSettlementTransRequest.pmtTransId}" name='pmt'>
<h:inputText id="AgentID" value="#{searchSettlementTransRequest.AgentId}" name='agnt'>
<h:inputText id="AgencyID" value="#{searchSettlementTransRequest.AgencyId}" name='agncy'>
<h:commandButton id="tranSearchBtn" styleClass="valign first button-search sSearch" action="stlmtSubmit"/>
My requirement is:
- on entered data in 1st input field the other input fields should be disabled(ie. 2,3,4).
- on entered data in 2nd input field the other input fields should be disabled(ie. 1,3,4). and so on..
Note: at the sametime if user entered data in 1st or 2nd or 3rd or 4th (user dynamic)field and delete the same before leaving out the input field in such case all field should be enabled.
When i get response back(empty or non-empty data response) after clicking “search” button now all the input fields should be enabled for another search(now user may input data in any of the 4 fields)
If you want the inputs to be enabled after each page load you can have a flag representing the page is loaded and set that flag to false after each ajax request through an listener. And to ensure that the flag is set to true after complete page loads you can use
preRenderViewevent. You just need a method to be executed forpreRenderViewevent which set the flag to true if the page is loaded through complete request rather than an ajax request. If the page is loaded with ajax request,faces-requestparameter will be set to “partial/ajax”.And if you want to disable other inputs whenever the user writes into one of the fields, you can make an ajax call after a blur event to change the state of other input fields and set the
pageIsLoadedWithFullRequestflag to false in a listener.If you want to disable them through ajax you should add the f:ajax command and render all four of these inputTexts. Example:
Unrelated It is not a good practice to capitalize the first letters of variables such as AgentId, AgencyID, it should be better if you change them to agentId and agencyID.
Cheers