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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:49:51+00:00 2026-05-27T01:49:51+00:00

My command object have a list of objects. I want to bind a text

  • 0

My command object have a list of objects. I want to bind a text field to the attribute of the object inside that list. Is it possible to do in Spring MVC?

Command object class

public class SubDevisonDto {

private String devId;
private List subDevisions;

Subdevision object class mentioned in the list

public class SubDivison implements Serializable{

private String subDivisonName;
private String createdBy;
private String createdDate;
private String developerID;
private List users;

I want text box to set the value for subDivisonName field.

I have written the Spring MVC tags like this.

<spring:bind path="subdivisondto.subDevisions[0].subDivisonName">
    <span class="formw">
        <input name="subDivisonName" type="text" style="width:350px;" />
    </span>
</spring:bind>

Just for test purpose I have given it as 0. If it’s working I can make it to a variable. my requirement is, I should let the user to dynamically add subdevision objects. So, initially when page is loading I will just show one text box. I will give a button for him to add if he want to add more. I will dynamically generate text boxes when he clicks the add button. After that I have to submit the form with the list.

This jsp code gives me an error. It says:

org.springframework.beans.NullValueInNestedPathException

Is there anyway for me to do this in jsp code?

  • 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-27T01:49:52+00:00Added an answer on May 27, 2026 at 1:49 am

    I found the answer for my question. But, it’s not the solution for my requirement as I need to implement a dynamic list. but I found a solution for this question.

    As I understood, first time we have to send data from back end to bind input elements. I didn’t find a way to bind form elements which takes input without sending a list data from beck end. But when we send data and bind the elements, we can take input from those elements. So, I think to bind the element in a situation like this we need to send data first time. Correct me if this statement is wrong. Because, that would be a more good solution for me.

    We need to use the lazy list and jsp code is bit modified.

    Your command class object should be created as below mentioned.

    import org.apache.commons.collections.list.LazyList;
    import org.apache.commons.collections.FactoryUtils;
    
    
    
    public class SubDevisonDto {
    
        private String devId;
    
        private List subDevisions = 
            LazyList.decorate(
              new ArrayList(),
              FactoryUtils.instantiateFactory(SubDivison.class));
    

    JSP code should look like below.

    <c:forEach items="${subs.subDevisions}" var="obj" varStatus="gridRow"> 
    

    Binding an input element text box

    <spring:bind path="subdivisondto.subDevisions[${gridRow.index}].subDivisonName">
          <span class="formw"><input name="<c:out value="${status.expression}"/>" type="text"  style="width:350px;" />
    

    binding an input element check box. This input element makes a list.

    <spring:bind path="subs.subDevisions[${gridRow.index}].users">
                  <c:forEach items="${obj.users}" var="dependenttwo" varStatus="dependentRowtwo">
                    <li>
                      <input name="<c:out value="${status.expression}"/>" type="checkbox" class="users" value="<c:out value="${dependenttwo}"/>"/>
                      <c:out value="${dependenttwo}"/>
                    </li>
                    </c:forEach>
                    </spring:bind>
    
    `subs` is a map key name. the value for this key `subs` is a list of my DTO objects which named as `SubDevisonDto `
    

    This code works fine for me.

    Thanks the support given.

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

Sidebar

Related Questions

I have a Grails command object that contains an emailAddresses field, e.g. public class
I have a data object that has many different List properties. I want to
I have a populated SqlCommand object containing the command text and parameters of various
I have a list of objects produced. after click on next I want to
I have a ListBox that is bound to a list of CustomerViewModel-objects, that each
I have the same command that I want to use for two controls on
I have a collection of objects and a command in my ViewModel. I want
I have a display object that displays a list of Users and provides a
Let's say I have an object who's class definition looks like: class Command: foo
I am trying to test a Controller that has a Command object with data

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.