You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sumanth <ro...@gmail.com> on 2015/06/10 23:23:17 UTC

Form's validate event is fired even though cancel event is handled.(5.4)

Hi All,

I have a ajax form and even though i click a submit button with t:mode =
"cancel", the validate method of this form is called.

The javadocs for SUBMITMODE.CANCEL says that,"If the event handler for that
event allows the submission to proceed, then server-side validation still
occurs on the server"

but I'm preventing it to proceed by returning true in the cancel event
handler method, but still i'm able to see error message on UI. basically it
is the validation message saying "you must provide a value for security
code"

//code component.tml

 <t:Zone t:id="resetPasswordLinkZone" id="prop:clientId">
    <t:form t:id="resetPasswordLinkForm" class="form-horizontal"
role="form" t:zone="^">
      <t:Errors />
      <fieldset>
        <div class="form-group">
          <t:Label t:for="SecurityCode" class="col-xs-3" />
          <div class="col-xs-12 col-sm-6">
            <t:TextField t:id="securityCode" t:value="securityCode"
t:validate="required,minLength=6,maxLength=20" />
          </div>
        </div>
        <div class="form-group">
          <div class="col-xs-12 text-center">
            <t:submit value="Reset" t:id="resetPasswordLinkSubmit"
t:mode="cancel"
/>
            <t:submit value="Send Recovery Link"
t:id="sendPasswordLinkSubmit"  />
          </div>
        </div>
      </fieldset>
    </t:form>
  </t:Zone>

// component.java

  boolean onCanceledFromResetPasswordLinkForm() {
    componentResources.triggerEvent(MyEventConstants.CANCELED, new Object[]
{}, null);
    return true;
  }

  public String getClientId() {
    return componentResources.getId() + "-resetPasswordLinkZone";
  }

  public void onValidateFromresetPasswordLinkForm() {
    System.out.print(true); """THIS GETS CALLED EVEN IF CANCELED EVENT WAS
HANDLED""""
  }

or am i handling the canceled event wrong?

thanks in advance,