留言板

Users not getting added in my customized user registration

thumbnail
Vikas V,修改在12 年前。

Users not getting added in my customized user registration

Junior Member 帖子: 83 加入日期: 11-9-28 最近的帖子
Hi,

Am customizing user registration as per my requirements and hence I want only 3 (mandatory) fields to be inserted.

Also my UI for registration page is customized (in fact totally different from Liferay's)

When I click on 'Submit' button on my registration page, I am calling below piece of code.

----------------------------- Code starts here ---------------------------------------------------
public void myUserRegistration( emailaddress, password)
throws Exception
{
System.out.println("Control is inside my myUserRegistration");

String emailAddress = emailaddress;
String password1 = password;
System.out.println("Value stored in emailAddress:" +emailAddress);
System.out.println("Value stored in password1:" +password1);
long organizationIds[] = (long[])null;
long groupIds[] = (long[])null;
long roleIds[] = (long[])null;
long userGroupIds[] = (long[])null;
ThemeDisplay themeDisplay = null;
ServiceContext serviceContext = null;
System.out.println("Control is before addUser call");

try{
User user = UserServiceUtil.addUser(Long.parseLong(null), false, password1, "null", false, "null", emailAddress, Long.parseLong(null), "null",themeDisplay.getLocale(), "null", "null", "null", 0, 0, true, 8, 1, 1986, "customer", groupIds, organizationIds, roleIds, userGroupIds, false, serviceContext);
}catch(Exception e){
throw e;
}
System.out.println("Control is after add User call");
}
--------------------------------------- Code ends here ---------------------------------------------------------------------------

Since am not bothered about other fields , I have explicitly initialized with null value or some default values.

When I click on Submit, neither records are getting added to USER_ table nor am getting any exception.

Below is the log stack,

Control is inside my myUserRegistration
Value stored in emailAddress : myemailid@liferay.com
Value stored in password1:test123
Control is before addUser call


Complete code of myUserRegistration has been attached.

Where am I going wrong? Is this the correct way of customizing? If I try to extend CreateAccountAction class , I get an error that it cannot be resolved and .class are missing.

Regards,
thumbnail
Hitoshi Ozawa,修改在12 年前。

RE: Users not getting added in my customized user registration

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
I'm using UserLocalServiceUtil to add users, but I think I had to specify a companyId, which usually is the default instance.
thumbnail
Vikas V,修改在12 年前。

RE: Users not getting added in my customized user registration

Junior Member 帖子: 83 加入日期: 11-9-28 最近的帖子
Thanks Hitoshi emoticon

I tried UserLocalServiceUtil as below,

UserLocalServiceUtil.addUser(company.getCompanyId(), Long.parseLong(null), false, password1, "null", false, "null", emailAddress, Long.parseLong(null), "null",themeDisplay.getLocale(), "null", "null", "null", 0, 0, true, 8, 1, 1986, "customer", groupIds, organizationIds, roleIds, userGroupIds, false, serviceContext);

But am getting Null pointer exceptions..

1) I guess its because in most of the fields am passing null values. Is it so?

2) Is it that I have to pass non null values?

3) As per my requirement I can take only 3 inputs from user (email, password and name). Other details I have to pass null or some default values. How can I overcome this problem?

Thanks in advance!

Best Regards,

Vikas
thumbnail
Hitoshi Ozawa,修改在12 年前。

RE: Users not getting added in my customized user registration

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
To get the exception message, you have to look at the class name instead of the exception message.
System.out the classname to find what your error is. And yes, you do need to enter some non-null values in key fields.
thumbnail
Vikas V,修改在12 年前。

RE: Users not getting added in my customized user registration

Junior Member 帖子: 83 加入日期: 11-9-28 最近的帖子
Thanks Hitoshi,

Am getting null pointer exception here,

java.lang.NullPointerException
at com.liferay.portal.service.impl.UserLocalServiceImpl.addUser(UserLocalServiceImpl.java:402)

Since am customizing user registration and not using Liferay's, am not able to get what values I can set (as default) for below fields or do some configurations in
portal-ext.properties file to set default values
,

1) themeDisplay.getLocale()
2) serviceContext

Other fields have been set to some non null values and I guess am getting null pointer exceptions because am not setting any value to above fields. emoticon

Complete trace of the exception is in the attachment.

Also , for your information I am using Liferay 6

Thanks!!

Regards,
thumbnail
Vikas V,修改在12 年前。

RE: Users not getting added in my customized user registration

Junior Member 帖子: 83 加入日期: 11-9-28 最近的帖子
Hi,

I was able to add users now by providing all non null values.

In the process of achieving the same I came accross couple of exceptions like below,

1) com.liferay.portal.UserScreenNameException

2) com.liferay.portal.UserPasswordException

3) com.liferay.portal.DuplicateUserEmailAddressException

4) com.liferay.portal.ContactFirstNameException

Guess, liferay does a check on the inputs that we enter.

So, can anyone please provide me where these checks are happening (if they are all in same class or through portal.property file) so that I can override them
as per my requirement.

Regards,
thumbnail
Sandeep Nair,修改在12 年前。

RE: Users not getting added in my customized user registration

Liferay Legend 帖子: 1744 加入日期: 08-11-6 最近的帖子
UserLocalServiceImpl class >> validate method

Regards,
Sandeep
thumbnail
Vikas V,修改在12 年前。

RE: Users not getting added in my customized user registration

Junior Member 帖子: 83 加入日期: 11-9-28 最近的帖子
Thanks Sandeep emoticon

Also am using UserLocalServiceUtil.addUser method which has 27 fields !!

I am bothered about storing only 3 fields (user name , password , email id) . So tried passing null values to remaining fields (like Locale , openId and others am not bothered of having them)

But I got null pointer exceptions and my guess is, I have to provide some values to all fields. How can I make Liferay to accept only whatever fields

I provide?

Can it be done through portal-ext.properties?

Regards,
thumbnail
Hitoshi Ozawa,修改在12 年前。

RE: Users not getting added in my customized user registration (答复)

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
Why don't you just extend Liferay's classes to put in default values for other fields in the addUser method.
That way, you won't have to modify Liferay and will be able to still use all of Liferay's functionalities.
That's what I've done in my version.
thumbnail
Vikas V,修改在12 年前。

RE: Users not getting added in my customized user registration

Junior Member 帖子: 83 加入日期: 11-9-28 最近的帖子
Hi Hitoshi,

Initially when I started working on User Registration I had extended CreateAcountAction.

But, was getting exception which is reported here https://bugs.eclipse.org/bugs/show_bug.cgi?id=280469

So, had to follow above approach. Anyways felt that what you are saying is right and will go accordingly by fixing above exception.

Thanks!

Regards,