Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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 <code>preRenderView</code> event. You just need a method to be executed for <code>preRenderView</code> event 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, <code>faces-request</code> parameter will be set to "partial/ajax". </p> <pre><code>public static final String INITIAL_VALUE = ""; // I assume your fields are integer and they are initialized to INITIAL_VALUE in the first place public Boolean pageIsLoadedWithFullRequest = true; public void preRenderView() { //check whether the request is an ajax request or not Map&lt;String, String&gt; requestHeaderMap = FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap(); if(!"partial/ajax".equals(requestHeaderMap.get("faces-request"))) { pageIsLoadedWithFullRequest = true; } </code></pre> <p>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 <code>pageIsLoadedWithFullRequest</code> flag to false in a listener.</p> <pre><code>public void madeAjaxRequest() { pageIsLoadedWithFullRequest = false; } public Boolean getStlIDEnabled() { return pageIsLoadedWithFullRequest || !stlmtTransId.equals(INITIAL_VALUE) &amp;&amp; pmtTransId.equals(INITIAL_VALUE) &amp;&amp; AgentId.equals(INITIAL_VALUE) &amp;&amp; AgencyId.equals(INITIAL_VALUE); } public Boolean getPmtTransIdEnabled() { return pageIsLoadedWithFullRequest || stlmtTransId.equals(INITIAL_VALUE) &amp;&amp; !pmtTransId.equals(INITIAL_VALUE) &amp;&amp; AgentId.equals(INITIAL_VALUE) &amp;&amp; AgencyId.equals(INITIAL_VALUE); } public Boolean getAgentIdEnabled() { return pageIsLoadedWithFullRequest || stlmtTransId.equals(INITIAL_VALUE) &amp;&amp; pmtTransId.equals(INITIAL_VALUE) &amp;&amp; !AgentId.equals(INITIAL_VALUE) &amp;&amp; AgencyId.equals(INITIAL_VALUE); } public Boolean getAgencyIdEnabled() { return pageIsLoadedWithFullRequest || stlmtTransId.equals(INITIAL_VALUE) &amp;&amp; pmtTransId.equals(INITIAL_VALUE) &amp;&amp; AgentId.equals(INITIAL_VALUE) &amp;&amp; !AgencyId.equals(INITIAL_VALUE); } &lt;f:event type="preRenderView" listener="#{searchSettlementTransRequest.preRenderView()}"/&gt; &lt;!--This will ensure that preRenderView method will be called right before rendering of the view ends --&gt; &lt;h:inputText id="stlID" value="#{searchSettlementTransRequest.stlmtTransId}" name='stlmt' disabled="#{not searchSettlementTransRequest.stlIDEnabled}"/&gt; &lt;h:inputText id="pmtID" value="#{searchSettlementTransRequest.pmtTransId}" name='pmt' disabled="#{not searchSettlementTransRequest.pmtTransIdEnabled}"/&gt; &lt;h:inputText id="AgentID" value="#{searchSettlementTransRequest.AgentId}" name='agnt' disabled="#{not searchSettlementTransRequest.AgentIdEnabled}"/&gt; &lt;h:inputText id="AgencyID" value="#{searchSettlementTransRequest.AgencyId}" name='agncy' disabled="#{not searchSettlementTransRequest.AgencyIdEnabled}"/&gt; </code></pre> <p>If you want to disable them through ajax you should add the f:ajax command and render all four of these inputTexts. Example:</p> <pre><code>&lt;h:inputText id="stlID" value="#{searchSettlementTransRequest.stlmtTransId}" name='stlmt' disabled="#{not searchSettlementTransRequest.stlIDEnabled}"&gt; &lt;f:ajax event="blur" listener=#{searchSettlementTransRequest.madeAjaxRequest()} execute="stlID pmtID AgentID AgencyID" execute="stlID pmtID AgentID AgencyID"/&gt; &lt;/h:inputText&gt; </code></pre> <p><b>Unrelated</b> 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.</p> <p>Cheers</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload