I have a unable to implementing the Invisible recaptcha V2.0 in ADF.
Below is my Login.jspx code
<?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:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1">
<af:resource type="javascript">
var onloadCallback = function() {
grecaptcha.render('cb2', {
'sitekey' : 'SITE_KEY',
'size' :'invisible',
'callback':validate
});
};
function validate(response){
alert("Validate: "+response);
var button = AdfPage.PAGE.findComponentByAbsoluteId('cb2');
AdfActionEvent.queue(button, button.getPartialSubmit());
}
</af:resource>
<af:resource type="javascript" source="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" />
<af:form id="login">
<af:panelGroupLayout id="pgl1"
inlineStyle="width:732px; height:259px;">
<af:panelFormLayout id="pfl1">
<f:facet name="footer"/>
<af:inputText label="Label 1" id="it1"/>
<af:inputText label="Label 2" id="it2"/>
<af:spacer width="10" height="10" id="s1"/>
<af:commandButton text="Submit" id="cb2"
actionListener="#{LoginBC.test}"/>
</af:panelFormLayout>
</af:panelGroupLayout>
</af:form>
</af:document>
</f:view>
</jsp:root>
The problem is when I am clicking on the Submit button the page is not waiting for the user to take action of related to captcha verification and calling the bean #{LoginBC.test}.
In the bean I have below code
Login.java
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
String gRecaptchaResponse = request.getParameter("g-recaptcha-response");
Since the captcha was never validated by user I am getting blank response for "gRecaptchaResponse"
Because of the cuncorrent call of the bean and the Java script I am unable implement the Google Invisible Recaptcha V2.0 on my login page.
Message was edited by: 3065074