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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:34:30+00:00 2026-05-31T16:34:30+00:00

I am working with MyFaces/Primefaces and I have a problem to get information using

  • 0

I am working with MyFaces/Primefaces and I have a problem to get information using ajax.
My page contains a list of panel, inside each panel, the user can select value in a dropdown list, and click on a checkbox which will update its panel (Ajax), I hope I am clear.
This is my code:

<p:panel>
...
<h:selectOneMenu id="beanSet" value="#{myBean.selectedSet}">
    <f:selectItem itemLabel=" " noSelectionOption="true" />
    <f:selectItems value="#{langSet}" />
</h:selectOneMenu>


<h:selectBooleanCheckbox 
id="chkbxBeanSet"
value="#{myBean.selectedSetChkbx}" >
    <p:ajax 
    event="click" render="@parent"
    listener="#{action.updateSet}"
    execute="@form"
    immediate="true"
    />
</h:selectBooleanCheckbox>
...
<p:panel>

And here my java code:

public void updateSet(AjaxBehaviorEvent e) {
    UIComponent source = (UIComponent)e.getSource();
    System.out.println("Value:"+((HtmlSelectBooleanCheckbox)source).getValue());
    UIComponent parent = source.getParent();
    List<UIComponent> children = parent.getChildren();


    HtmlSelectOneMenu lvSet = (HtmlSelectOneMenu)parent.findComponent("beanSet");
    Object value = lvSet.getValue();
    System.out.println("value: " + value);

I get the beanSet component, but I can’t get its value. As I understand, the getValue calls the getSelectedSet from myBean which is not set (it is in request scope).
I don’t understant how I can get the selected value in the dropdown list using ajax.
Another way is to post all the form, but in that case, I have to determine which checkbox was clicked by the user…
If someone can explain me where I am wrong?

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

    The culprit is immediate="true" on the ajax action. This will skip all input components which do not have this attribute set during the processing. You should finetune the to-be-processed components in the process attribute of <p:ajax>. Yes, another culprit is that you used execute instead of process. The <p:ajax> uses process where <f:ajax> uses execute. Also, the way how you accessed the dropdown value is unnecessarily overcomplicated. Just access the selectedSet property directly. JSF will set it in the same bean anyway.

    So, this should do

    <h:selectOneMenu id="beanSet" value="#{myBean.selectedSet}">
        <f:selectItem itemLabel=" " noSelectionOption="true" />
        <f:selectItems value="#{langSet}" />
    </h:selectOneMenu>
    <h:selectBooleanCheckbox id="chkbxBeanSet" value="#{myBean.selectedSetChkbx}">
        <p:ajax process="@this beanSet" listener="#{action.updateSet}" update="@parent" />
    </h:selectBooleanCheckbox>
    

    with

    public void updateSet() {
        System.out.println(selectedSet);
    }
    

    Note that I omitted event="click" from <p:ajax>. It’s already the default for checkboxes.

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

Sidebar

Related Questions

I have a JSF page (using MyFaces 2.0) that does a bit of data
Working on a website that has Employee and Branch entities, using a database table
Working on a page with multiple sections. at the very top there is a
I want to have a generic menu in my JSF (MyFaces 1.2) application. <h:form>
I'm trying to get some data from a datatable in rich:modal panel The whole
Working on a website http://www.ArenaText.com written in asp.net with Microsoft AJAX control toolkit. iPad
I am working on a projec, the application is in j2ee and I have
I am fairly new to Servlet Filters and have basically joined a project using
Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,
Working with a Lucene index, I have a standard document format that looks something

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.