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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:32:04+00:00 2026-05-28T05:32:04+00:00

I have a multiselect listbox and depending on how many elements user will choose

  • 0

I have a multiselect listbox and depending on how many elements user will choose I have to show same number of checkboxes. I’m using jsf and primefaces /spring webflow. How I can do that? Any examples?
And I have to make one checkbox which allow to check all generated checkboxes using one click.

  • 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-28T05:32:05+00:00Added an answer on May 28, 2026 at 5:32 am

    I have a multiselect listbox

    Thus, a <h:selectManyListbox> with a fixed <f:selectItems> value.

    <h:selectManyListbox id="listbox" value="#{bean.selectedListboxItems}">
        <f:selectItems value="#{bean.availableListboxItems}" />
    </h:selectManyListbox>
    

    With something like:

    private List<String> availableListboxItems;
    private List<String> selectedListboxItems;
    
    @PostConstruct
    public void init() {
        availableListboxItems = new ArrayList<String>();
        availableListboxItems.add("menu item 1");
        availableListboxItems.add("menu item 2");
        availableListboxItems.add("menu item 3");
    }
    

    and depending on how many elements user will choose I have to show same number of checkboxes

    Thus, just prepopulate the <f:selectItems> of a <h:selectManyCheckbox> based on the value of the <h:selectManyListbox>.

    <h:commandButton value="Generate checkboxes">
        <f:ajax execute="listbox" listener="#{bean.generateCheckboxes}" render="checkboxes" />
    </h:commandButton>
    <h:selectManyCheckbox id="checkboxes" value="#{bean.selectedCheckboxItems}">
        <f:selectItems value="#{bean.availableCheckboxItems}" />
    </h:selectManyCheckbox>
    

    with something like

    private List<String> availableCheckboxItems;
    private List<String> selectedCheckboxItems;
    
    public void generateCheckboxes() {
        availableCheckboxItems = new ArrayList<String>();
    
        for (int i = 1; i <= selectedListboxItems.size(); i++) {
            availableCheckboxItems.add("checkbox item " + i);
        }
    }
    

    I’m using jsf and primefaces /spring webflow. How I can do that? Any examples?

    I believe the above trivial examples are sufficient. For PrimeFaces, just replace <h:xxx> with <p:xxx>. I have however no idea how Spring Webflow plays a role in this as I have never used it.


    And I have to make one checkbox which allow to check all generated checkboxes using one click.

    That’s left as an exercise for you. Hint: make sure that availableCheckboxItems contains the desired values depending on the current value of the <h:selectBooleanCheckbox> which should represent the “toggle selected items”.

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

Sidebar

Related Questions

I have a ListView control that is in FullRowSelect mode, MultiSelect off and using
I have a multiselect ListBox in a FormPanel in GWT. I have set the
I have a multiselect listbox and before submitting the form i want to check
I have a ListBox in a WinForm with multiselect enabled. The selected items appear
I have one WPF ListBox loaded using LINQ: lbxCalculosSec.ItemsSource = from p in database.CALCULOS
Is there a way to limit the number of selections a user can choose
I have a listbox in a Microsoft Access form. The MultiSelect property is set
I have a multi-select listbox in a SL3 app using prism and I need
i have to send form data which have multiselect boxes to a servlet using
I should load images to listbox.I have a trouble when I choose images, to

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.