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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:57:05+00:00 2026-05-22T16:57:05+00:00

I have a4j command button on my jsf page , when I press Enter

  • 0

I have a4j command button on my jsf page , when I press Enter Key anywhere in the page this command button gets the focus and excutes its action

I want to prevent the button from getting focus when pressing Enter Key
I tried to use onfocus=”this.blur()” but it didn’t work

Thanks in advance

  • 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-22T16:57:06+00:00Added an answer on May 22, 2026 at 4:57 pm

    <a4j:commandButton> acts as a submit button. Hence executes action when pressed enter.

    When you see the code generated you will find like <input type="submit"/>

    To ignore that you should use a command link and to look like button give a style button as follows:

    .button {
        font: bold 11px Arial;
        text-decoration: none;
        background-color: #EEEEEE;
        color: #333333;
        padding: 2px 6px 2px 6px;
        border-top: 1px solid #CCCCCC;
        border-right: 1px solid #333333;
        border-bottom: 1px solid #333333;
        border-left: 1px solid #CCCCCC;
       }
    

    If you still want to go with <a4j:commandButton> then you can prevent enter by using

     onkeypress="var keycode;
     if (window.event) { keycode = window.event.keyCode;}else {return true;}
     if (keycode == 13) {return false;}else {return true;}"
    

    But this would cause like when you press enter even onfocus then it would not submit or call action, better not to use it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF/RichFaces setup with an index.jsp which a4j:include s another piece of
From now on, I have this : ..... <a4j:commandButton action=#{ChoixContratBean.Submit1} reRender=suite value=valider > </a4j:commandButton>
Using jsf 1.2, hibernate, richfaces 3.3.0GA and facelets. I have this code in my
We have a rich:comboBox on a JSF page which has a valueChangeListener that calls
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a JSF 1.2 application (Sun RI, Facelets, Richfaces) that was used only
I have a a4j:commandButton which is supposed to redirect me to an appropriate Edit
I have a page-scoped component, which has an instance variable List with data, which
I am new to JSF and have a problem with my simple JSF application.
I have a JSF file with a rather large form, the form consists of

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.