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

  • Home
  • SEARCH
  • 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 168811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:31:09+00:00 2026-05-11T12:31:09+00:00

Without thinking about it too much, I’ve been doing something like the following: 1)

  • 0

Without thinking about it too much, I’ve been doing something like the following:

1) building a list of SomeBean objects based on the results of a database call

2) putting that list in my command object

3) building a form based on that command object where users can modify attributes of the SomeBeans

4) extracting data out of the post-submit command object and writing the updated data to my database

My code looks something like this:

public class UpdateThingsinListController extends SimpleFormController {      protected Object formBackingObject(final HttpServletRequest request)           throws Exception {      List<SomeBean> beans = database.getBeans();      Command comamnd = new UpdateThingsCommand()     command.setList(beans);      return command;    }     protected ModelAndView onSubmit(final HttpServletRequest request,           final HttpServletResponse response, final Object commandArg,           final BindException errors) throws Exception {      database.setBeans(commandArg.getList());             }   } 

my jsp looks somthething like:

<form:form>     <c:forEach var='bean' items='${beans}' varStatus='status'>         <form:checkbox path='beans[${status.index}].someBooleanProperty' />${bean.name} <br>         </c:forEach> </form:form> 

The code works fine, but it’s just dawned on me that my ‘beans’ list is getting created twice (sessionform must be false in my case) — once when displaying the form, once when binding. If anything changes on the second creation (a bean is missing, the results are in a different order), my binding will get messed up, and I’ll get fired. I’m beginning to think that any biding scheme where a command object needs to be merged with a form submission is very risky.

So, my question is — how do folks ensure that form submissions get bound to lists correctly? Is there another way to do it besides list index? Object ids maybe?

thanks,

-Morgan

  • 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. 2026-05-11T12:31:09+00:00Added an answer on May 11, 2026 at 12:31 pm

    If you can’t depend on the List always being the same whenever you retrieve it, then you have to use a different collection – a map.

    Another approach would be to cache your List somewhere. Perhaps some AOP around your database.getBeans method.

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

Sidebar

Ask A Question

Stats

  • Questions 84k
  • Answers 84k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The easiest way to access form data from an HTTP… May 11, 2026 at 5:01 pm
  • Editorial Team
    Editorial Team added an answer We have a similar system setup; What we use is… May 11, 2026 at 5:01 pm
  • Editorial Team
    Editorial Team added an answer The scrollTop property only accepts an integer (not pixels). Omit… May 11, 2026 at 5:01 pm

Related Questions

Without thinking about it too much, I've been doing something like the following: 1)
I was looking for a generic method in .Net to encode a string for
How much code documentation in your .NET source is too much? Some background: I
I have been trying to get more in to TDD. Currently keeping it simple
SQL to find duplicate entries (within a group) I have a small problem and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.