Search code examples
pluginsliferay-6portlet

Liferay search in several portlets


The user will see 4 portlets: 1. Custom Github portlet where it is possible to see different commits from an user in the repository 2. Custom jira portlet which shows tasks from a User 3. NAS server with documents ordered by users 4. Another database with documents ordered by users

I want a "Main search field" where it is possible to enter a username and update all the portlets from this search.

Is this possible? If yes, how could this be done?

Good tutorials for custom portlets in general would be nice


Solution

  • The best way for do this, is "Public render parameters", and it is easy.

    This is a example:

     <?xml version="1.0"?>
     <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
         version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
         <portlet>
             <portlet-name>P1</portlet-name>
             <display-name>P1</display-name>
             <portlet-class>PortletClass1</portlet-class>
                ...
            <security-role-ref>
                <role-name>administrator</role-name>
            </security-role-ref>
                ...
            <supported-public-render-parameter>param1</supported-public-render-parameter>
        </portlet>
        <portlet>
             <portlet-name>P2</portlet-name>
             <display-name>P2</display-name>
             <portlet-class>PortletClass2</portlet-class>
                ...
            <security-role-ref>
                <role-name>administrator</role-name>
            </security-role-ref>
                ...
            <supported-public-render-parameter>param2</supported-public-render-parameter>
        </portlet>
        ...
        <public-render-parameter>
            <identifier>param1</identifier>
            <qname xmlns:x="http://www.liferay.com/public-render-parameters">x:param1</qname>
        </public-render-parameter>
        <public-render-parameter>
            <identifier>param2</identifier>
            <qname xmlns:x="http://www.liferay.com/public-render-parameters">x:param2</qname>
        </public-render-parameter>
    </portlet-app>
    

    At the example, Portlet P1 can modify the parameter "param1" and P2 can modify the parameter "param2", when one of these portlets modify his parameter other portlets can read this param like normal param:

    request.getParameter(“param1”);