Reputation: 299
I have two bean values one is Integer and other is string i want to check for equality how to do so in jsf?
My code is as below
<c:if test="#{item.asString eq items.asInt}">
<h:outputText value="#{item.name}"></h:outputText>
</c:if>
Now for all condition the codition is checked true please help.
Upvotes: 0
Views: 3751
Reputation: 1108762
You can use the body of <c:set>
to convert any object to string (note: using <c:set value>
as posted by popovitsj's currently edited and deleted answer will not work!)
<c:set var="intAsString">#{items.asInt}</c:set>
<c:if test="#{item.asString eq intAsString}">
<h:outputText value="#{item.name}" />
</c:if>
Unrelated to the concrete problem, unless the condition is only available during view build time, you normally use JSF component's rendered
attribute to conditionally render JSF components:
<c:set var="intAsString">#{items.asInt}</c:set>
<h:outputText value="#{item.name}" rendered="#{item.asString eq intAsString}" />
Upvotes: 1