Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

s:iterator issue

 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the aboce code get method is called twice..whta does that mean??
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not so sure about your value attribute, but yes, you don't need to iterate the options yourself.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic