File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts 2 s:if test tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 s:if test tag" Watch "struts 2 s:if test tag" New topic

struts 2 s:if test tag

Katie Doody
Ranch Hand

Joined: Nov 03, 2006
Posts: 90
Hello, I am having some problems getting the syntax correct for an if tag test. I set a String called status in my action that will have a value of "inactice" or "active". I try to test this in my jsp with the following code that does not even render on the page?

Can someone tell me what I am doing wrong here?

<s:if test="%{#status == 'inactive'}">
write something
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Make sure that you have a getStatus and setStatus method in your Action class. Then just remove the "#" from the expression, and it should work:

Consultant, Sima Solutions
Katie Doody
Ranch Hand

Joined: Nov 03, 2006
Posts: 90
It works now, thanks!
I agree. Here's the link:
subject: struts 2 s:if test tag
It's not a secret anymore!