Forums de discussion

How to access hidden field of one portlet in other portlets

Abutalib Shaikh, modifié il y a 7 années.

How to access hidden field of one portlet in other portlets

Junior Member Publications: 36 Date d'inscription: 17/05/16 Publications récentes
Hello all,

I am facing problem and confuse how to achieve my requirement.

- i have one portlet name is navigation portlet
contains "product" drop down list
- when user select any product i will put that product value in hidden field by using Javascript as like below
- <aui:input type="hidden" name="txt" value= "selected_product ">
- and refreshing other portlets by using
Liferay.Portlet.refresh('#p_p_id_myportletmyreferrals_WAR_profilemanagementportlet_ ');

but other hand on same page having 3 other portlets
- content of that portlet is based on that user selected product
- so how to access that hidden field value (selected product ) in other portlet render phase ?

or there is any another way's to achieve this type of scenario ?

please suggest me solution for the same

thank you in advance !!! emoticon
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: How to access hidden field of one portlet in other portlets

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Telling the portal to refresh the page is bad form, it means a full page refresh on each selection and honestly that is not what users are going to be looking for.

You have a couple of options for sharing the value. First, from the JS perspective, it is all just one document. So JS can access any form, any field, anything you want as long as you code it correctly. The trick is getting around the namespacing, but that can be handled by adding a class to the field so JS can find everything to update using a simple selector.

On the backend, the portal offers ways to share the data. The portlet 2 spec has the event mechanism to notify other portlets. Liferay has the concept of "shared" parameters if you configure it correctly.
Abutalib Shaikh, modifié il y a 7 années.

RE: How to access hidden field of one portlet in other portlets

Junior Member Publications: 36 Date d'inscription: 17/05/16 Publications récentes
thank's David
your reply always helping me ,

by using
- Liferay.Portlet.refresh('#p_p_id_myportlerID');
its not refresh whole page (all portlets on this page) . it refresh only that particular portlet as we passing as parameter to the function.
- correct me if something is wrong ... emoticon

i think on your mentioned point's and make one demo for the same but ,
- i have some findings as follows :

- if we are go with IPC Event mechanism so our workflow like as follow.
1. when user select "product" from drop down list (i.e. from Navigation portlet)
- Navigation portlet Producer which is responsible to produce event

code looks like :
public class navigationEventGeneratorPortlet extends MVCPortlet{
      @ProcessAction(name="processEvent")
    public void process(ActionRequest request, ActionResponse response) {
        String sampleText = ParamUtil.getString(request, "prodcut","");
        QName qName = new QName("http://proliferay.com/events", "ipc-text");
        response.setEvent(qName, prodcut);
    }
}


NOTE : but thing is that we write this code in "navigation" portlet action method means after execution of this action method
- rest of the portlet render method is called as per liferay JSR 286 lifecycle (refresh the all portlets on this page).

can we put event parameter through AJAX call so other portlets render phase never call after serveResource () method ? :
ResourceResponse resourceResponse
resourceResponse.setEvent(qName, prodcut);


2. there is another portlet "product info" which is Receiver its automatically call when some event is perform by producer
- and showing content as per "selected" product
- it's working for me when i use IPC event mechanism.

- in short i wanted to put "selected product " in share parameter but not through "action" method / phase

- so please suggest me any way for the same.....
thumbnail
David H Nebinger, modifié il y a 7 années.

RE: How to access hidden field of one portlet in other portlets

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
In that case I'd pursue the Liferay.on() and Liferay.fire() mechanism for in-browser JS IPC. The receiver would receive the JS message when the value changes and can update itself.