Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5948319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:05:26+00:00 2026-05-22T17:05:26+00:00

I have a form with a validator on one field. I have two h:commandButton

  • 0

I have a form with a validator on one field. I have two h:commandButtons: Ok and Cancel. When I input wrong data and click Cancel, I get a validation message. What must I do that validator don’t run when I click cancel?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:05:27+00:00Added an answer on May 22, 2026 at 5:05 pm

    In case you aren’t using ajax, or are still on JSF 1.x, and you really need to invoke a business action in cancel() method (i.e. just reloading the page is insufficient), then your best bet is to add immediate="true" to the button. This way all input fields which don’t have immediate="true" will be skipped in processing.

    <h:commandButton value="Cancel" action="#{bean.cancel}" immediate="true" />
    

    On JSF 2.x, much better is to submit the form by <f:ajax>, which by default only processes @this instead of @form.

    <h:commandButton value="Cancel" action="#{bean.cancel}">
        <f:ajax />
    </h:commandButton>
    

    If you want to navigate to another page here, add ?faces-redirect=true to the outcome in the cancel() method.

    Or, if you actually don’t need to invoke any business action at all, then just use <h:button> wherein you directly specify the (implicit) navigation case outcome.

    <h:button value="Cancel" outcome="previouspage" />
    

    This will basically reload the page by a GET request. The <h:button> doesn’t exist in JSF 1.x, but you can also just use plain HTML+JS for that.

    See also:

    • Why was "immediate" attribute added to the EditableValueHolders?
    • How to navigate in JSF? How to make URL reflect current page (and not previous one)
    • How to let validation depend on the pressed button?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that contains two input textboxes, one called serial and the
I have a form in CakePHP that has two live-search text input. Each one
I have a two field HTML form for newsletter signup. One field is for
I have one model but two different forms ,one form i am saving through
I have a very simple form with a name field and two submit buttons:
In a form I have one Date text field and 2 dropdowns: Start time
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For
I have created an form validation using ajax/php. Each text box is validated using
Form validation for check boxes only seems to be working in IE....? Anyone have
I have a multi-lingual page where I want to display form validation error in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.