This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
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

struts2 iterator status question

 
Nilesh Thali
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Just wondering if something like this is legal in strut2:

even though, while debugging, i can see that course.index and someVar are the same value, the if condition doesn't trigger.
is it not possible to compare the status index with a jsp variable?
Thanks,
Nilesh
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you use a scriptlet variable for this?
 
Nilesh Thali
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, but a question like that doesn't even begin to help.
anyways, disregard the question - downloaded struts2 and xwork src, debugged and found out that the s:if test construct will only take specific literal or predefined constants.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "test" attribute will take any valid OGNL expression, which can be constants, literals, method calls, expressions, etc.

The point was that there's almost *never* any reason to use a scriptlet variable in this fashion, and that by answering the question and showing *why* you wanted to use a scriptlet variable for this, you might have learned a better way to do it.
 
vishwa venkat
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you try test=%{#course.index == someVar}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic