Search code examples
jsfjakarta-eedatatableicefaces

"mod" not working in <ace:datatable>


I am using .Nowm when i apply a condition with eq then it is working great in datatable.
For Reference:

<ace:dataTable id="tbl" ..... rowIndexVar="row" 
rowStyleClass="#{((row+2)/2 eq 1)?'chkred':'chknone'}">

but When i am using mod like this

<ace:dataTable id="tbl" ..... rowIndexVar="row" 
rowStyleClass="#{((row+2)/2 mod 0.0)?'chkred':'chknone'}">

it throws an exception

java.lang.IllegalArgumentException: Cannot convert ? of type class java.lang.Double to class java.lang.Boolean

I want to know that Why this code is throwing this exception and how can I use "mod" here?


Solution

  • Its cause the result of mod is a double and not boolean , and you were trying to treat that double result as a boolean

    for example #{10 mod 4} will result in 2 and not true or false

    Also, You can't use + in EL Expression

    try something like this

    <ace:dataTable id="tbl" ..... rowIndexVar="row" 
        rowStyleClass="#{(row mod 2 eq 0)?'chkred':'chknone'}">