Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay 7.2 - Set attribute on javascript
Hi,
I have a custom portlet with another portlet embedded:
What this is producing is: a simple select with 3 options, and when the user selects an option, the javascript is called and the embedded portlet is refreshed with the value of the selected option. Now, I want to get this value on my doView method of the refreshed portlet (Importer_INSTANCE_TEST). How should I do this?
I have a custom portlet with another portlet embedded:
<%@ include file="/init.jsp" %>
<aui:select name="testId">
<aui:option value="100">Test 100</aui:option>
<aui:option value="200">Test 200</aui:option>
<aui:option value="300">Test 300</aui:option>
</aui:select>
<liferay-portlet:runtime portletName="Importer_INSTANCE_TEST" />
<aui:script>
AUI().ready('aui-dialog', 'node' , function(A) {
A.one("#<portlet:namespace />testId").on('change', function(e) {
var data = {'param1': this.val()};
Liferay.Portlet.refresh('#p_p_id_Importer_INSTANCE_TEST_', data);
});
});
</aui:script>
What this is producing is: a simple select with 3 options, and when the user selects an option, the javascript is called and the embedded portlet is refreshed with the value of the selected option. Now, I want to get this value on my doView method of the refreshed portlet (Importer_INSTANCE_TEST). How should I do this?
It seems that I can get the value on my doView method if I so something like this:
But doing like this I get the following WARN:
EDIT:
Ok, seems that doing like this, I can get the value without the warning:
Still not sure if this is the correct way to do this...
UploadPortletRequest test = PortalUtil.getUploadPortletRequest(renderRequest);
System.out.println(test.getParameter("param1"));
But doing like this I get the following WARN:
WARN [http-nio-8080-exec-10][UploadServletRequestImpl:242] Unable to parse upload request: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null
EDIT:
Ok, seems that doing like this, I can get the value without the warning:
HttpServletRequest test = PortalUtil.getHttpServletRequest(renderRequest);
test = PortalUtil.getOriginalServletRequest(test);
System.out.println(test.getParameter("param1"));
Still not sure if this is the correct way to do this...
Hi,
You can get the parameter in doView either in two ways
1. set attribute with prefix portlet namespace
You can get the parameter in doView either in two ways
1. set attribute with prefix portlet namespace
var data = {'<portlet:namespace />param1': value};
then you can fetch usingParamUtil.getString(renderRequest, "param1");
2. Without setting namespace you can fetch directly using HttpServletRequest var data = {'param1': value};
PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest)).getParameter("param1")
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™