Saturday 12 July 2014

Using JSTL in ADF Faces

This blog we will see how to use JSTL in ADF faces.

In some scenario, sometimes it is required to use Java Server Pages Standard Tag Library (JSTL) in JSPX page or page fragment. The below functions can use in regular expression.




JSTL Function
Description
fn:contains()
Tests if an input string contains the specified substring.
fn:containsIgnoreCase()
Tests if an input string contains the specified substring in a case insensitive way.
fn:endsWith()
Tests if an input string ends with the specified suffix.
fn:escapeXml()
Escapes characters that could be interpreted as XML markup.
fn:indexOf()
Returns the index within a string of the first occurrence of a specified substring.
fn:length()
Returns the number of items in a collection, or the number of characters in a string.
fn:replace()
Returns a string resulting from replacing in an input string all occurrences with a given string.
fn:startsWith()
Tests if an input string starts with the specified prefix.
fn:substring()
Returns a subset of a string.
fn:substringAfter()
Returns a subset of a string following a specific substring.
fn:substringBefore()
Returns a subset of a string before a specific substring.
fn:toLowerCase()
Converts all of the characters of a string to lower case.
fn:toUpperCase()
Converts all of the characters of a string to upper case.
fn:trim()
Removes white spaces from both ends of a string.


To use JSTL functions in ADF Faces component, you need to add the JSTL namespace in JSPX page or page fragment. The below namespace manually need to add the name space.
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
                  xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
                 xmlns:fn="http://java.sun.com/jsp/jstl/functions">
The below expression required in an af:outputText component.
<af:outputText value="#{fn:substring(bindings.userName.inputValue,1,5)}" id="ot1"/>

The below code is required to display the department name if the department name is “IT”.
<af:outputText value=”#{ row.bindings.deptName.inputValue}” rendered="#{fn:containsIgnoreCase(row.bindings.deptName.inputValue,'IT')}" id="ot1"/>
 

Thanks…

No comments:

Post a Comment