Note that there are some explanatory texts on larger screens.

plurals
  1. POSwitch off Validations during ajax call
    primarykey
    data
    text
    <p>I have a JSF page in which I am iterating a list to display the <code>&lt;h:dataTable&gt;</code> with some rows containing checkbox, some text and a textbox. I have added validations such that if a chechbox in a row is checked, the user must enter value inside the corresponding textbox. Also, I have a checkbox with id 'copy' above the <code>&lt;h:dataTable&gt;</code> which should copy the value entered in the first textbox to all other textboxes whose checkboxes are checked within the <code>&lt;h:dataTable&gt;</code>.I used an ajax call for the same.</p> <pre><code> &lt;h:form prependId="false" id="form"&gt; &lt;h:selectBooleanCheckbox value="#{bean.copy}" id="copy"&gt; &lt;p:ajax process="#{bean.mailId}" event="change" partialSubmit="true" listener="#{Controller.copyEmail()}" update="rm"&gt; &lt;/p:ajax&gt; &lt;/h:selectBooleanCheckbox&gt; &lt;h:dataTable id="rm" width="100%" cellspacing="4" value="#{controller.alertTriggers}" var="alt" columnClasses="c1,c2,c3,c4"&gt; &lt;h:column&gt; &lt;h:selectBooleanCheckbox value="#{alt.checkValue}" id="checkbox" binding="#{checkbox}"/&gt; &lt;/h:column&gt; &lt;h:column&gt; &lt;h:outputText value="#{alt.id}" /&gt; &lt;/h:column&gt; &lt;h:column&gt; &lt;h:outputFormat value="#{alt.msg1}" /&gt; &lt;/h:column&gt; &lt;h:column&gt; &lt;h:message for="emailID" id="email" styleClass="validation-error"/&gt; &lt;h:inputText value="#{alt.mailId}" id="emailID" style="width: 87%;" required="#{checkbox.value}" requiredMessage="Enter the value"/&gt; &lt;/h:column&gt; &lt;/h:dataTable&gt; &lt;/h:form&gt; </code></pre> <p>In the controller</p> <pre><code>public void copyEmail() { //code for copying the first textbox value to all other textboxes } </code></pre> <p>The Validation works fine, but when i check the <strong>copy</strong> checkbox, the textbox value do not get copied to the other textboxes. Instead, validation errors are shown. If I remove validations from the textbox, the copying part works fine. </p> <p>I tried using <code>immediate=true</code> for my ajax call but then the value of the checkboxes inside the <code>&lt;h:dataTable&gt;</code> are not updated within the controller.</p> <p>So, in summary </p> <p><strong>I want to switch off my validations during the ajax call. Is there any way to do that other than <code>immediate=true</code>?</strong></p>
    singulars
    1. This table or related slice is empty.
    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.
 

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