Foren
Captcha Not working in Liferay DXP
Murtaza Ghadiali, geändert vor 7 Jahren.
Captcha Not working in Liferay DXP
New Member Beiträge: 11 Beitrittsdatum: 03.03.14 Neueste Beiträge
Hi,
I had implement liferay captcha in DXP but it is not working.
Following is the code that I had used.
On Jsp :-
<portlet:resourceURL id="/captcha" var="captchaURL">
</portlet:resourceURL>
<liferay-ui:captcha url="<%=captchaURL%>" />
Below is the class
@Component(property = { "javax.portlet.name=" + ContactUsRegistrationConstant.CONTACTUS_REGISTRATION_PORTLET_ID,
"mvc.command.name=/captcha" }, service = MVCResourceCommand.class)
public class CaptchaMVCResourceCommand implements MVCResourceCommand {
/** The Constant _log. */
private static final Log _log = LogFactoryUtil.getLog(CaptchaMVCResourceCommand.class);
/*
* (non-Javadoc)
*
* @see com.liferay.portal.kernel.portlet.bridges.mvc.MVCResourceCommand#
* serveResource(javax.portlet.ResourceRequest,
* javax.portlet.ResourceResponse)
*/
@Override
public boolean serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws PortletException {
try {
CaptchaUtil.serveImage(resourceRequest, resourceResponse);
return false;
} catch (Exception e) {
_log.error(e, e);
return true;
}
}
}
I had implement liferay captcha in DXP but it is not working.
Following is the code that I had used.
On Jsp :-
<portlet:resourceURL id="/captcha" var="captchaURL">
</portlet:resourceURL>
<liferay-ui:captcha url="<%=captchaURL%>" />
Below is the class
@Component(property = { "javax.portlet.name=" + ContactUsRegistrationConstant.CONTACTUS_REGISTRATION_PORTLET_ID,
"mvc.command.name=/captcha" }, service = MVCResourceCommand.class)
public class CaptchaMVCResourceCommand implements MVCResourceCommand {
/** The Constant _log. */
private static final Log _log = LogFactoryUtil.getLog(CaptchaMVCResourceCommand.class);
/*
* (non-Javadoc)
*
* @see com.liferay.portal.kernel.portlet.bridges.mvc.MVCResourceCommand#
* serveResource(javax.portlet.ResourceRequest,
* javax.portlet.ResourceResponse)
*/
@Override
public boolean serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws PortletException {
try {
CaptchaUtil.serveImage(resourceRequest, resourceResponse);
return false;
} catch (Exception e) {
_log.error(e, e);
return true;
}
}
}
John Lulich, geändert vor 7 Jahren.
RE: Captcha Not working in Liferay DXP
New Member Beiträge: 10 Beitrittsdatum: 19.04.16 Neueste Beiträge
I'm about to work on the same type of thing. Have you figured out the problem yet?
Cheers,
John
Cheers,
John
Arti Gupta, geändert vor 6 Jahren.
RE: Captcha Not working in Liferay DXP
New Member Beiträge: 5 Beitrittsdatum: 29.04.13 Neueste Beiträge
Hi Murtaza,John
I also facing the same problem . need to implement captcha for signin portlet but it is not working.
Have your issue resolved ?
Any help really appreciated.
Thanks,
Arti Gupta
I also facing the same problem . need to implement captcha for signin portlet but it is not working.
Have your issue resolved ?
Any help really appreciated.
Thanks,
Arti Gupta
pablo iglesias, geändert vor 6 Jahren.
RE: Captcha Not working in Liferay DXP
New Member Beiträge: 9 Beitrittsdatum: 16.12.13 Neueste Beiträge
Hi,
Actually I do not render the captcha with the tag liferay-ui: captcha, I did it in the following way:
jsp:
Resource comand class:
Action Class:
I hope you have solved the problem
Actually I do not render the captcha with the tag liferay-ui: captcha, I did it in the following way:
jsp:
<portlet:actionurl name="/contact/contact" var="contactActionURL" />
<portlet:resourceurl id="/contact/captcha" var="captchaURL" />
<liferay-ui:error exception="<%= CaptchaException.class %>" message="text-verification-failed" />
<form action="${contactActionURL}" method="post">
<img alt="captcha" class="captcha" id="captchaImg" src="${captchaURL}">
<liferay-ui:icon cssClass="refresh" iconCssClass="icon-refresh" id="refreshCaptcha" label="<%= false %>" localizeMessage="<%= true %>" message="refresh-captcha" url="javascript:;" />
<input name="<portlet:namespace />captchaText" id="<portlet:namespace />captchaText" size="10" type="text" value="" required>
</form>
<aui:script>
$('#<portlet:namespace />refreshCaptcha').on("click",
function(ev){
$("#captchaImg").attr('src', '${captchaURL}&force=' + encodeURIComponent(Math.floor(Math.random() * Math.pow(2, 53))));
});
</aui:script>
Resource comand class:
@Component(
immediate = true,
property = {
"javax.portlet.name=" + FormulariosConstantes.PORTLET_FORMULARIOS_CONTACTANOS,
"mvc.command.name=/contact/captcha"
},
service = MVCResourceCommand.class
)
public class CaptchaMVCResourceCommand extends BaseMVCResourceCommand{
private final Log _log = LogFactoryUtil.getLog(
CaptchaMVCResourceCommand.class);
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws Exception {
ParamUtil.print(resourceRequest);
try {
CaptchaUtil.serveImage(
resourceRequest, resourceResponse);
} catch (Exception e) {
_log.error(e.getMessage());
}
}
}
Action Class:
@Component(
immediate = true,
property ={
"javax.portlet.name=" + FormulariosConstantes.PORTLET_FORMULARIOS_CONTACTANOS,
"mvc.command.name=/contact/contact"
},
service = MVCActionCommand.class
)
@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
ParamUtil.print(actionRequest);
try {
CaptchaUtil.check(actionRequest);
} catch (CaptchaException e) {
SessionErrors.add(actionRequest, CaptchaException.class);
}
I hope you have solved the problem
Arti Gupta, geändert vor 6 Jahren.
RE: Captcha Not working in Liferay DXP
New Member Beiträge: 5 Beitrittsdatum: 29.04.13 Neueste Beiträge
Hi pablo iglesias,
Thanks for the quick reply. Actually i stucked to implement captcha in SignIn Portlet.
For implementing Captcha In SignIn Portlet
Need to customise
1. login.jsp
2.Add MVCResourceCommand for LogIn portlet
3 Override LoginMVCActionCommandAction
I created the fragment and add your JSP code
it's working well .
But the problem for calling the serveImage method need to implement MVCResource command
So ,i created another Component for add CustomMvcResource command .
and when I tried to deploy it showing me error
Caused by: java.lang.NoClassDefFoundError: com/liferay/portal/kernel/portlet/bridges/mvc/BaseMVCResourceCommand
For detail PFA log file.
Here i am attaching my source code
Any Help really appreciated .
Thanks for the quick reply. Actually i stucked to implement captcha in SignIn Portlet.
For implementing Captcha In SignIn Portlet
Need to customise
1. login.jsp
2.Add MVCResourceCommand for LogIn portlet
3 Override LoginMVCActionCommandAction
I created the fragment and add your JSP code
it's working well .
But the problem for calling the serveImage method need to implement MVCResource command
So ,i created another Component for add CustomMvcResource command .
and when I tried to deploy it showing me error
Caused by: java.lang.NoClassDefFoundError: com/liferay/portal/kernel/portlet/bridges/mvc/BaseMVCResourceCommand
For detail PFA log file.
Here i am attaching my source code
Any Help really appreciated .
Arti Gupta, geändert vor 6 Jahren.
RE: Captcha Not working in Liferay DXP
New Member Beiträge: 5 Beitrittsdatum: 29.04.13 Neueste Beiträge
Any Help???
Do i need to put any changes in properties file??
Do i need to put any changes in properties file??
pablo iglesias, geändert vor 6 Jahren.
RE: Captcha Not working in Liferay DXP
New Member Beiträge: 9 Beitrittsdatum: 16.12.13 Neueste Beiträge
Hello,
you do not need to put anything in the properties file.
you do not need to put anything in the properties file.
Arti Gupta, geändert vor 6 Jahren.
RE: Captcha Not working in Liferay DXP
New Member Beiträge: 5 Beitrittsdatum: 29.04.13 Neueste Beiträge
Hi pablo iglesias,
Thanks for the quick reply. Actually i stucked to implement captcha in SignIn Portlet.
For implementing Captcha In SignIn Portlet
Need to customise
1. login.jsp
2.Add MVCResourceCommand for LogIn portlet
3 Override LoginMVCActionCommandAction
I created the fragment and add your JSP code
it's working well .
But the problem while calling the serveImage method need to implement MVCResource command
So ,i created another Component for add CustomMvcResource command .
and when I tried to deploy it showing me error
Caused by: java.lang.NoClassDefFoundError: com/liferay/portal/kernel/portlet/bridges/mvc/BaseMVCResourceCommand
For detail PFA log file.
Here i am attaching my source code
Any Help really appreciated .
Thanks for the quick reply. Actually i stucked to implement captcha in SignIn Portlet.
For implementing Captcha In SignIn Portlet
Need to customise
1. login.jsp
2.Add MVCResourceCommand for LogIn portlet
3 Override LoginMVCActionCommandAction
I created the fragment and add your JSP code
it's working well .
But the problem while calling the serveImage method need to implement MVCResource command
So ,i created another Component for add CustomMvcResource command .
and when I tried to deploy it showing me error
Caused by: java.lang.NoClassDefFoundError: com/liferay/portal/kernel/portlet/bridges/mvc/BaseMVCResourceCommand
For detail PFA log file.
Here i am attaching my source code
Any Help really appreciated .
Jignesh Vachhani, geändert vor 6 Jahren.
RE: Captcha Not working in Liferay DXP
Liferay Master Beiträge: 803 Beitrittsdatum: 10.03.08 Neueste Beiträge
Remove
Import-Package: com.liferay.login.web.constants
-sources: true
from Login-web-hook .bnd file.
This will resolve your issue of class loading and you will be able to see Liferay captcha
Import-Package: com.liferay.login.web.constants
-sources: true
from Login-web-hook .bnd file.
This will resolve your issue of class loading and you will be able to see Liferay captcha
Joye Luo, geändert vor 6 Jahren.
RE: Captcha Not working in Liferay DXP
Regular Member Beiträge: 144 Beitrittsdatum: 03.05.16 Neueste Beiträge
Hey Murtaza,
I have met the same issue as u.
Did you find the solution?
I have met the same issue as u.
Did you find the solution?
Joye Luo, geändert vor 6 Jahren.
RE: Captcha Not working in Liferay DXP
Regular Member Beiträge: 144 Beitrittsdatum: 03.05.16 Neueste Beiträge
I solved my problem by change
<liferay-ui:captcha url="<%= captchaURL %>
to <liferay-captcha:captcha url="<%= captchaURL %>" />
See ticket https://issues.liferay.com/browse/LPS-69383
<liferay-ui:captcha url="<%= captchaURL %>
to <liferay-captcha:captcha url="<%= captchaURL %>" />
See ticket https://issues.liferay.com/browse/LPS-69383
Pradnya Parvatikar, geändert vor 4 Jahren.
RE: Captcha Not working in Liferay DXP
New Member Beiträge: 10 Beitrittsdatum: 03.11.17 Neueste Beiträge
Please try with the following in jsp:
<%@taglib uri="http://liferay.com/tld/captcha" prefix="liferay-captcha" %>
<%@page import="com.liferay.portal.kernel.captcha.Captcha"%>
<portlet:resourceURL var="captchaURL"/>
<liferay-captcha:captcha url="${captchaURL}" />
<%@taglib uri="http://liferay.com/tld/captcha" prefix="liferay-captcha" %>
<%@page import="com.liferay.portal.kernel.captcha.Captcha"%>
<portlet:resourceURL var="captchaURL"/>
<liferay-captcha:captcha url="${captchaURL}" />