Fri. Apr 23rd, 2021

Requirement: I have an af:inputDate field in which by default the keyboard input, and the Date selection both are allowed. Now, as per the requirement, I want to disable the keyboard input and only allow the user to select the Date from the Date component.

Solution: For solution of the above requirement follow the steps as shown below:

Step 1: Create an Oracle ADF Fusion Web Application. Create a demo.jspx page in the ViewController project.

Step 2: Drag and drop af:inputDate and set label=”Select Date”

Drag and drop af:resource and set type=”javascript”. The af:resource will be inside af:document

Write the below JavaScript function inside the af:resource

function disableKeyboardInput(event) {
	event.cancel();
}

Drag and drop af:clientListener inside af:inputDate and set method=”disableKeyboardInput” and type=”keyDown”

Thus, the complete code for demo.jspx page 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="demo.jspx" id="d1">
            <af:resource type="javascript">
              function disableKeyboardInput(event) {
                  event.cancel();
              }
            </af:resource>
            <af:form id="f1">
                <af:inputDate label="Select Date" id="id1">
                    <af:clientListener method="disableKeyboardInput" type="keyDown"/>
                </af:inputDate>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>

Save and run the application. Thus, the ran application is shown below:

In the above af:inputDate field user won’t be able to enter date using keyboard nor the user will be able to remove the date using backspace of the keyboard

Hence, the solution to our requirement.

If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.

Thanks & Regards,
Susanto Paul

 152 total views,  2 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

Leave a Reply

Your email address will not be published. Required fields are marked *