Fórum

Discussion's notification contains incorrect contentURL

旻 吴, modificado 1 Mês atrás.

Discussion's notification contains incorrect contentURL

Junior Member Postagens: 56 Data de Entrada: 17/05/17 Postagens Recentes
Hello everyone. I am using liferay-ui:discussion to create a discussion section on my customized model. The liferay's version is 7.0 dxp sp3. I follows the instruction on the page https://dev.liferay.com/zh/develop/tutorials/-/knowledge_base/7-0/adding-updating-and-deleting-assets-for-custom-entities and the code is:

<liferay-ui:panel-container extended="<%= false %>" id="<%= renderResponse.getNamespace()+" customizedmodelcommentspanelcontainer" %>" persistState="&lt;%= true %&gt;"&gt;
	<liferay-ui:panel collapsible="<%= true %>" extended="<%= true %>" persiststate="<%= true %>" title="Comment:">
		
		<portlet:actionurl name="invokeTaglibDiscussion" var="discussionURL" />
		
		<liferay-ui:discussion className="<%= CustomizedModel.class.getName() %>" classPK="<%= customizedModel.getModelId() %>" formAction="<%= discussionURL %>" formName="fm2" ratingsEnabled="true" redirect="<%= currentURL %>" userId="<%= customizedModel.getUserId() %>" />
	</liferay-ui:panel>
</liferay-ui:panel-container>


The code works well in adding, updating, deleting discussions. But there is a strange problem: the users subscribing to the discussion can not be redirected to the view page of the customized model. Liferay gives:

java.lang.IllegalArgumentException: localhost:8080 is not a valid redirect

It can be shown that the redirect parameter of notification link of the message is 'localhost:8080' . By checking the source code one can find that the redirect part is set in MBMessageLocalServiceImpl's notifySubscribers with 'contentURL'. However, by monitoring network status, one can exam that the 'contentURL' parameter during post a new discussion message is currently set.

I am wondering how I could solve this problem. Thank you very much.
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Discussion's notification contains incorrect contentURL

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
旻 吴:
java.lang.IllegalArgumentException: localhost:8080 is not a valid redirect


Hmm, this may actually be a result of your virtual host settings.

Normally I need to tweak things so the generated urls are correct, including setting the http port in portal-ext.properties (when behind an Apache httpd or other web server) and defining the hostname in the instance setting so the default portal urls are actually resolvable from outside of the organization.
旻 吴, modificado 1 Mês atrás.

RE: Discussion's notification contains incorrect contentURL

Junior Member Postagens: 56 Data de Entrada: 17/05/17 Postagens Recentes
Hello David H Nebinger, thanks for your response. I am sorry I didn't mention that the developing server was running locally with default setting. Therefore its hostname and port name should be localhost and 8080.

Indeed, if a user post a comment to one resource, it can be obtained that the 'contentURL' field of the form submitted by liferay-ui:discussion is correct:
contentURL:	http://localhost:8080/web/dc-sales-information/dcb?p_p_id=customized_model_web_display_portlet__INSTANCE_eYwBkJ ........ customziedModelId=71644


But when the subscribers click to open the notification, liferay says:
localhost:8080 is not a valid redirect

due to the redirect parameter of the URL in notification message is set as localhost:8080.
http://localhost:8080/group/control_panel/manage?p_p_id=com_liferay_notifications_web_portlet_NotificationsPortlet&amp;p_p_lifecycle=1&amp;p_p_state=maximized&amp;p_p_mode=view&amp;_com_liferay_notifications_web_portlet_NotificationsPortlet_javax.portlet.action=markNotificationAsRead

&amp;_com_liferay_notifications_web_portlet_NotificationsPortlet_redirect=localhost%3A8080

&amp;_com_liferay_notifications_web_portlet_NotificationsPortlet_userNotificationEventId=1371597&amp;p_auth=glTky1Oj&amp;p_p_auth=VkRBTiTB[code]

 It is expected to be just the same as the link shown above.
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Discussion's notification contains incorrect contentURL

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
旻 吴:
I am sorry I didn't mention that the developing server was running locally with default setting. Therefore its hostname and port name should be localhost and 8080.


Okay, maybe it is not completely clear, but clicking on a notification if the url has localhost:8080 is only going to work actually on the development server.

If you are going to be hitting notifications from outside of the server and expecting folks to be able to click on links to get to some other place on the dev server, you still have to have the virtualhost and port number stuff set up. It still has to be set up as basically you would a production server so links clicked in your email or notification are still valid from an external browser.
旻 吴, modificado 1 Mês atrás.

RE: Discussion's notification contains incorrect contentURL

Junior Member Postagens: 56 Data de Entrada: 17/05/17 Postagens Recentes
Thank you so much for reminding me about this issue. However I'm afraid that it would not be the point because I always access to the server locally.

Actually, if the
formAction="&lt;%dicussionURL%&gt;"

line is removed, notification works quite well, although another problem will occur: liferay-ui:discussion returns No Permission Error