Meaningless Drivel is fun!*
The moose likes Struts and the fly likes s:iterator issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "s:iterator issue" Watch "s:iterator issue" New topic
Author

s:iterator issue

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I have an iterator for select like this...



In my Action class...
---------------------------

public class ConditionActionPopUpAction extends ActionSupport
{
ArrayList conAtrAL;

public ArrayList getConAtrAL()
{
System.out.println("in getConAtrAL !!! ");
return conAtrAL;
}

public String execute() throws Exception
{
System.out.println("in execute() !!! ");
conAtrAL=new ArrayList();

.......................
...................... //getting the values into the ArrayList



}

for (Iterator<String> it = conAtrAL.iterator(); it.hasNext();)
{
String st = it.next();
System.out.println("The conAtrAL vals are :--> "+st);

}

}


The Output
----------------

in execute() !!!
The conAtrAL vals are :--> a5
in getConAtrAL !!!
in getConAtrAL !!!

---------------------------------------

Is there any error anywhere in the code??

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
In the aboce code get method is called twice..whta does that mean??
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8876
    
    8

Pradeep Adibatla wrote:In the aboce code get method is called twice..whta does that mean??


There are two references to conAtrAL, one in the iterator tag and one in the property tag. I would assume if conAtrAL had more than one item, it would get called more.
The s:select tag lets you specify a collection for options. Look at the list property in the documentation.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
so you mean to say that I can eliminate s:iterator and give the name of Arraylist in the 'list ' option of s:select...would that suffice?

making the iterator



into this??

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8876
    
    8

I'm not so sure about your value attribute, but yes, you don't need to iterate the options yourself.
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Should I change it to c:if or something wrong with my iterator...

I can see the value in the console but its blank in my UI output....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: s:iterator issue