aspose file tools*
The moose likes Struts and the fly likes Iterator in Struts 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Iterator in Struts 1" Watch "Iterator in Struts 1" New topic
Author

Iterator in Struts 1

Manoj Paul
Ranch Hand

Joined: Jan 18, 2007
Posts: 112
Hi all,

I have a list in my session.
My jsp page:




Can I use Struts iterator to loop through the list (myList)?
I am using Struts 1.

Regards
Kartik Talasu
Ranch Hand

Joined: Aug 21, 2009
Posts: 98
In this way it works.
At first set the list in request attribute in Action class



And in JSP using Logic Iterator to collect them.

Manoj Paul
Ranch Hand

Joined: Jan 18, 2007
Posts: 112
Hi Kartik
Thanks for the reply

# <logic:iterate id="myList" name="myList" scope="request">
# <bean:write name="myList" />
# </logic:iterate>


Where should I make the changes if I want to display the value of each ("description") of my list in my jsp page using
out.println();

Regards
Kartik Talasu
Ranch Hand

Joined: Aug 21, 2009
Posts: 98
Why do you need again out.println ?
The code which I had given will automatically displays all the values of the list in the JSP.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

Why do you need again out.println ?

Agreed, if you want to display the description property of the elements in the list, then I think you should use the property attribute of the bean:write tag (but I'm not sure, I'm not good at Struts 1.x)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Manoj Paul
Ranch Hand

Joined: Jan 18, 2007
Posts: 112
Hello Kartik,
The data is not displaying in my jsp page.

Here's my method in the Action class




This is my jsp page:



Can you figure it out?
I checked that request .getAttribute always point to null

Thanks & regards
Kartik Talasu
Ranch Hand

Joined: Aug 21, 2009
Posts: 98
session.setAttribute("TARIFF_CATEGORIES_LIST", tariffCategoriesList);
httpRequest.setAttribute("TARIFFCATEGORIESLIST", tariffCategoriesList);


This lines should suppose to be at end of try loop i.e at line number 105.
And after writing this lines write Sytem.out.println to check in action class itself whether its having value or not.
And one more thing like had you declared "request" in JSP? as am not able to see in the jsp.
Manoj Paul
Ranch Hand

Joined: Jan 18, 2007
Posts: 112
And one more thing like had you declared "request" in JSP? as am not able to see in the jsp.

No
Request is an jsp implicit object.. Do I need to declare it still?
Please advice

Kartik Talasu
Ranch Hand

Joined: Aug 21, 2009
Posts: 98
Ya its my mistake, it will come automatically.
But are you able to see the results in action class or not?
Manoj Paul
Ranch Hand

Joined: Jan 18, 2007
Posts: 112
Hello Kartik!

To descibe you in more detail
Here's my jsp page coding


You could see that within the for-loop there is a
The data is diplaying fine here. But using this that is within the for-loop the value showing in the text field is that of the value of the

So thats where the problem is if I use any Html element in my code the value showing is that of some other elements.
Yes the data is displaying in the Action class (i.e both description and tariff_Category_Id) of the complete list.

Please advice if you can.

Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterator in Struts 1