Tuesday, September 25, 2012

Using JSTL in ADF Faces - By Frank Nimphius

The JavaServer Pages Standard Tag Library (JSTL) provides expressions for common web application functionalities. Though JavaServer Faces Expression Language (EL) is different from JSTL expressions, the two can be used in combination for functional for which it makes sense. For example, the table below lists JSTL expressions that operate on String values.
 
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 withing 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 in Oracle ADF Faces component EL references, you need to add the JSTL namespace of the tags you want to reference. For the JSTL functions shown in the table above, you need to manually add the name space highlighted in red to the JSPX document or page fragment.
 
<jsp:root  
 xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"         
 xmlns:f="http://java.sun.com/jsf/core"         
 xmlns:h="http://java.sun.com/jsf/html"         
 xmlns:af="http://xmlns.oracle.com/adf/faces/rich"        
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
 
The value expression below, referenced in an af:outputText component, displays the substring (first, second and third character) for a value read from the ADF binding layer.
 
<af:outputText value="#{fn:substring(bindings.employeeName.inputValue,1,3)}" id="ot7"/>
 

Friday, September 14, 2012

How to read and write prefs.js (Preference) Firefox

Have to call the below JavaScript from the jsp page onload
function load() {
      try
      {
          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.ietab2.");
          if (prefManager.prefHasUserValue("filterlist")) {
              prefString = prefManager.getCharPref("filterlist");
              if (prefString.indexOf("http://127.0.0.1:7001/*") == -1){
              prefManager.setCharPref("filterlist",prefManager.getCharPref("filterlist")+" http://127.0.0.1:7001/*");
              }
          }
          else {
              prefString = "0";
          }
          window.open("http://127.0.0.1:7101/Application/login.jsp",'_SELF');
      }
          catch(err)
          {       
          }
      }