Forums de discussion

currentURL in edit portrait url

juan meza, modifié il y a 8 années.

currentURL in edit portrait url

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
hi, i have liferay 6.2 GA4

im trying to copy the edit portrait code from my account portlet..
i found the code, i just have 1 issue...

when the editUserPortraitURL is declared
<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>


the current URL, i dont know what value that variable has, and i cant find it in the source code...
i tried setting my current url, from my custom portlet... but when it opens the pop up to change the portrait, it shows the view page of the portlet...

anyone knows what i should put there? in currentURL redirect parameter?
my guess is the URL of the edit part of the portlet (where this code is).. but themeDisplay.getURLCurrent() does not seem to give me that

thank you!
thumbnail
Amos Fong, modifié il y a 8 années.

RE: currentURL in edit portrait url (Réponse)

Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
currentURL's declaration is in portal-web/docroot/html/portlet/init.jsp

From that jsp, it's defined with:
PortletURL currentURLObj = PortletURLUtil.getCurrent(liferayPortletRequest, liferayPortletResponse);

String currentURL = currentURLObj.toString();


The redirect parameter is the URL you want to user to go to after submitting the action. Using currentURL is to redirect the user to the current page after he submits the form.
juan meza, modifié il y a 8 années.

RE: currentURL in edit portrait url

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
thank you!

i have a new question maybe you can help me? pls

i copied the edit_user_portrait.jsp to my portlet...
and in the renderURL tag, i pass my page as parameter... like this:
<portlet:param name="mvcPath" value="/html/perfil/edit_user_portrait.jsp" />

i removed the struts_action to add this one...

this works fine, and it opens the pop up to update the portrait, but the problem comes here...
when i add a new photo, it doesnt render in the logoEditor.. it shows a broken image image... how can i make this work?

thank you!
thumbnail
Amos Fong, modifié il y a 8 années.

RE: currentURL in edit portrait url

Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
I'm not sure, but my guess would be the uploadURL and previewURL in Liferay.LogoEditor. It may be throwing a permission error if the user is trying to invoke those struts actions but that portlet isn't on the page.
juan meza, modifié il y a 8 années.

RE: currentURL in edit portrait url

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
you are right the LogoEditor invokes the /users_admin/edit_user_portrait struts action...
do you have an idea about how to make this work?

thank you!
thumbnail
Amos Fong, modifié il y a 8 années.

RE: currentURL in edit portrait url

Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
Depends on what you are trying to do. Are you going to handle the whole portrait thing yourself (like storing/serving it yourself)? or do you just want to replicate that functionality in your portlet?

If you're just replicating the functionality, I think you'll have to either copy the edituserportraitaction.java code as well or use reflection to invoke it from your plugin. Both options aren't that clean but I'd probably go with creating your own actions and then copy the backend code.
juan meza, modifié il y a 8 années.

RE: currentURL in edit portrait url

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
hi Amos!

yes you are right, im trying to replicate the edit portrait image from my account...
i did as you said about copying the java code of the edituserportraitaction but i have an issue...

my portlet is a spring portlet (the liferay default) and the <portlet:resourceURL> asks for a parameter, with a struts_action in it...
i can deal with the <portlet:actionURL> because you just put the name of the method in the name...
but what can i do about the resourceURL?

can you help me?

thank you!!
thumbnail
Amos Fong, modifié il y a 8 années.

RE: currentURL in edit portrait url

Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
juan meza, modifié il y a 8 années.

RE: currentURL in edit portrait url

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
it did help, but its still not working... it does'nt give me any errors.. but the image preview keeps showing a broken image...

is there a way to just call liferay's portrait update from my portlet? just like in a render URL or something like that... call the edit_user_portrait from liferay's my account portlet, and then let liferay do everything else... update the image, show errors, etc...

do you know if i can achieve this, and how?

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>


but letting the renderURL know that it has to look in liferay's my account portlet, instead of my custom portlet

that would be great!

thank you!
juan meza, modifié il y a 8 années.

