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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:29:14+00:00 2026-05-19T17:29:14+00:00

I´m currently developing a Struts2 app where a user will make one of three

  • 0

I´m currently developing a Struts2 app where a user will make one of three choices, and based on the choice a number of different predefined checkboxes will be presented. Some of the checkboxes will appear regardless of the choice made, while others will be unique for each choice that can be made. In total, there are currently around 50 different checkboxes, and each checkbox will have an ID, from 1 to 50.

The selections made by the user will be persisted as rows in a database, and I need to be able to repopulate the selected checkboxes should the user want to change the selections made.

Using a checkboxlist is not suitable, as I need to put the checkboxes into different fieldsets on the page. So I guess I´m stuck with the regular .

Now, has anybody got a good idea of how I could:
1) Retrieve the selected checkboxes, preferebly by putting them into a list/set in my action
2) Repopulate the selected checkboxes from a list where the selections has been stored?

Any ideas are much appreciated!

  • 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-19T17:29:15+00:00Added an answer on May 19, 2026 at 5:29 pm

    1) To retrieve the selected checkboxes, use something like this (supposing you’re using JSP):

    <input type="checkbox" name="YourName" id="checkbox-1" value="1" />
    <input type="checkbox" name="YourName" id="checkbox-2" value="2" />
    <input type="checkbox" name="YourName" id="checkbox-3" value="3" />
    etc...
    

    In your Action class, you can retrieve the variable “YourName” as an ArrayList of integers for instance, it will be automatically populated with the checked checkbox IDs by Struts2.

    2) To repopulate the checkboxes on an Edit page for instance, there are many possible solutions (could you give us some more details about your architecture, objects, and so on?)

    In your Action class, you could retrive in a list the ids of formerly-checked checkboxes (let’s call it selectedList).Once on your JSP view, you could add the “checked=”checked”” parameter to your checkbox field on the condition that the ID of the box is contained in selectedList. Something like that should work:

    <s:if test="'checkboxId' in selectedList">checked="checked"</s:if> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.