Foros de discusión

Portlet for adding custom users

Charaf faceofjock, modificado hace 11 años.

Portlet for adding custom users

Junior Member Mensajes: 30 Fecha de incorporación: 8/04/13 Mensajes recientes
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, modificado hace 11 años.

RE: Portlet for adding custom users

Regular Member Mensajes: 237 Fecha de incorporación: 25/03/08 Mensajes recientes
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, modificado hace 11 años.

RE: Portlet for adding custom users

Junior Member Mensajes: 30 Fecha de incorporación: 8/04/13 Mensajes recientes
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, modificado hace 11 años.

RE: Portlet for adding custom users

Liferay Master Mensajes: 658 Fecha de incorporación: 15/06/10 Mensajes recientes
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, modificado hace 11 años.

RE: Portlet for adding custom users

Junior Member Mensajes: 30 Fecha de incorporación: 8/04/13 Mensajes recientes
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, modificado hace 11 años.

RE: Portlet for adding custom users

Liferay Master Mensajes: 658 Fecha de incorporación: 15/06/10 Mensajes recientes
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, modificado hace 10 años.

RE: Portlet for adding custom users

New Member Mensajes: 8 Fecha de incorporación: 9/11/11 Mensajes recientes
expando is the quick way to add special fields but use of service builder is more preferred .emoticon
master slave, modificado hace 10 años.

RE: Portlet for adding custom users

Junior Member Mensajes: 30 Fecha de incorporación: 8/04/13 Mensajes recientes
yes this is what i did
thumbnail
nitin kumar sharma, modificado hace 9 años.

RE: Portlet for adding custom users

New Member Mensajes: 12 Fecha de incorporación: 26/04/13 Mensajes recientes
Hi Apoorva Prakash,

Thank you so much for sharing point to point solutions.