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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:37:19+00:00 2026-05-18T04:37:19+00:00

I’m currently learning about jsf 2.0 from core jsf 2.0 book + glassfish +

  • 0

I’m currently learning about jsf 2.0 from core jsf 2.0 book + glassfish + cdi.

I have a question about the validation feature of JSF.

Let’s say i have a very simple login application, which has a very simple layout like :

userid : (input field for userid – using required=”true”)
password : (input secret for password – using required=”true”)
loginButton + registerButton(using immediate=”true”) + checkUserIdAvailabilityButton

Now, let’s say the loginButton is pressed, and the userid and password are left empty, validation error would occur on both of the fields, and that’s working as what i intended.

And when the registerButton is pressed, it doesnt care whether the userid or password is filled by the user, since it’s using immediate=”true”, thus bypassing validation and the command gets executed at the apply request value phase, and that’s still working as what i intended.

And here comes my problem .. When the checkUserIdAvailabilityButton is pressed, i only expect the userid to be filled, and i dont need to care about whether the password field is filled or not, but the password field will throw error saying that it’s a required field.

Is there anyway to resolve this kind of problem ? I know this could be a very simple application, but in my working place, i think they design lots of screens like this, like the save button along with refresh button with different required fields but the buttons are in the same page.

Thank you !

  • 1 1 Answer
  • 2 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-18T04:37:20+00:00Added an answer on May 18, 2026 at 4:37 am

    Set both the availability button and username field with immediate="true" and put the register button in a separate <h:form>.

    E.g.

    <h:form>
         <h:inputText value="#{bean.username}" required="true" immediate="true" />
         <h:inputSecret value="#{bean.password}" required="true" />
         <h:commandButton value="Login" action="#{bean.login}" />
         <h:commandButton value="Check name availability" action="#{bean.checkNameAvailability}" immediate="true" />
    </h:form>
    <h:form>
         <h:commandButton value="Register" action="#{bean.register}" />
    </h:form>
    

    An alternative is to determine in the required attribute which button is been pressed (it’s then present as request parameter).

    <h:form id="form">
         <h:inputText value="#{bean.username}" required="#{not empty param['form:login'] or not empty param['form:check']}" />
         <h:inputSecret value="#{bean.password}" required="#{not empty param['form:login']}" />
         <h:commandButton id="login" value="Login" action="#{bean.login}" />
         <h:commandButton id="check" value="Check name availability" action="#{bean.checkNameAvailability}" />
         <h:commandButton value="Register" action="#{bean.register}" />
    </h:form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.