Foren

Portlet for adding custom users

Charaf faceofjock, geändert vor 11 Jahren.

Portlet for adding custom users

Junior Member Beiträge: 30 Beitrittsdatum: 08.04.13 Neueste Beiträge
Hi ,
I would like to create some portlets for adding users with some custom fields , i saw this article here but i don't know if it's good or not , and if it's the best solution for liferay 6.1.

I have lunched a discussion before here but no answers.

Please help and thanks in advance
thumbnail
Archi Madhu, geändert vor 11 Jahren.

RE: Portlet for adding custom users

Regular Member Beiträge: 237 Beitrittsdatum: 25.03.08 Neueste Beiträge
Hello,

I think expando is good option for custom fields.

If we think about exporting custom user information from Liferay in future, if we create custom tables, we have to write our own logic to fetch out custom fields information.

Also, if we go for custom tables, we have to write lot of code for service builders and have to update the OOTB code to do CRUD operations while some one is saving user information, which is not a good practice and gives pain during upgrades.

As per me expando is good option and one should go for it.

HTH!

- Archi
Charaf faceofjock, geändert vor 11 Jahren.

RE: Portlet for adding custom users

Junior Member Beiträge: 30 Beitrittsdatum: 08.04.13 Neueste Beiträge
With this , could i add differente portlets that include different forms according to which type of user i like to add ?
Have you some tutorials or good examples ?
thumbnail
Apoorva Prakash, geändert vor 11 Jahren.

RE: Portlet for adding custom users

Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste Beiträge
Charaf faceofjock:
Hi ,
I would like to create some portlets for adding users with some custom fields , i saw this article here but i don't know if it's good or not , and if it's the best solution for liferay 6.1.

I have lunched a discussion before here but no answers.

Please help and thanks in advance


Hello Charaf,

Following is some rough code.

Adding New user

toReturnUser = UserLocalServiceUtil.addUser(0,getCompanyId(request), false, pswd, pswd, true,
						StringPool.BLANK, getUserEmailId(request), 0,
						StringPool.BLANK, getLocale(request),
						getUserFirstName(request), StringPool.BLANK,
						getUserLastName(request), 0, 0, true, 1, 1, 2000,
						StringPool.BLANK, null, null, null, null, false,
						ServiceContextFactory.getInstance(ServiceContext.class.getName(), request));


Saving Value in Expando:

ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getTable(getCompanyId(request), User.class.getName(), "expandoTableName");
if(expandoTable ==null){
expandoTable  = ExpandoTableLocalServiceUtil.addTable(getCompanyId(request), User.class.getName(), "expandoTableName");
}

ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), "columnName");
if (null == column) {
				column = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), "columnName", ExpandoColumnConstants.STRING);
}

ExpandoValue expandoValue = ExpandoValueLocalServiceUtil.addValue(themeDisplay.getCompanyId(), User.class.getName(), "expandoTableName", "columnName", groupId, "value to be saved");


HTH...

Thanks and Regards,
Apoorva Prakash
Charaf faceofjock, geändert vor 11 Jahren.

RE: Portlet for adding custom users

Junior Member Beiträge: 30 Beitrittsdatum: 08.04.13 Neueste Beiträge
Is expando the best Way to this task cause i'm trying to learn how to use service builder to add my addUser function with special fields
thumbnail
Apoorva Prakash, geändert vor 11 Jahren.

RE: Portlet for adding custom users

Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste Beiträge
Charaf faceofjock:
Is expando the best Way to this task cause i'm trying to learn how to use service builder to add my addUser function with special fields


Its always a good idea to use expando in case you want to add some custom fields with liferay existing entities.
thumbnail
Itishree Parida, geändert vor 10 Jahren.

RE: Portlet for adding custom users

New Member Beiträge: 8 Beitrittsdatum: 09.11.11 Neueste Beiträge
expando is the quick way to add special fields but use of service builder is more preferred .emoticon
master slave, geändert vor 10 Jahren.

RE: Portlet for adding custom users

Junior Member Beiträge: 30 Beitrittsdatum: 08.04.13 Neueste Beiträge
yes this is what i did
thumbnail
nitin kumar sharma, geändert vor 9 Jahren.

RE: Portlet for adding custom users

New Member Beiträge: 12 Beitrittsdatum: 26.04.13 Neueste Beiträge
Hi Apoorva Prakash,

Thank you so much for sharing point to point solutions.