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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:56:40+00:00 2026-05-25T15:56:40+00:00

I have a javascript function to run h: or a4j: commanButton. When javascript function

  • 0

I have a javascript function to run h: or a4j: commanButton. When javascript function is called, action button runs action but after that page is not redirected.
I am using Seam 2.2 and RichFaces 3.3.3
What is the problem here? Thanks.

  function submitForm(){
        document.getElementById('myForm:save').click(); 

        // does not redirect.
        //document.getElementById('myForm').submit();
        }  

Even if I use submit() page is not redirected.

Form:

<h:form id="myForm">
//some fields

<h:commandButton id="save" value="Save"
                         action="#{personHome.persist}" />

</h:form>
  • 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-25T15:56:41+00:00Added an answer on May 25, 2026 at 3:56 pm

    To the point, the following should work for <h:commandButton>:

    document.getElementById('myForm:save').click(); 
    

    and when the button is the first button of the form in question:

    document.getElementById('myForm').submit();
    

    You only need to ensure that the generated client ID is exactly the same as the ID which you’re specifying in getElementById(). If the <h:form> is by itself nested in another UINamingContainer component, then the ID will be prepended with its ID. Rightclick page in browser and View Source to be sure.

    As to the concrete problem, perhaps you’ve attached this function to another button which in turn also submits some form by itself which will result in a race condition of two requests. You should then return false; from or after the function to block the caller’s default action. E.g.

    <h:commandButton onclick="return submitForm();" />
    

    with

    function submitForm(){
        // ...
    
        return false;
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript function that manipulates the DOM when it is called (adds
I have a javascript function being called by an input type=image tag that generates
' i have a javascript function that im trying to trigger and run. here
I have a javascript function that needs to run when a user clicks on
If I have a javascript function, it is possible that I do not return
In one HTML page I have a JavaScript function checkUpdates() that hits the server.
I have a javascript function (class) that takes a function reference as one paremter.
I have a javascript function (function1) that checks some global variables (can the user
I have a javascript function that calls a generic function to make an ajax
I have a javascript function that accepts a number and performs a mathematical operation

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.