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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:30:35+00:00 2026-06-18T08:30:35+00:00

I have complex form objects, with unlimited depth and I’m trying to edit them

  • 0

I have complex form objects, with unlimited depth and I’m trying to edit them on jsp with spring form tags.

Main modelAttribute is bind to spring form, and while I’m iterating through childs, I use nestedPath and everithing works OK. As result I have generated input names something like:

name="elements['secondColumn'][0].elements[0].removed"

Problem is that I can not know the generated name. Why I need it? Let’s say that I have delete button from which I want to set appropriate field “removed” to 1.

Update:
How does it works? I am using tag files which are recursively calling them self.

container.tag

<c:forEach items="${elements}" var="element" varStatus="index">
 <spring:nestedPath path="elements[${index.count - 1}]">
   <my:elementConfig element="${element}">
    <my:container elements="${element.elements}"/>
   </my:elementConfig>
 </spring:nestedPath>
</c:forEach>

elementConfig.tag

...
<form:hidden path="removed"/>
...
<button onclick="delete('howToGetNameOfRemovedHidden')">Delete</button>
...
<jsp:doBody/>
...

Closest match I allready found is a “nestedPath” pageContext attribute, but it contains the name of the modelAttribute (form) name too.

Is there official way to get the generated name?

Thanks

  • 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-18T08:30:36+00:00Added an answer on June 18, 2026 at 8:30 am

    As it seems there is no official support for getting generated input names, so I’ve made a function which handles it. It is based on a functionality I found in Spring form tag library.

    Static methods:

    public class JspUtils {
    
        public static String escapeJS( String value) {
            return StringEscapeUtils.escapeJavaScript( value);
        }
    
        public static String getPath( PageContext pageContext, String name) {
    
            String path =   (String)pageContext.getRequest().getAttribute( "nestedPath");
            if (path == null)
                path    =   (String)pageContext.getAttribute( "nestedPath");
            if (path == null)
                return name;
    
            path        =   path.substring( path.indexOf( ".") + 1);
            path        +=  name;
            return path;
        }
    
        public static String getPathJsEscaped( PageContext pageContext, String name) {
            return StringEscapeUtils.escapeJavaScript( getPath(pageContext, name));
        }
    }
    

    tld definition:

    <function>
        <description>
            Get nested path value as string
        </description>
        <name>getPath</name>
        <function-class>com.pathfix.JspUtils</function-class>
        <function-signature>java.lang.String getPath(javax.servlet.jsp.PageContext, java.lang.String)</function-signature>
    </function>
    <function>
        <description>
            Get nested path value as javascript escaped string
        </description>
        <name>getPathJsEscaped</name>
        <function-class>com.pathfix.JspUtils</function-class>
        <function-signature>java.lang.String getPathJsEscaped(javax.servlet.jsp.PageContext, java.lang.String)</function-signature>
    </function>
    

    Example usage:

    <%@ taglib prefix="pathfix" uri="http://pathfix.com"%>
    
    Name: <form:input path="name"/>
    <a href="javascript: alert('Generated name is ${pathfix:getPathJsEscaped( pageContext, 'name')}')">Test it!</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm have a fair complex Form that I am trying to create in Play
I have a complex form in Ruby on Rails 2.3.5, here's the structure for
I have a complex input form within a PHP based web application. To structure
I have a fairly complex html form enhanced via jquery. It has multiple tabs,
I have a web app that has a big and complex form (fields, checks,
We have the following code working for a complex rails form with checkboxes. I'm
I am following alloy-complex-form-examples from github trying to learn nested forms and I just
In the project, I have to send complex JSON commands form the server to
I have a complex view model which contains a collection of other objects which
I have a rather complex model that I am using to render a form

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.