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 8542739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:08:19+00:00 2026-06-11T12:08:19+00:00

I am currently adding validation to a form. There are two things to check:

  • 0

I am currently adding validation to a form. There are two things to check: The correctness of the value itself (e.g. if it is a positive integer or valid email) and whether all required fields were filled in.

However, if by some means (f:ajax or IceFaces partialSubmit attribute) I make the validation for type correctness happen at once (e.g. when the field loses focus), it will also check the required attribute in this same step. In most cases this is no problem, as the user already entered a value and is likely to correct it rather than go back to a blank field.

However, in the case where he actually wants to clear the field again, he can no longer do so without getting an error. In consequence, I only want to check the required-ness of fields on finally submitting the page.

At the moment, my only idea to separate the two validation types is by performing all required-checks in the backing beans action method, thus tying it to directly to the final submit via button.

Is there another way?

(For background: The reason why one might want to clear the field again is that requirements can change depending on other selections in the form. So one might decide to not provide this field after all and only after that correct the option that actually makes this field optional.)

  • 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-06-11T12:08:20+00:00Added an answer on June 11, 2026 at 12:08 pm

    Just let the required attribute evaluate true when the submit button has really been pressed.

    The answer however depends on the way how your submit button executes its logic (standard, f:ajax, ICEfaces, etc). But it basically boils down to that you could check the request parameter map for a request parameter which indicates that the desired submit button has been pressed.

    E.g., if it’s a standard command button:

    <h:form id="form">
        ...
        <h:commandButton id="submit" value="Submit" action="#{bean.submit}" />
    </h:form>
    

    Then you could check for it by checking if the button’s client ID is present in the request parameter map:

    <c:set var="submitButtonPressed" value="#{not empty param['form:submit']}" />
    ...
    <h:inputText ... required="#{submitButtonPressed}" />
    <h:inputText ... required="#{submitButtonPressed}" />
    <h:inputText ... required="#{submitButtonPressed}" />
    

    Or, if it’s a <f:ajax> button:

    <h:form id="form">
        ...
        <h:commandButton id="submit" value="Submit" action="#{bean.submit}">
            <f:ajax execute="@form" ... />
        </h:commandButton>
    </h:form>
    

    Then you could check it by checking if javax.faces.source parameter equals the button’s client ID:

    <c:set var="submitButtonPressed" value="#{param['javax.faces.source'] == 'form:submit'}" />
    ...
    <h:inputText ... required="#{submitButtonPressed}" />
    <h:inputText ... required="#{submitButtonPressed}" />
    <h:inputText ... required="#{submitButtonPressed}" />
    

    You could even combine both:

    <c:set var="submitButtonPressed" value="#{not empty param['form:submit'] or param['javax.faces.source'] == 'form:submit'}" />
    ...
    <h:inputText ... required="#{submitButtonPressed}" />
    <h:inputText ... required="#{submitButtonPressed}" />
    <h:inputText ... required="#{submitButtonPressed}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm adding some javascript validation to a form. The form has fields that currently
I'm in the process of adding some much needed client side form validation to
I am currently working on adding pre-validation to my website. So that pages that
I'm currently adding a div to use as a slider programmatically, but when I
I am currently adding products programatically to the cart, to create a 'free sample'
I'm currently adding transposition tables in my chess engine, and I'm having issues with
I currently am adding some features to our logging-library. One of these is the
I'm adding a toolbar to my application and currently I'm adding some toggle buttons
Currently in my controller, when adding new data, I validate the inputs, and if
I'm currently evaluating options for adding sub-domain support to a new Ruby on Rails

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.