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

  • SEARCH
  • Home
  • 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 this seemingly-innocent code on my main JSF page: <a4j:outputPanel id=sidebarContainer> <a4j:include viewId=#{UserSession.currentSidebar}/>
I have an a4j:commandButton which looks like this <a4j:commandButton id=stopBtn type=button reRender=lastOp action=#{MyBacking.stop} value=Stop
I have such code in my JSF template: <h:form> <table id=users cellspacing=0> <a4j:repeat var=person
From now on, I have this : ..... <a4j:commandButton action=#{ChoixContratBean.Submit1} reRender=suite value=valider > </a4j:commandButton>
I have a form which, when the button gets clicked by a user, redirects
I have a JSF 1.2 / Seam 2.2.2 application. I have button and on
I have a bunch of Seam form pages; each has a command button that
I have a JSF page that includes a tree form tag which is rendered
I have the following components on xhtml page. <h:inputText id=dateFromText value=#{fileSearchCriteria.fromDateStr}> <a4j:support event=onchange reRender=datePanel1
I have a JSF/RichFaces setup with an index.jsp which a4j:include s another piece 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.