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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:21:31+00:00 2026-06-12T11:21:31+00:00

I have a List. The user can add n item number and description. He

  • 0

I have a List. The user can add n item number and description.

He will add first and then to add second will press add more button .

I am giving a call to action class storing the data in array and redirecting back to the page to get the next record.

When I am using the iterator the text boxes are getting added again.

If I dont use iterator my arraylist is getting initailized everytime I visit the action class.

I cannot make it static.It will helpful if anyone can help me either to not initailize the arraylist everytime or use iterator and not repeat the textfields.

<table>
  <tr align="center">
    <s:iterator value="preAdviceDetailsDO" id="preAdviceDetailsDO" status="outerStat">
      <s:if test="#outerStat.may be some useful word like even odd first == true">
        <td style="background: #CCCCCC">
          <s:textfield value="%{itemNumber}" name="preAdviceDetailsDO[%{#outerStat.index}].itemNumber" onblur="checkBarcode();"/>
        </td>

        <td style="background: #CCCCCC">
          <s:textfield value="%{itemDescription}" name="preAdviceDetailsDO[%{#outerStat.index}].itemDescription"/>
        </td>
      </s:if>
    </s:iterator>
  </tr>     
</table>
<input type="button" value="Add More" onclick="addRow()" />
  • 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-12T11:21:32+00:00Added an answer on June 12, 2026 at 11:21 am

    Thanks Dave Newton for editing. MohanaRao SV, I found the solution on it actually its a tweak.The problem I was facing in the above code was :

    When the user see the form for the first time he will see two text field.He will enter the details and to add another record he will press add button. This time the arraylist is incremented. So the text fields on the form will increase to four.That is two earlier one and the new two text fields.And so on…

    So now what I did is in the if condition I am checking if the index is last then I am displaying the fields and in the else part I am writing the same code for adding text field but I have set the css property display:none.

    If I dont write the else part the arraylist is properly incremented but the details in the arraylist are not persisted.

    So now only the required text fields are displayed.

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

Sidebar

Related Questions

I have a list of items that a user can add to by clicking
I have a list of questions that the user will iterate through, they can
I have a list of videos that a user can select from to watch.
I have a list of items on my web page that the user can
I have a list of cities, and i want a user can choose one
I have a check box list in that user can check or uncheck the
I have the following list of time zones that a user can choose from,
I have the following select list from which the user can select multiple values.
I have a form with a select list, where the user can select anywhere
I'm trying to have a View where the user can add items in a

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.