Paweł Domański Paweł Domański - 8 months ago 42
Java Question

Call portlet action from external application

I have liferay portal with some portlets. Portlet has for example some action:

@RenderMapping(params = "action=displayHome")
public String displayHome(final RenderRequest request, final RenderResponse response, final ModelMap map) {

return "home";

Inside liferay I can use this action by and everything works fine. But! I have second application ( normal spring mvc hibernate etc) on which I need to call this action. Srsly I don`t know how to do this. Can anyone help me?

I created routes file with :

<implicit-parameter name="action">testAction</implicit-parameter>

<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
<implicit-parameter name="p_p_id">xxx_WAR_xxxportlet_INSTANCE_73iYU2pK0li</implicit-parameter>
<implicit-parameter name="p_p_state">normal</implicit-parameter>
<implicit-parameter name="p_p_mode">view</implicit-parameter>
<implicit-parameter name="p_p_col_id">column-1</implicit-parameter>
<implicit-parameter name="p_p_col_count">1</implicit-parameter>

And I have problem, that it is not working. Always send me to actual page -> Action is not called :/

  • Option 1 - copy the url from the page where you can use it and paste it in your Spring app. Downside - many things can change in the portal, resulting in url change and your application will not work anymore.

  • Option 2 - learn how URLs are constructed and generate one from your Spring app. Downside - portlet URL are complex and long (there is not enough space here to describe all options in details)

  • Option 3 - generate a Fiendly URL(s) for your portlet and use that in your Spring app. Downside - will stop working if you move the portlet to a different page)

  • Option 4 - don't use portlet alone, use local/remote service + portlet instead. Put your logic in local service, call it via portlet when local and via remote service form other apps (even mobile ones)