Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Raja Seth
Delete profile image in custom portlet
24 de abril de 2013 7:04
Respuesta

Raja Seth

Ranking: Regular Member

Mensajes: 217

Fecha de incorporación: 18 de agosto de 2011

Mensajes recientes

Hi All,

In my project I am developing user account portlet, somewhat similar to My Account in Liferay control panel. I have used image upload functionality using the below taglib :

<liferay-ui:logo-selector
defaultLogoURL="/my-new-theme/images/img_comment_user.png"
editLogoURL="${editPortraitURL}"
imageId="<%= userProfile.getPortraitId() %>"
logoDisplaySelector=".user-logo"
showBackground="<%= false %>" />


When I uploads the image, it gets uploaded and saved for the user logged in. But for deleting the image, as from control panel we need to save our modifications, similar kind of functionality I want to use on save.

Please let me know if anyone have developed the same thing in custom portlet.

Any help would be appreciated.

Thanks,
Raja
Apoorva Prakash
RE: Delete profile image in custom portlet
25 de abril de 2013 5:37
Respuesta

Apoorva Prakash

Ranking: Liferay Master

Mensajes: 659

Fecha de incorporación: 15 de junio de 2010

Mensajes recientes

Raja Seth:
Hi All,

In my project I am developing user account portlet, somewhat similar to My Account in Liferay control panel. I have used image upload functionality using the below taglib :

<liferay-ui:logo-selector
defaultLogoURL="/my-new-theme/images/img_comment_user.png"
editLogoURL="${editPortraitURL}"
imageId="<%= userProfile.getPortraitId() %>"
logoDisplaySelector=".user-logo"
showBackground="<%= false %>" />


When I uploads the image, it gets uploaded and saved for the user logged in. But for deleting the image, as from control panel we need to save our modifications, similar kind of functionality I want to use on save.

Please let me know if anyone have developed the same thing in custom portlet.

Any help would be appreciated.

Thanks,
Raja


Hello Raja,

Method is already available in API, see the following:

1com.liferay.portal.service.UserLocalServiceUtil.deletePortrait(userId)


HTH.

Thanks and Regards,
Apooorva Prakash
Raja Seth
RE: Delete profile image in custom portlet
26 de abril de 2013 7:39
Respuesta

Raja Seth

Ranking: Regular Member

Mensajes: 217

Fecha de incorporación: 18 de agosto de 2011

Mensajes recientes

Hi Apoorva,

Thanks for your reply. Yes I am aware about this method, but using liferay taglib, I am not able to delete it.

Also, using this method only entry from USER table gets removed not from IMAGE table. But if you check the flow from control panel, it removes from both the places. Correct me if I am wrong!

Please let me know how we can delete the image from taglib.

Thanks,
Raja
Chintan Akhani
RE: Delete profile image in custom portlet
26 de abril de 2013 7:46
Respuesta

Chintan Akhani

Ranking: Regular Member

Mensajes: 111

Fecha de incorporación: 13 de marzo de 2008

Mensajes recientes

Hi Raja,

"deletePortrait(long userId)" this method will take care of image deletion from Image gallery as well. If you check the implementation of this method in UserLocalServiceImpl than you will find two calls, one is for 'update user' and another one is 'delete image'. So this method should work for you. Please check your logs as well.

Thanks,
Chintan
Raja Seth
RE: Delete profile image in custom portlet
2 de mayo de 2013 5:11
Respuesta

Raja Seth

Ranking: Regular Member

Mensajes: 217

Fecha de incorporación: 18 de agosto de 2011

Mensajes recientes

Hi Chintan,

Thanks for your reply. I used this method in my controller :

boolean deleteLogo = ParamUtil.getBoolean(request, "deleteLogo");
if (deleteLogo) {
UserServiceUtil.deletePortrait(user.getUserId());
}


But something strange is happening. When I delete and click on save button from my custom portlet, my profile image is replaced by the liferay logo image. I debugged and found out, My Account in Liferay control panel also calls the same method. Also when I looked into the database, the call from my custom portlet only removes the entry from IMAGE_ table, but doesn't reset's the PORTRAITID in USER_ table. Because of which its displaying the liferay logo image.

Please help me out.

Thanks,
Raja