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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:29:05+00:00 2026-06-12T09:29:05+00:00

I have a h:commandButton calling some action=#{bean.do} . And also some ajax request for

  • 0

I have a h:commandButton calling some action="#{bean.do}". And also some ajax request for that button which should restyle a part of the website. This restyling should take place before the action is executed. How can I do this?

<h:commandButton action="#{bean.do}">
    <f:ajax execute="@form" render="specificId" />
</h:commandButton>

As the action do sometimes takes a long time, I want the page first to display a message/image or likewise. And after that frist execute the action. But how?

  • 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-12T09:29:06+00:00Added an answer on June 12, 2026 at 9:29 am

    You can use the onclick attribute to execute some JavaScript code right before the action is invoked.

    E.g.:

    <h:commandButton ... onclick="document.body.style.background='pink'">
    

    It’s however better to use onevent attribute of <f:ajax> for this, so that you can revert the change:

    <h:commandButton ...>
        <f:ajax ... onevent="handleDo" />
    </h:commandButton>
    <img id="progress" src="progress.gif" class="hidden" />
    

    with e.g. this which disables/enables the button and displays/hides the progress image:

    function handleDo(data) {
        var status = data.status; // Can be 'begin', 'complete' and 'success'.
        var button = data.source; // The HTML element which triggered the ajax.
        var image = document.getElementById("progress"); // Ajax loading gif?
    
        switch (status) {
            case 'begin': // This is called right before ajax request is been sent.
                button.disabled = true;
                image.style.display = "block";
                break;
    
            case 'complete': // This is called right after ajax response is received.
                image.style.display = "none";
                break;
    
            case 'success': // This is called when ajax response is successfully processed.
                button.disabled = false;
                break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an a4j:commandButton which looks like this <a4j:commandButton id=stopBtn type=button reRender=lastOp action=#{MyBacking.stop} value=Stop
I have the following layout in my page (simplified) <h:form> <h:commandButton action=#{bean.save} value=Save/> <rich:tabPanel
I have simple component - CommandButton <tr:commandButton text=test styleClass=form-button actionBean=#{testPage} action=synchAction partialSubmit=true id=btnId />
If I have a simple button: <ice:panelGroup> <ice:commandButton value=foobar action=#{fileManager.openNoFlashVisiblePopup} /> </ice:panelGroup> Is it
I have something like: <h:commandButton> <h:ajax event=click listener=#{controller.onLog} onchange=onLogProcess /> .... </h:commandButton> I send
I have a Facelets Composite component that includes, among other things, a commandButton: <?xml
I have this piece of code for render a popup, using f:ajax: <h:commandButton id
I have a simple query tied to a command button that shows a summary
I have a a4j:commandButton which is supposed to redirect me to an appropriate Edit
From now on, I have this : ..... <a4j:commandButton action=#{ChoixContratBean.Submit1} reRender=suite value=valider > </a4j:commandButton>

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.