1

I have Array list called matrixList, on which i am iterating. I want to display different value if return value from getStatus() method equals to value "GREEN" .For some reason i am getting error "target is null for method equals"

<s:iterator status="stat" value="matrixList">
  <tr>
    <s:if test="%{#status.equals('GREEN')}">
      THIS IS green
    </s:if>

    <td class="R0C1"><s:property value="status"/></td>
    <td class="R0C1"><s:property value="releaseTarget"/></td>
  </tr>
</s:iterator>

Any idea what I'm missing?

2
  • Are you sure that status isn't null? Commented Jan 13, 2015 at 6:56
  • yes, Status value is not null. it have value 'GREEN', I displayed it at separate column. Commented Jan 13, 2015 at 19:25

2 Answers 2

2

Omit # if status is on the value stack (as opposed to a named value in the stack context):

<s:if test="%{status.equals('GREEN')}">

If <s:property value="status"/> works why reference it differently in the <s:if> tag?

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Removing '#' sign fix it.
0

The property name used in the if statement should be stat and not status.

<s:if test="%{#stat.equals('GREEN')}">

This is because the name of the variable in the iteration scope is defined as stat in the status = "stat" statement.

3 Comments

But i want to compare against value return by getStatus() Method.<td class="R0C1"><s:property value="status"/></td>
status="stat" is an attribute of <s:iterator> tag which isn't current iteration element.
it is also current iteration element as well, just like releaseTarget as shown above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.