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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:52:26+00:00 2026-05-25T21:52:26+00:00

When my page is loaded I execute the following JS script, which I use

  • 0

When my page is loaded I execute the following JS script, which I use to display a popup saying (please wait…) when any form is submitted.

jQuery(function(){
  jQuery("form").submit(function(){jQuery('#wait-link').trigger('click');return true;});
});

This works fine when using h:commandButton tag, however when I use the h:commandLink tag it doesn’t work because the form is submitted by java script (from the file jsf.js in the jar jsf-impl.jar) as shown below

mojarra.jsfcljs = function jsfcljs(f, pvp, t) {
  mojarra.apf(f, pvp);
  var ft = f.target;
  if (t) {
    f.target = t;
  }
  f.submit();
  f.target = ft;
  mojarra.dpf(f);
};

To solve this problem I copied the jsf.js file under WEB-INF/resources/javax.faces/jsf.js and modified it to trigger the form submit method using jQuery. This works fine but:

1) I don’t like the fact that I am touching the jsf.js file since it may change in newer releases of JSF.

2) I don’t like the fact that I am using jQuery inside the jsf.js file.

Is there a better solution to solve this problem?

  • 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-25T21:52:27+00:00Added an answer on May 25, 2026 at 9:52 pm

    As Bodgan suggested a better solution is to execute the following piece of code when the page is loaded, I don’t know what the term is in JS but seems an override for me.

    jQuery(function(){
      var oldjsfcljs = mojarra.jsfcljs; // save a pointer to the old function
    
      mojarra.jsfcljs = function jsfcljs(f, pvp, t) {
        jQuery(jq(f.id)).trigger('submit');
        oldjsfcljs.apply(this, arguments);
      };
    });
    
    function jq(myid) {
      return '#' + myid.replace(/(:|\.)/g, '\\$1');
    }
    

    Note: the jq() method is only used to escape the special characters in the form ID.

    update: the above code seemed to work but if you have parameters in the form it wont so I had to rewrite the mojarra.jsfcljs function as follows:

    jQuery(function(){
      mojarra.jsfcljs = function jsfcljs(f, pvp, t) {
        mojarra.apf(f, pvp);
        var ft = f.target;
        if (t) {
          f.target = t;
        }
    
        // trigger the submit event manually.
        jQuery(jq(f.id)).trigger('submit');
    
        f.submit();
        f.target = ft;
        mojarra.dpf(f);
      };
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to execute a script after the whole page has loaded, when it's
I have a div in which a page is loaded with the DojoX Layout
I want to load .php files via ajax which execute ExtJS script as they
I have the following HTML page: sample_page.html: <h1>sample html page</h1> <script type=text/javascript src=sample_page.js/> The
My script function is defined inside a JSF2 form on a XHTML page and
I'm looking to execute a function when the a page is loaded with a
I have a custom aspx page loaded in a IFrame in one of the
Is it possible that the html page loaded, cannot be refreshed or reloaded by
My application needs to be able to read cookies stored by a page loaded
I have a page being loaded with jQuery. The initial load includes 100 records

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.