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

The Archive Base Latest Questions

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

I am trying to use <a4j:ajax> to feed a method with a value just

  • 0

I am trying to use <a4j:ajax> to feed a method with a value just entered on the form;

<h:selectOneMenu id="aa" value="#{colorClass.color}">
    <f:selectItems value="#{myChoices.colorOptions}"/>
    <a4j:ajax event="change" render="colorCode" 
        execute="#{myChoices.getColorCode(colorClass,colorClass.color)}"/>
</selectOneMenu>

Color on the form is selected correctly;

my problem is that when I pass colorClass.color as part of the execute, it is blank;
if I replace colorClass.color with a literal

<a4j:ajax event="change" render="colorCode" 
    execute="#{myChoices.getColorCode(colorClass,'green')}"/>

the method is called, finds the colorCode and repaints the form

How can I “grab” the value just entered so that I can pass it as a parameter to the method?

  • 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-25T20:55:40+00:00Added an answer on May 25, 2026 at 8:55 pm

    You need listener attribute instead of execute attribute. The execute attribute should point to a collection of client IDs which are to be submitted (which defaults to @this in <f:ajax> and @form in <a4j:ajax>). However in your particular case it returns void and keeps the execute empty. The listener attribute is supposed to point to a bean action listener method. Fix it accordingly:

    <a4j:ajax event="change" render="colorCode" 
        listener="#{myChoices.getColorCode(colorClass,colorClass.color)}"/>
    

    Note that the colorClass argument seems superfluous here, or at least the colorClass.color as you could also just do colorClass.getColor() inside the getColorCode() method. Just passing one of them ought to be sufficient. Passing colorClass.color would be preferable so that your myChoices bean is not tight coupled with the colorCode bean.

    <a4j:ajax event="change" render="colorCode" 
        listener="#{myChoices.getColorCode(colorClass.color)}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to use this method (gist of which is use self.method_name in the FunnyHelper
I am trying to use <a4j:commandLink> in my JSP and I get the following
I'm trying to use cURL to post data to the form on this URL:
I'm trying to use cURL to post data to the form on this URL:
I'm trying use the Sum method in a lambda expression for a comparison, but
I was trying use a set of filter functions to run the appropriate routine,
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am trying use a Java Uploader in a ROR app (for its ease
Trying to use an excpetion class which could provide location reference for XML parsing,

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.