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

  • Home
  • SEARCH
  • 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 6530893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:48:37+00:00 2026-05-25T09:48:37+00:00

In JSF 2.0 have the following: Using this as a base <h:inputText id=email size=60

  • 0

In JSF 2.0 have the following: Using this as a base

<h:inputText id="email" size="60" label="Email"
            styleClass=" #{component.valid ? '' : 'input-error'}"
            value="#{familyBacking.family.email}" requiredMessage="Required">
            <f:validateRequired />
            <f:attribute name="family" value="#{familyBacking.family}" />
            <f:validator validatorId="EmailValidator" />
            <f:validator validatorId="ExistingEmailAddressValidator" />
            <f:ajax event="blur" onevent="updateFocus"
                render="email emailMessage" />
</h:inputText>

With a javascript function

function updateFocus(obj) {
    jQuery(":input.input-error:first").focus();
}

This has the effect to focus and highlight the invalid field. However, it also allows the person to tab to the next input field. So, the sequence is:

  1. User enters no or invalid data into the field clicks on another field or tab.
  2. The brower focuses on another field
  3. The on blur on the original field fires causing the ajax.
  4. The invalidation occurs, and the class is added to the input. The JS function is executed bringing focus back to the invalid field. All is good until this point.
  5. BUT, now the onBlur on the 2nd field fires and causes the whole thing again.

Potential Solution:

I can see that the onevent function for the <f:ajax/> is called 3 times. Onces for begin, once for success and once for complete. What I am thinking I can do is somehow disable on blur events for all other input fields until I re-enable them in the last execution of my javascript event.

Suggestions on how I might be able to accomplish this?

  • 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-25T09:48:38+00:00Added an answer on May 25, 2026 at 9:48 am

    I understand that this is disturbing to you, apparently you’d like to show just one message at once. But this is also disturbing to the enduser, the cursor doesn’t stick in the next field anymore, the enduser is forced to correct the validation error of the previous field right now and without excuses! Perhaps the enduser wanted some more time to think about the data before filling it in? How would you feel when you encounter such a form? Perhaps you should just not change the focus? Perhaps you should only change the focus to the 1st invalid field whenever the real submit button has been pressed?

    Nonetheless, this is an interesting problem. You could indeed hook on the onevent attribute of <f:ajax> to intercept on the status of the ajax request. You could indeed use the jQuery magic to disable (actually, remove) the onblur handler and then add it again when JSF has done its ajax job (and you have done your focus job). You could use jQuery.data() to store and retrieve arbitraty HTML element information such as the original onblur handler (something like as you would do with <f:attribute> in JSF world):

    function process(data) {
        switch (data.status) {
            case "begin":
                jQuery(":input", data.source.form).not(data.source).each(function() {
                    var $this = $(this);
                    $this.data("onblur", $this.attr("onblur"));
                    $this.removeAttr("onblur");
                });
                break;
    
            case "success":
                jQuery(":input.input-error:first").focus();
                jQuery(":input", data.source.form).not(data.source).each(function() {
                    var $this = $(this);
                    $this.attr('onblur', $this.data("onblur"));
                    $this.removeData("onblur");
                });
                break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have JSF code like: <h:inputText id=from value=#{fromToMBean.fromName}/> I would like to get this
I'm using Glassfish 3.1.1 and JSF 2.0: I have the following code: public String
I'm using JSF 2.0 and Glassfish 3.1 and have the following problem: I've got
I have a problem with a JSF composite which validates internal input fields. Following
I am using Struts Tiles with JSF to have one header, menu and footer
I have a JSF application with several major components and a component tree under
I have the following 3 simple pages in a JSF app. index.html start.html confirmSuccess.thml
This code, a test case for a custom component using JSF2 Just for the
I have a problem with using jQuery Dialog and Ajax submit in JSF. I
I have the following code: <rich:tabPanel switchType=client> <rich:tab name=tab1 label=tab1 onclick=alert('Hello');> ... </rich:tab> <rich:tab

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.