Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display Array data in JSP

 
kapil pat
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a property in the ActionForm of type array. I need to display that on the JSP tabele.

Below is the code snippet.

I am not able to iterate to the Array and display it on the JSP. I tried hardcoding the arrayindex like addressId[0] and it displays proper data.

Please suggest a way out..

Action Form
public class CustomerForm extends ValidatorForm {

String customerId = null;
String[] addressId = null;
String[] addressName = null;

}


JSP Page
<html:form action="customer" name="CustomerForm" type="test.CustomerForm">
<html:text name="customerData" property="customerId" />
<tabl>
<tr><td>Address ID </td><td>Address Name </td>
</tr>
<tr>
<td><html:text name="customerData" property="addressId"/></td>
<td><html:text name="customerData" property="addressName"/></td>
</tr>
</tabl>
</html:form>



Thanks in advance,
Kapil
 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kapil please Use Code Tags when you post a source code. You can edit your message using button and then add code tags to it.

Where are you iterating over the arrays?? You are just displaying the array in text fields. Look at the logic:iterate tag...
 
kapil pat
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ankit,

I did try logic:iterate but was not able to achieve it. Can you please help me in writing that part of code ?

My CustomerForm is available in the custBO session variable. And I have to create as many rows as the size of addressId Array.

Thanks,
Kapil
 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but I'm not good at struts 1.x, someone else would be able to help you. You can show us the logic:iterate code that you tried which might make it easier to know the mistake that you did. This example might also be useful...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic