留言板
RE: Custom Registration Portlet
Hello! I have to do an exercise for university. I have to create a registration portlet. I have done a form with Name, LastName, Username, Password and Email Address.
I want that when I have insert all personal informations, new user was written in database. So I do this:
But also if I see message ok, I won't have new user in database.
What I have to do?
This istruction not work: UserLocalServiceUtil.addUser(utente);
I want that when I have insert all personal informations, new user was written in database. So I do this:
public void login(ActionRequest req, ActionResponse res) throws IOException, ReadOnlyException, ValidatorException, SystemException, com.liferay.portal.kernel.exception.PortalException{
PortletPreferences p=req.getPreferences();
String n= req.getParameter("nome");
String c= req.getParameter("cognome");
String u= req.getParameter("user");
String e= req.getParameter("email");
String psw= req.getParameter("password");
String rpsw= req.getParameter("ripeti");
if(n.equals("")){
SessionErrors.add(req,"bad1");
}
else if(c.equals("")){
SessionErrors.add(req,"bad2");
}
else if(u.equals("")){
SessionErrors.add(req,"bad3");
}
else if(e.equals("")){
SessionErrors.add(req,"bad4");
}
else if(psw.equals("")){
SessionErrors.add(req,"bad5");
}
else if(rpsw.equals("")){
SessionErrors.add(req,"bad6");
}
else if(!psw.equals(rpsw)){
SessionErrors.add(req,"nopass");
}
else{
long id=CounterLocalServiceUtil.increment();
User utente=UserLocalServiceUtil.createUser(id);
utente.setFirstName(n);
utente.setLastName(c);
utente.setScreenName(u);
utente.setPassword(psw);
utente.setEmailAddress(e);
try {
UserLocalServiceUtil.addUser(utente);
}
catch (SystemException e2) {
e2.printStackTrace();
}
p.setValue("user",u);
p.store();
SessionMessages.add(req,"ok");
res.setRenderParameter("jspPage","/html/prova/edit.jsp");
}
}
But also if I see message ok, I won't have new user in database.
What I have to do?
This istruction not work: UserLocalServiceUtil.addUser(utente);
Try addUser(many many parameters)
I have tried with this:
And I have use addUser with all parametres.
But I have seen: "Your request failed to complete". Without other informations
ThemeDisplay theme= (ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);
long creatorUserId = theme.getUserId(); // default liferay user
long companyId = theme.getCompanyId(); // default company
boolean autoPassword = false;
String password2 = "";
boolean autoScreenName = false;
long facebookId = 0;
String openId = "";
Locale locale = theme.getLocale();
String middleName = "";
int prefixId = 0;
int suffixId = 0;
boolean male = true;
int birthdayMonth = 10;
int birthdayDay = 10;
int birthdayYear = 2010;
String jobTitle = "";
long[] groupIds = null;
long[] organizationIds = null;
long[] roleIds = null;
long[] userGroupIds = null;
boolean sendEmail = false;
And I have use addUser with all parametres.
But I have seen: "Your request failed to complete". Without other informations
Hi Valerio,
In your code I couldn't find 'password1;. Hope you had given both password1 and password2 as params for addUser.
Thanks,
SIby
In your code I couldn't find 'password1;. Hope you had given both password1 and password2 as params for addUser.
Thanks,
SIby
I have use psw and not password1 because with
I catch value from the form
String psw= req.getParameter("password");
I catch value from the form
Obiouvsly I have done also this:
try {
UserLocalServiceUtil.addUser(creatorUserId,companyId,autoPassword, psw,password2,autoScreenName,u,e,facebookId,openId,locale,n,middleName,c,prefixId,suffixId,male,birthdayMonth,birthdayDay,birthdayYear,jobTitle,groupIds,organizationIds,roleIds,userGroupIds,sendEmail,ServiceContextFactory.getInstance(req));
}
catch (SystemException e2) {
e2.printStackTrace();
}
Hi all,
I have a problem similar to Valerio and I have a question...how can I see if an user is added into database of Liferay? Because I use the same code of Valerio but the user doesn't appear into user table in the control panel.
I have a problem similar to Valerio and I have a question...how can I see if an user is added into database of Liferay? Because I use the same code of Valerio but the user doesn't appear into user table in the control panel.
Please, can help me?
Hi Valerio,
Both the psw and password2 should be of same value .
This is because they are used in password confirmation.
See this :
http://www.liferay.com/community/forums/-/message_boards/message/18015925
- Please make sure both passwords are same.
- Also please check if you are giving a valid screenName.
Thanks,
Siby
Both the psw and password2 should be of same value .
This is because they are used in password confirmation.
See this :
http://www.liferay.com/community/forums/-/message_boards/message/18015925
- Please make sure both passwords are same.
- Also please check if you are giving a valid screenName.
Thanks,
Siby
Regarding the user table, is there a way to see if a user is in the database of liferay? And a way to make him appear in the user table in control panel-->user and organization? Because i use the same code but user don't appear in the table
I have insert same psw but the answer is the same: Your request failed to complete
What I have to do?
What I have to do?
Hi Valerio/Matt
Hope you checked the screenName doesnt exist already in the DB.
The best way is to put breakpoints in your code and debug..
Thanks,
Siby
Hope you checked the screenName doesnt exist already in the DB.
The best way is to put breakpoints in your code and debug..
Thanks,
Siby
I think that I needn't to a debug because this is my code:
If I delete this:
portlet work correctly but obiouvsly don't add user in database.
So I have tried to do this:
portlet work correctly but don't add user in database. Work the same that code before but in this case it would be add a new user but it don't made this
So I tried with try/cath:
The same!
What I have to do? Why user don't is added in database?
ThemeDisplay theme= (ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);
long creatorUserId = theme.getUserId(); // default liferay user
long companyId = theme.getCompanyId(); // default company
boolean autoPassword = true;
boolean autoScreenName = true;
long facebookId = 0;
String openId = "";
Locale locale = theme.getLocale();
String middleName = "";
int prefixId = 0;
int suffixId = 0;
boolean male = true;
int birthdayMonth = 10;
int birthdayDay = 10;
int birthdayYear = 2010;
String jobTitle = "";
long[] groupIds = null;
long[] organizationIds = null;
long[] roleIds = null;
long[] userGroupIds = null;
boolean sendEmail = false;
UserLocalServiceUtil.addUser(creatorUserId,companyId,autoPassword, psw,psw,autoScreenName,u,e,facebookId,openId,locale,n,middleName,c,prefixId,suffixId,male,birthdayMonth,birthdayDay,birthdayYear,jobTitle,groupIds,organizationIds,roleIds,userGroupIds,sendEmail,ServiceContextFactory.getInstance(req));
If I delete this:
UserLocalServiceUtil.addUser(creatorUserId,companyId,autoPassword, psw,psw,autoScreenName,u,e,facebookId,openId,locale,n,middleName,c,prefixId,suffixId,male,birthdayMonth,birthdayDay,birthdayYear,jobTitle,groupIds,organizationIds,roleIds,userGroupIds,sendEmail,ServiceContextFactory.getInstance(req));
portlet work correctly but obiouvsly don't add user in database.
So I have tried to do this:
long id=CounterLocalServiceUtil.increment();
User utente=UserLocalServiceUtil.createUser(id);
utente.setFirstName(n);
utente.setLastName(c);
utente.setScreenName(u);
utente.setPassword(psw);
utente.setEmailAddress(e);
UserLocalServiceUtil.addUser(utente);
portlet work correctly but don't add user in database. Work the same that code before but in this case it would be add a new user but it don't made this
So I tried with try/cath:
long id=CounterLocalServiceUtil.increment();
User utente=UserLocalServiceUtil.createUser(id);
utente.setFirstName(n);
utente.setLastName(c);
utente.setScreenName(u);
utente.setPassword(psw);
utente.setEmailAddress(e);
try {
UserLocalServiceUtil.addUser(utente);
}
catch (SystemException e2) {
e2.printStackTrace();
}
The same!
What I have to do? Why user don't is added in database?
Hi Valerio,
Just wanted to know if you are giving valid values as parameter..as it can fail inside the UserLocalServiceImpl validation.
Debugging is your best bet.
Thanks,
Siby
Just wanted to know if you are giving valid values as parameter..as it can fail inside the UserLocalServiceImpl validation.
Debugging is your best bet.
Thanks,
Siby
Ok now I try.
Before I have tried another thing:
After try/cath
Because I wanted to see if db was written and is only a visual problem. But if I have this row of code portlet said me: "Your request failed to complete"
So I think that there are some problem with UserLocalServiceUtil
Before I have tried another thing:
System.out.println(UserLocalServiceUtil.getUserById(id));
After try/cath
Because I wanted to see if db was written and is only a visual problem. But if I have this row of code portlet said me: "Your request failed to complete"
So I think that there are some problem with UserLocalServiceUtil
I possible do a query to user_ table of liferay to control if an user is added to database? How can do this?
Up. Please I have very much problems