swetha
swetha

Reputation: 241

Using greater than logical expression in rendered attribute

I have an outputText field for which I write a condition in the rendered attribute. The condition is for comparing the length of the string with some numeric value.

<h:outputText id="emailaddress" 
    value ="#{subsAlertsHelper.personEmail.substring(0,20)}"
    rendered="#{subsAlertsHelper.personEmail.length() >20}" />

If I use == or != in rendered it is working fine. But for greaterthan and lessthan it is not giving the output. What could be the reason for that?

Upvotes: 24

Views: 56286

Answers (2)

dertkw
dertkw

Reputation: 7858

You have to use gt and lt operators.

Check out JavaServer Faces Expression Language Intro from Sun/Oracle. Precisely the Operators section.

Upvotes: 52

Jean-Charles
Jean-Charles

Reputation: 1720

rendered only accepts EL expression.

subsAlertsHelper.personEmail.length() is incorrect.

On the personEmail object, add a method getLength() witch returns the length

public int getLength(){ return this. length();}

Modify :

rendered="#{subsAlertsHelper.personEmail.length >20}"

Upvotes: 3

Related Questions