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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:57:11+00:00 2026-06-12T03:57:11+00:00

i have this Class public Class Employee { String name; List<Address> listOfAddress; } public

  • 0

i have this Class

public Class Employee
{
    String name;
    List<Address> listOfAddress;
}

public Class Address
{
    String location;
    String streetName;
}

in my JSP page i have filled like this

 <s:textfield id="streetName" name="listOfAddress[%{listOfAddress.size()}].streetName" size="20" maxlength="24" cssStyle="width: 100px" />

each time i submit the page an object of time Address is added to the list therefore the size will increase by one.
when i view the source HTML of the previous textField, its name looks like this listOfAddress[0].streetName , if i submit the JSP page after succefull addition, it will return to the same page and the name of this textfield will be listOfAddress[1].streetName
if you view its HTML source

and like this i can add as many addresses as i want to same Employee object.

so far everything is OK. the problem is when i want to validate this field ican’t because it is dynamic
if i put this validation it will validate it the first time only.

     <field name="listOfAddress[0].streetName">
        <field-validator type="requiredstring" short-circuit="true">
           <param name="trim">true</param>
           <message>sorry this field is required field</message>
       </field-validator>
    </field> 

what i want is to make the index of the list “listOfAddress” dymanic according to the size of the list.

i don’t know how to pass it dynamicall from the jsp

can i do something like this ?

    <field name="listOfAddress[**${dynamic index value}**].streetName">
        <field-validator type="requiredstring" short-circuit="true">
           <param name="trim">true</param>

           **<param name="myIndex">${dynamic index value}</param>**

           <message>sorry this field is required field</message>
       </field-validator>
    </field> 

or pass the dynamic value to a custom validator ?

please help me, how to validate the list when the index is dynamic

  • 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-12T03:57:12+00:00Added an answer on June 12, 2026 at 3:57 am

    Use visitor validator. See http://struts.apache.org/2.x/docs/using-visitor-field-validator.html.

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

Sidebar

Related Questions

i have a data structure like this public class Employee { public string Name
Assume I have a business object like this, class Employee { public string name;
For C# properties, I can do this: public class Employee{ public string Name {
i have this class public class Image { public string url { get; set;
I have this class: public MyClass { public void initialize(Collection<String> data) { this.data =
I have this Class: public class User { public string id{ get; set; }
I have this class : public class TempFileRef { public readonly string FilePath; public
I have this class public class wordObject implements java.io.Serializable { String wordName; int occCount;
If I have a couple of classes like this ; public class Employee {
I have a class Employee, this has an IList<> of TypeOfWork. public class Employee

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.