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

Related Questions

Without thinking about it at all I just want to say I should allow
I usually, almost without thinking anymore, use forward declarations so that I won't have
Without getting a degree in information retrieval, I'd like to know if there exists
Without the use of any external library, what is the simplest way to fetch
Without calculating them , I mean?
Without spending a long time reviewing the boost source code, could someone give me
Without using Javascript, is there a way to make a CSS property toggle on
Without using a WebBrowser control, how could I execute a JavaScript function, that is
Without routing, HttpContext.Current.Session is there so I know that the StateServer is working. When
Without using plpgsql, I'm trying to urlencode a given text within a pgsql SELECT

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.