Wednesday, 18 May 2016

Convert af:inputText value to upperCase, lowerCase, and capitalize by setting contentStyle of the af:inputText in ADF

Requirement: Convert af:inputText value to upperCase, lowerCase, and capitalize by setting contentStyle of the af:input text in ADF
Solution: For solution to the above requirement follow the steps as shown below:
Step 1: Create an Oracle ADF Fusion Web Application.
Step 2: Create a demoPage.jspx page in the ViewController project of our application.
Step 3: Open demoPage.jspx page.
The below code will enforce the User to enter text in an upperCase format
<af:inputText label="First Name" id="it2" contentStyle="text-transform:uppercase;" />
The below code will enforce the User to enter text in a lowerCase format
<af:inputText label="Middle Name" id="it3" contentStyle="text-transform:lowercase;" />
The below code will enforce the User to enter text in an initCap (capilatize) format
<af:inputText label="Last Name" id="it4" contentStyle="text-transform:capitalize;" />
Thus the complete demoPage.jspx code is shown below:
<?xml version='1.0' encoding='UTF-8'?>
<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">
       <jsp:directive.page contentType="text/html;charset=UTF-8" />
       <f:view>
              <af:document title="demoPage.jspx" id="d1">
                     <af:form id="f1">
                           <af:inputText label="First Name" id="it2"
                                  contentStyle="text-transform:uppercase;" />
                           <af:inputText label="Middle Name" id="it3"
                                  contentStyle="text-transform:lowercase;" />
                           <af:inputText label="Last Name" id="it4"
                                  contentStyle="text-transform:capitalize;" />
                     </af:form>
              </af:document>
       </f:view>
</jsp:root>
Step 4: Save all and run the application . Thus the ran application is shown below:
Now type First Name as Susanto, Middle Name as Kumar, and Last Name as Paul. So, irrespective of the case we enter in the various af:inputText, the First Name is accepted as SUSANTO, Middle Name as kumar and Last Name as Paul as shown below:
Thus, the solution to our requirement.
If you like the post, please comment, share and do like me on Facebook.

Thanks & Regards,

Susanto Paul