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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:09:40+00:00 2026-05-26T08:09:40+00:00

I would like that when the user clicks on a button 2 things happen

  • 0

I would like that when the user clicks on a button 2 things happen :

  1. First a setPropertyActionListener is triggered, to update a property of my bean
  2. Then an ajax call is made to execute a method from the bean

It seems that I must choose between the f:setPropertyActionListener tag and the f:ajax tag to nest inside the commandButton tag.

Is there a way to execute both the ajax call and the property update at the same time?

Thanks a lot!

EDIT : I forgot to mention I don’t want a form execution, I want to use the ajax listener, here is my code :

<h:commandLink styleClass="blue-button" value="+">
  <f:setPropertyActionListener target="#{tvShowForm.selected}" value="#{tvShow.externalId}" />
  <f:ajax event="click" listener="#{tvShowForm.add}" />
</h:commandLink>

With this code the f:setPropertyActionListener is not executed.

EDIT 2 :

I modified my code to the folowing, using action form method instead of listener. Now it works only if I don’t specify an event attribute on the ajax tag, but when I specify one, the action method is not executed.

<h:commandLink action="#{tvShowForm.add}" styleClass="blue-button" value="+">
  <f:setPropertyActionListener target="#{tvShowForm.selected}" value="#{tvShow.externalId}" />
  <f:ajax event="click" />
</h:commandLink>
  • 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-26T08:09:41+00:00Added an answer on May 26, 2026 at 8:09 am

    Works just for me with Mojarra 2.1.3 on Tomcat 7.0.19 and Glassfish 3.1.1.

    I used this relevant piece of the view:

    <h:form>
        <h:commandButton value="submit" action="#{bean.submit}">
            <f:setPropertyActionListener target="#{bean.value}" value="foo" />
            <f:ajax />
        </h:commandButton>
    </h:form>
    

    with this relevant piece of the bean:

    private String value;
    
    public void submit() {
        System.out.println("Value: " + value);
    }
    
    // Getter/setter.
    

    which prints the following on the ajax submit:

    Value: foo

    Your problem is caused by something else which you left out the question.


    Update: as per your update

    I forgot to mention I don’t want a form execution, I want to use the ajax listener, here is my code :

    I really don’t see why you don’t want “a form execution”. You are submitting the form. You’ve only left out the action method and you’re doing the business job in the ajax event listener instead. The action listener methods aren’t intented to do any business job, they’re for at highest some self-containing processing or logging job. The model-dependent business job should be done in the action method, there it is for.

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

Sidebar

Related Questions

I’m developing an application dedicated to generate statistical reports, I would like that user
Imagine a user that would like to put a form on their website that
I have a photo gallery I would like that every time a user does
I would like to know the paths of certain files that a user is
We have a customer that would like to modify application user messages that we
I would like to have a checkbox preference that takes the user to a
I'm building a website that will require user registration and logon. I would like
I have a single user java program that I would like to have store
I have a MySQL user added to a database that I would like to
so if you have a favorite button like on SO, then the user could

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.