Solved

How do I make dynamic lists of Struts 2 form elements?

Posted on 2008-10-23
1
2,454 Views
Last Modified: 2013-11-24
I can display my lists of form objects using Struts 2. I am having problems with the JSP syntax to retrieve data using a ModelDriven object. You can see in code snippet the idea of what I am trying to do.  I have a dynamic list of data and I need to get back one or more data members from each individual object in the list.
<s:iterator value="myList" status="status">			

	<s:textfield id="%{myList[#status.index].description" />

	<s:textfield id="%{myList[#status.index].quantity" />

</s:iterator>
 

class MyRowItem

{

  private String description;

  private Integer quantity;

  // Assume getters/setters

}
 
 

class MyModel

{

  private List<MyRowItem> myList;

  // Assume getters/setters and proper initialization of class

}

Open in new window

0
Comment
Question by:dancingevilgenius
1 Comment
 

Accepted Solution

by:
dancingevilgenius earned 0 total points
ID: 22798842
Found the solution on my own. Below is an example of list of parts.  2 data members will be changed in the form.  One is a dropdown and the other is a textfield.
<s:iterator id="partList"  status="status">

	<s:select list="%{shippingCarrier}" headerKey="-1"

		headerValue="Select One" listKey="id" listValue="descr"		

		id="partList[%{#status.index}].coreReturnCarrierId"

		name="partList[{#status.index}].coreReturnCarrierId"

		value="%{partList[#status.index].coreReturnCarrierId}"       

	/>

	<s:textfield								

		id="partList[%{#status.index}].coreReturnTrackingNumber"

		name="partList[%{#status.index}].coreReturnTrackingNumber"								

		value="%{partList[#status.index].coreReturnTrackingNumber}"

	/>

</s:iterator>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JKS to store upstart data 2 84
mergeTwo  challenge 13 84
count8 challlenge 13 117
eclipse shortcuts 9 45
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now