Foren

IPC between theme and page

thumbnail
Olivier ROMAND, geändert vor 12 Jahren.

IPC between theme and page

New Member Beiträge: 24 Beitrittsdatum: 07.01.12 Neueste Beiträge
Hey people,

Is it possible to make IPC between a portlet instanciated in a theme and a portlet embedded in a page ?
My need is to have an input field for quick search that would then use the facilities of my advanced search logic to then display the result.

It looks like my porlet doesn't receive the event unless they are both embedded in the same page.

Any hints ?
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: IPC between theme and page

Liferay Legend Beiträge: 14917 Beitrittsdatum: 02.09.06 Neueste Beiträge
Anything that requires input processing should be handled by a portlet. So it sounds like you need 2 portlets, one embedded in the theme to handle the input field, and the other tied to the search results.
thumbnail
Olivier ROMAND, geändert vor 12 Jahren.

RE: IPC between theme and page

New Member Beiträge: 24 Beitrittsdatum: 07.01.12 Neueste Beiträge
Hey David,

Thanks for your return.

I actually have 2 portlets.

The first one is instanciated from the theme:


#set ($VOID = $velocityPortletPreferences.setValue('portlet-setup-show-borders', 'false'))
$taglibLiferay.runtime("CustomSearch_WAR_gedportlet", '', $velocityPortletPreferences.toString())
#set ($VOID = $velocityPortletPreferences.reset())


The view of the portlet is as follow:


		<h:form styleclass="quickSearchBox">
			<span></span>
			
			<aui:fieldset>
				<h:inputtext value="Keywords" size="25" />
				<h:commandbutton image="${themeDisplay.pathThemeImage}/images/search.png" type="submit" value="none" action="#{quickSearchBackingBeanController.quickSearchSubmitAction}" actionListener="#{quickSearchBackingBeanController.publishIPCEvent}" />
			</aui:fieldset>
		</h:form>



Then the code of the publishing event is as follow :


public void publishIPCEvent(ActionEvent event){  
			 Object response = FacesContext.getCurrentInstance().getExternalContext().getResponse();  
			  
			 logger.info("!!!! PUBLISHING EVENT OCCURING !!!!");
			 if(response instanceof ActionResponse){  
				 	ActionResponse aResponse = (ActionResponse)response;  
			   		QName qname = new QName("http://steria.com/quicksearch" , "QuickSearch");  
			   		aResponse.setEvent(qname, "Keywords searching terms");  
			  } 
		}


But then from the other portlet this code won't be called anytime


 public void processEvent(EventRequest request, EventResponse response) {  

        logger.info("!!!! RECEIVING AN EVENT !!!!");

    	Event event = request.getEvent();  
        if(event.getName().equals("QuickSearch")){  
          String ipc = (String) event.getValue();  
        }  
     } 


The portlet.xml admits the declaration of the event publisher/receiver.

Is this all correct so far ?

Thanks for your returns.
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: IPC between theme and page

Liferay Legend Beiträge: 14917 Beitrittsdatum: 02.09.06 Neueste Beiträge
With the exception that for IPC to work, the portlets have to be on the same page...

If they are not on the same page, the receiving portlet is not active and will not receive the events, so it's not like sending an event from the first portlet will force the portal to switch to the page that your 2nd portlet is so it can respond to the event or anything.
thumbnail
Olivier ROMAND, geändert vor 12 Jahren.

RE: IPC between theme and page

New Member Beiträge: 24 Beitrittsdatum: 07.01.12 Neueste Beiträge
Ok,

So what would be the recommended option ?
In particular, looking at liferay website, what's the best way to implement a quick search facility ?
thumbnail
jelmer kuperus, geändert vor 12 Jahren.

RE: IPC between theme and page

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
Well take a look at what liferay itself does when you embed the search tag in the theme

https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/taglib/ui/search/start.jsp

they use urls
thumbnail
Olivier ROMAND, geändert vor 12 Jahren.

RE: IPC between theme and page

New Member Beiträge: 24 Beitrittsdatum: 07.01.12 Neueste Beiträge
Oh great !

Thanks for the reply.