Priya Pratheep
Priya Pratheep

Reputation: 43

Pass parameters from javascript liferay

Using IPC I am calling another portlet

My problem is I want to pass the value from hidden field.

But if I assign jsp scriplets

<%! public String projectid= "300015"; %>`

<portlet:param name="projectid" value="<%= projectid%>" />

it is working fine.

But I need to pass the value from the hidden field:

<input type="text" name="hiddenprojectidBox" id="hiddenprojectidBox">

at the place <%= projectid%>

Problem solved. It may help others. No need of hidden fields

var portletURL = new Liferay.PortletURL('ACTION_PHASE');
            portletURL.setWindowState("maximized");
            portletURL.setPortletId("apseprojectmgmtportlet_WAR_apseprojectmgmtportlet")
            portletURL.setParameter("_spage", "/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2");
            portletURL.setPortletMode('view');
            portletURL.setParameter("projectid", projectid);
            portletURL.setParameter("limit", 10); 
            portletURL.setParameter("offset", 0);
            document.getElementById('myForm').action =portletURL.toString();
            document.getElementById('myForm').submit();

Upvotes: 0

Views: 2277

Answers (1)

Pritesh Shah
Pritesh Shah

Reputation: 887

If you are using IPC using liferay javascript api then below code could help you,

Calling portlet javascript,

Liferay.fire('UPDATE_PROJECT', {
   projectId : A.one('<portlet:namespace />hiddenprojectidBox'),
});

Receiving portlet javascript

Liferay.on('UPDATE_PROJECT', function(data) {   
   // When event is being executed, getState of the selected countryCode via ajax call     using resourceURL   
   //data.projectId will give the value of the project id passed from calling portlet
} ); 

Upvotes: 0

Related Questions