Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using greater than logical expression in rendered attribute

Tags:

jsf

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?

like image 308
swetha Avatar asked Aug 22 '11 09:08

swetha


2 Answers

You have to use gt and lt operators.

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

like image 140
dertkw Avatar answered Nov 23 '22 23:11

dertkw


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}"
like image 38
Jean-Charles Avatar answered Nov 23 '22 23:11

Jean-Charles