This post is about a question that is asked on the OTN forum. In this post, I'll show you how we can set the current date in af:inputDate component with a double click of the mouse. For this, we need to use a simple javascript function.
Here we have an inputDate component on the page and added javascript function as a resource in the page. See page XML source
- <?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="SetCurrentDate.jspx" id="d1">
- <af:resource type="javascript">
- function setDate(evt) {
- var comp = evt.getSource()
- comp.setValue(new Date());
- }
- </af:resource>
- <af:form id="f1">
- <af:inputDate label="Label 1" id="id1">
- <af:clientListener method="setDate" type="dblClick"/>
- </af:inputDate>
- </af:form>
- </af:document>
- </f:view>
- </jsp:root>
All done, as you can see that the javascript function is called using clientListener on double click event of input date component.
Cheers Happy Learning
No comments :
Post a Comment