Showing posts with label ajax call using serveResource method. Show all posts
Showing posts with label ajax call using serveResource method. Show all posts

Wednesday, 24 July 2013

Add Captcha in custom portlet with refresh using ajax

Hi Friend,

Here i want to explain how to add captch image in custom portlet & refresh that captch .So i explain step by step.



First in Jsp File Write below code .

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
jQuery("#refreshCaptchaActivity").click(function()
{

jQuery(".captcha").attr("src", jQuery(".captcha").attr("src")+"&force=" + new Date().getMilliseconds());
return false;
});
</script>

<div>
<portlet:resourceURL var="captchaURL" />
<liferay-ui:captcha url="<%=captchaURL%>" />
<div style="padding: 23px 0 0 5px; cursor: pointer;">
<img id="refreshCaptchaActivity"
src="<%= request.getContextPath()%>/refresh.png">
</div>
</div>

//here serveResource Method is used forhandle ajax call in jrs 286 portlet....
Now in java classs we implement serveResourse as well as validate the captch which user enter is valide or not..