java - How to send values from inputs to AutoLogin class in Liferay -


i developing linkedin login hook following this example got stuck @ passing parameters .jsp file .java class implementing autologin.

if write portlet, values sent correctly processaction method, here same approach not working.

in linkedin.jsp file have following (simplified) structure.

<% portleturl linkedinregiserurl = renderresponse.createactionurl(); linkedinregiserurl.setparameter(actionrequest.action_name, "linkedinregister"); %>  <form id="linkedinform" action="<%= linkedinregiserurl.tostring() %>" method="post"         name='<portlet:namespace/>linkedinform'>     <input type="hidden" name='<portlet:namespace/>email' id="email" /> </form> 

and inside javascript method, based on linkedin api, populate input , submit form.

document.getelementbyid('email').value = member.emailaddress; document.getelementbyid('linkedinform').submit(); 

everything fine here. problems start inside login() function in loginhook implements autologin class. if print test, following results shown:

@override public string[] login(httpservletrequest request,         httpservletresponse response) throws autologinexception {      string email1 = paramutil.getstring(request, "email");     string email2 = request.getparameter("email");     string email3 = request.getattribute("email").tostring();      system.out.println("email1 : " + email1); //empty value     system.out.println("email2 : " + email2); //null     system.out.println("email3 : " + email3); //null      //etc. } 

i guess problems start here <form id="linkedinform" action="<%= linkedinregiserurl.tostring() %>", not sure , don't know how should pass email parameter.

ps: working liferay 5.2.3, writing class extending basestrutsportletaction out of question.

params inside login hooks in liferay bit tricky, can try 2 things:

use following function retrive "real" request wich may contains parameter (although i´´m not sure if it´s available in liferay 5.2.3, in liferay 6 works):

portalutil.getoriginalservletrequest((javax.servlet.http.httpservletrequest request)

try call , instead post.

another way save email cookie( in javascript) , recover in autologin hook.

hope help...


Comments