Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Friday, March 11, 2011

ADF 11g: String comparison in EL expressions

Few days ago I got a situation where i had to compare a part of a string type vo attribute to decide on rendering a component. The value in the vo attribute was a url like http:://facebook.com/user/id=2454555 . So, the requirement was to render a component only if the url is of facebook.  By default you cannot write an EL expression on render property to achieve this. So here is what you can do:

1. On the jspx or jsff add xmlns:fn="http://java.sun.com/jsp/jstl/functions" Make sure to add the library as well in the project properties

2. Now you can right as:  <af:outputtext id="o1" rendered="#{fn:contains(row.link, 'facebook') ? true :false}">

3 comments:

Anonymous said...

Hi, were you able to achieve this?

Unknown said...

Yes and that is why it is posted here.

Achinto Banerjee said...

works like a charm .