RE: currentURL in edit portrait url

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
solved it...

if anyone wants to know how... go here:
https://www.liferay.com/es/community/forums/-/message_boards/message/57413369

what i did is to use the url liferay generates, when changing the user portrait...
Karan kapoor, modifié il y a 7 années.

RE: currentURL in edit portrait url

New Member Publications: 5 Date d'inscription: 02/07/16 Publications récentes
Hallo,

I tried this method but however I am always getting this error :

11:00:33,939 ERROR [RuntimePageImpl-9][render_portlet_jsp:132] null
org.springframework.web.portlet.NoHandlerFoundException: No handler found for portlet request: mode 'view', phase 'RENDER_PHASE', parameters map[[empty]]


Tried a few fixes but nothing worked.

Would be great if someone could help.
juan meza, modifié il y a 7 années.

RE: currentURL in edit portrait url

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
i could never do it copying the code (the method i was trying in this post).. .in the end i just generated the same url liferay generates... in the post mentioned in my last comment..

is that the one that gives you an error?
Karan kapoor, modifié il y a 7 années.

RE: currentURL in edit portrait url

New Member Publications: 5 Date d'inscription: 02/07/16 Publications récentes
Hallo Juan.

Thanks for the reply, appreciate it. I am trying it in Liferay 6.2 and 7, both but nothing positive in any of them.
Someone said that this approach does not work in Liferay 7 since in Liferay 7 all functions and services are separate OSGI modules.

This is my view.jsp :

portlet:renderURL var="editUserPortraitURL" windowState="<%= LiferayWindowState.POP_UP.toString() %>">
<portlet:param name="jsppage" value="/users_admin/edit_user_portrait" />
<portlet:param name="redirect" value="/html/WEB-INF/actionurlbyportlettag/view.jsp" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(selUser.getUserId()) %>" />
<portlet:param name="portrait_id" value="<%= String.valueOf(selUser.getPortraitId()) %>" />
</portlet:renderURL>

was not sure how to have the following edited in it, due to UTF-8 formatting and didn't know what was "UserConstants" in the following:

<%
String editPortraitUrl = themeDisplay.getPortalURL()+"/group/control_panel/manage?p_p_id=2&p_p_lifecy‌​cle=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"/>

If possible, could you forward me the code that you used eventually to have it working i.e. view.jsp and .Java file. I would really appreciate it, since I have gone through a tonne of approaches but nothing got me success and I am running short of time.

Look forward to hearing from you.
juan meza, modifié il y a 7 années.

RE: currentURL in edit portrait url

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
Hi, sure.. sorry for late response...
as i told you, i just copied the URL generated by liferay, and added the parameters it needed
<div>
						<c:if test="<%= selUser != null %>">
							<c:choose>
								<c:when test="<%= UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, &quot;portrait&quot;) %>">
					 				&lt;%
					 				String editPortraitUrl = themeDisplay.getPortalURL()+"/group/control_panel/manage?p_p_id=2&amp;p_p_lifecycle=0&amp;p_p_state=pop_up&amp;p_p_mode=view&amp;_2_portrait_id=0&amp;_2_p_u_i_d="+themeDisplay.getUserId()+"&amp;_2_struts_action=%2Fmy_account%2Fedit_user_portrait";
					 				%&gt;
									<liferay-ui:logo-selector currentLogoURL="<%= selUser.getPortraitURL(themeDisplay) %>" defaultLogoURL="<%= UserConstants.getPortraitURL(themeDisplay.getPathImage(), selUser.isMale(), 0) %>" editLogoURL="<%=editPortraitUrl %>" imageId="<%= selUser.getPortraitId() %>" logoDisplaySelector=".user-logo" />
									
								</c:when>
								<c:otherwise>
									<img alt="<liferay-ui:message key=" portrait">" src="&lt;%= selUser.getPortraitURL(themeDisplay) %&gt;" /&gt;
								</c:otherwise>
							</c:choose>
						</c:if>
					</div>


what i did is this, hope it helps