anoop
anoop

Reputation: 1614

struts property tag inside struts if tag

How can I implement this without illegally nesting JSP tags?

<s:if test="<s:property value="#count" /> == <s:property value="%{arrayCount}" "/>

Upvotes: 1

Views: 8920

Answers (2)

Umesh Awasthi
Umesh Awasthi

Reputation: 23587

The Struts 2 <s:if> tag is capable enough to fetch values from the value stack or any other context so there is no need to use the property tag inside the if tag.

I assume that both count and arrayCount are available in your value stack, or you have set those in your action class/jsp page. All you need to do is:

<s:if test="#count == arrayCount">
  // do what ever you want 
</s:if>

Itss best to go through some basic OGNL syntax:

  1. OGNL
  2. OGNL Basics

Upvotes: 4

Dave Newton
Dave Newton

Reputation: 160321

You can't randomly nest tags like that, the same as with XML and HTML.

Use OGNL:

<s:if test="#count == arrayCount">

See here and here for some really basic OGNL info, and the OGNL site for specifics.

Upvotes: 4

Related Questions