1

I am new to struts and I saw below code in my current project

<logic:equal name="USER" property="readOnlyRole"  value="false" >

is USER in name="USER" a bean object? above code means USER.isReadOnlyRole right?

I want to implement a OR condition here, how would I do that for above condition. I know I can use jstl choose tag. Is following code correct replacement of above?

<c:choose>
    <c:when test="${USER.isReadOnlyRole == 'false'}">
       False
    </c:when>
    <c:when test="${USER.isReadOnlyRole == 'true'}">
        True
    </c:when>

</c:choose>
Sandeep Kumar
  • 13,799
  • 21
  • 74
  • 110

1 Answers1

0

Hello Sandy,

 <logic:equal name="USER" property="readOnlyRole"  value="false" >

You are right, above code checks for the equality of value of readOnlyRole property of USER bean with false.

However there is small change in your second code using c tag. Just replace User.isReadOnlyRole with User.readOnlyRole. It should be <BEAN NAME>.<PROPERTY NAME>. You can also use eq for checking equality, ne for not equal, etc. (You can use == as well.)

<c:choose>
    <c:when test="${USER.readOnlyRole eq false}">
       False
    </c:when>
    <c:when test="${USER.readOnlyRole eq true}">
        True
    </c:when>
</c:choose>

Hope it helps.

Saurabh
  • 1,405
  • 1
  • 21
  • 42