<j:set var="maxEachOSTime" value="0" />
<j:if test="${xmlval > maxEachOSTime}">
${xmlval} > ${ maxEachOSTime}
<j:set var="maxEachOSTime" value="${xmlval}"/>
<j:set var="finalTotalDuration" value="${total_duration}"/>
</j:if>
if ${xmlval} is compared with a number ( 1, 200, etc) it works. But when compared with ${eachMaxOSTime} it doesnt work. (condition is always working as true) .intValue() also didnt help. What is the solution for this?
CodePudding user response:
The following structure is used to define a string
variable with Jelly script:
<j:set var="stringVariable" value="I have value!"/>
<j:set var="maxEachOSTime" value="0"/>
Therefore, the type of the maxEachOSTime
variable is string
. You are trying to equate an integer
on the left side of the equation with a string
using the escape character >
.
CodePudding user response:
This is what that finally helped me in my specific use case.
xmlval is variable which has integer value by reading from xml file
maxEachOSTime var was set as string by default via <j:set>
Converted that into float and used its intValue()
Earlier intValue() was not working as String didnt have attribute intValue, hence the if condition was getting skipped.
This can be improvised by working directly into integers
<j:new className="java.lang.Float" var="tempFloat">
<j:arg value="${maxEachOSTime}" type="float"/>
</j:new>
<j:set var="intThing" value="${tempFloat.intValue()}"/>
<j:if test="${xmlval > intThing}">
<j:set var="maxEachOSTime" value="${xmlval}"/>
<j:set var="finalTotalDuration" value="${total_duration}"/>
</j:if>