Forums de discussion
call liferay's portrait update from custom portlet
juan meza, modifié il y a 8 années.
call liferay's portrait update from custom portlet
Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
hi, i have liferay 6.2 GA4 and i have a question
i want to use liferay's user portrait change, but i dont want to copy all the code to my portlet...
is there a way to call liferay's portrait update from my portlet? just like in a render URL or something like that... call the edit_user_portrait struts action from liferay's my account portlet, and then let liferay do everything else... update the image, show errors, etc...
using this for example: (this is the code in liferay's my account portlet, to call the pop up that updates the portrait)
i want something like this, but this is not working... where i tell the portlet name (users admin in this case) where the struts action lives... and let liferay handle the rest..
for this i imported the <%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
this code gives me a permissions error:
but i doesnt send any error in the log..
how can i make this work? what im i missing?
thank you!!
i want to use liferay's user portrait change, but i dont want to copy all the code to my portlet...
is there a way to call liferay's portrait update from my portlet? just like in a render URL or something like that... call the edit_user_portrait struts action from liferay's my account portlet, and then let liferay do everything else... update the image, show errors, etc...
using this for example: (this is the code in liferay's my account portlet, to call the pop up that updates the portrait)
<portlet:renderurl var="editUserPortraitURL" windowstate="<%= LiferayWindowState.POP_UP.toString() %>">
<portlet:param name="struts_action" value="/users_admin/edit_user_portrait" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(selUser.getUserId()) %>" />
<portlet:param name="portrait_id" value="<%= String.valueOf(selUser.getPortraitId()) %>" />
</portlet:renderurl>
i want something like this, but this is not working... where i tell the portlet name (users admin in this case) where the struts action lives... and let liferay handle the rest..
<liferay-portlet:renderurl portletname="<%=PortletKeys.USERS_ADMIN %>" var="editUserPortraitURL" windowstate="<%= LiferayWindowState.POP_UP.toString() %>">
<portlet:param name="struts_action" value="/users_admin/edit_user_portrait" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(selUser.getUserId()) %>" />
<portlet:param name="portrait_id" value="<%= String.valueOf(selUser.getPortraitId()) %>" />
</liferay-portlet:renderurl>
for this i imported the <%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
this code gives me a permissions error:
You do not have the roles required to access this portlet.
but i doesnt send any error in the log..
how can i make this work? what im i missing?
thank you!!
juan meza, modifié il y a 8 années.
RE: call liferay's portrait update from custom portlet (Réponse)
Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
solved!
ill leave the code here in case anyone needs if, or for future references
what i ended up doing, is to use the url liferay generates when changing the portrait in my account
ill leave the code here in case anyone needs if, or for future references
what i ended up doing, is to use the url liferay generates when changing the portrait in my account
<%
String editPortraitUrl = themeDisplay.getPortalURL()+"/group/control_panel/manage?p_p_id=2&p_p_lifecycle=0&p_p_state=pop_up&p_p_mode=view&_2_portrait_id=0&_2_p_u_i_d="+themeDisplay.getUserId()+"&_2_struts_action=%2Fmy_account%2Fedit_user_portrait";
%>
<liferay-ui:logo-selector currentLogoURL="<%= selUser.getPortraitURL(themeDisplay) %>" defaultLogoURL="<%= UserConstants.getPortraitURL(themeDisplay.getPathImage(), selUser.isMale(), 0) %>" editLogoURL="<%=editPortraitUrl %>" imageId="<%= selUser.getPortraitId() %>" logoDisplaySelector=".user-logo" />
Guillaume Lenoir, modifié il y a 7 années.
RE: call liferay's portrait update from custom portlet
New Member Publications: 5 Date d'inscription: 14/07/12 Publications récentes
hi
Try this =>
JSP
Javascript
Try this =>
JSP
<liferay-portlet:renderurl refererplid="<%= themeDisplay.getPlid() %>" plid="<%= PortalUtil.getControlPanelPlid(renderRequest) %>" portletname="<%= PortletKeys.MY_ACCOUNT %>" var="editUserPortraitURL" windowstate="<%= LiferayWindowState.POP_UP.toString() %>">
<portlet:param name="struts_action" value="/my_account/edit_user_portrait" />
<portlet:param name="redirect" value="<%= PortalUtil.getCurrentURL(request) %>" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(user.getUserId()) %>" />
<portlet:param name="portrait_id" value="<%= String.valueOf(user.getPortraitId()) %>" />
</liferay-portlet:renderurl>
<liferay-ui:logo-selector currentLogoURL="<%=user.getPortraitURL(themeDisplay) %>" defaultLogoURL="<%=UserConstants.getPortraitURL(themeDisplay.getPathImage(), user.isMale(), 0) %>" editLogoURL="<%= editUserPortraitURL %>" showBackground="true" imageId="<%=user.getPortraitId() %>" logoDisplaySelector=".user-logo" />
Javascript
function _<%= PortletKeys.MY_ACCOUNT %>_changeLogo(url){
<portlet:namespace />changeLogo(url);
}