aspose file tools
The moose likes Struts and the fly likes Display Array data in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Display Array data in JSP" Watch "Display Array data in JSP" New topic
Author

Display Array data in JSP

kapil pat
Greenhorn

Joined: Jul 21, 2006
Posts: 3
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
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
kapil pat
Greenhorn

Joined: Jul 21, 2006
Posts: 3
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
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display Array data in JSP
 
Similar Threads
blank page returned from validate
Struts making me nuts :)
Struts Validation Empty alert Box
Module 'null' not found
Can't get parameter in struts when using input type="file"...?