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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:08:27+00:00 2026-06-10T15:08:27+00:00

I want to pass check boxes to a backing CDI-Bean. The postTest.values are just

  • 0

I want to pass check boxes to a backing CDI-Bean. The postTest.values are just a List of Longs.

<h:form>
    <h:dataTable value="#{postTest.values}" var="val">
        <h:column>
            <h:outputLabel value="#{val}"/>
        </h:column>
        <h:column>
            <h:selectBooleanCheckbox value="#{postTest.checked[val]}"/>
        </h:column>
    </h:dataTable>
    <h:commandButton action="#{postTest.process}"/>
</h:form>

The action method should print out the checked values. But it is just empty.

@Named
@RequestScoped
public class PostTest {

    List<Long> values;
    Map<Long, Boolean> checked;

    ... 
    public String process() {
        logger.info(this.toString() + "Processing");
        for (Long l : checked.keySet()) {
            logger.info(this.toString() + "\t" + l + ". checked: " + checked.get(l));
        }

        return "index2";
    }
    ...
}

When I add logging to the getChecked() method, I can see, that it is just retrieved once per column and its content isn’t changed at all.

The problem seem to be related to the point that the postTest.values is not initialized when the form passes the values. Because if I initialize the postTest.values in the constructor (or a @PostConstruct) the checked items are passed correctly.

Why do I need to initialize the postTest.values at all after the POST request is executed?

Is there a way to prevent that?

Or do I have another option? E.g. make sure that the postTest.values are initialized properly not using the constructor nor the @PostConstruct, cause I want to pass values to it before initialization (I tried listeners, but they don’t seem to solve that).

Thanks!

Tim

  • 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-06-10T15:08:29+00:00Added an answer on June 10, 2026 at 3:08 pm

    You can also use Myfaces CODI @ViewAccessScoped annotation if you don’t want to play with @ConversationScoped and the start() and end() methods. it is a CDI extension that is kind of equivalent to @ViewScoped of JSF managed bean. I did not check the implementation of this annotation but I see many developers tell that it is even better than @ViewScoped annotation.

    Just download Myfaces CODI and drop it in your classpath and use the annotation.

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

Sidebar

Related Questions

I want to pass arrays in the jquery $.post() request. HTML: <input type=checkbox id=add-check-1e30>
My data is just number, I want pass it from VC1 to VC2 for
I want to pass an ImageIcon instance by value as we know that by
My main activity has three check boxes in it. I want to be able
I want to have a few check boxes on my page, and a link
How would I got about creating a user orderable list of check boxes in
if i want to pass in my value for confirmation box!!! so lets say
I have a series of check boxes on a page and I want to
I want pass a class-instace to a method of an other and be sure
I want to pass '#' to the query string like ?page.aspx?someParam=1234#5 .

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.