Reputation: 33
I am retrieving 2 values (user id and profile id) and I've set them in the variable userId and profileId as shown below.
<s:set name="userId" value="#session.User.id"/>
<s:set name="profileId" value="%{#parameters['id']}"/>
<s:if test="%{#userId} != %{#profileId}" >
<a href="#" title="Follow" id="follow-btn">
<img src="theme/images/follow.png" alt="like" />
<span>Follow</span>
</a>
</s:if>
I have tested by using <s:property value="%{#userId}" />
and <s:property value="%{#profileId}" />
and both of them is able to display out the value. However I just can't get it to work in the if tag. Right now, the link button will never display no matter what's the value in those 2 variable.
I'm not sure if the if tag statement is right however I have tried a lot of combination (playing around with the %{}
and ' '
)
I have a feeling it has something to do with the data type but no matter what I did, the comparison expression just doesn't seem to be working..
Cheers!~
UPDATE:
okay I've found out that the problem is in #profileId
. Probably because the value is from #parameters['id']
which returns a String value. Is there any way to convert this value to int? I've tried Integer.parseInt(#profileId)
but that doesn't work.
Upvotes: 0
Views: 3687