Fórum

Reload the portlet after configuration change

thumbnail
Loïc Dumont, modificado 12 Anos atrás.

Reload the portlet after configuration change

Junior Member Postagens: 43 Data de Entrada: 27/04/10 Postagens Recentes
I'm adding configuration possibilities to a portlet I have developed (using the configuration-action-class node in liferay-portlet.xml).

I was able to achieve this and everything is working fine, I just want a last step.

When I click on the save button in the configuration box, the configuration is saved but I need to reload the page manually to see the change in my portlet.

I would like that either the whole page, or only the portlet get reload to see directly the change after I save the new configuration. Only the portlet being reload would be the best.

Any idea on how to do this?
thumbnail
Loïc Dumont, modificado 12 Anos atrás.

RE: Reload the portlet after configuration change

Junior Member Postagens: 43 Data de Entrada: 27/04/10 Postagens Recentes
No idea on this?
thumbnail
Luis Rodríguez Fernández, modificado 12 Anos atrás.

RE: Reload the portlet after configuration change

Junior Member Postagens: 86 Data de Entrada: 26/06/09 Postagens Recentes
Hi Löic,

Maybe you could try to override your doDispatch method of your portlet. In this way you could redirect the flow to the view that you want. For sure this is going to reload the entire page. If you only want to reload your portlet you need to use some kind of asynchronous call (ajax).

For configuration operations I use to override the doEdit method. Maybe you can try also to do it in this way.

Hope it helps,

Luis
thumbnail
Loïc Dumont, modificado 12 Anos atrás.

RE: Reload the portlet after configuration change

Junior Member Postagens: 43 Data de Entrada: 27/04/10 Postagens Recentes
Thanks for your answer.

The reload of the page could be a solution, but I'd rather do something like the webcontent display portlet. To see what I mean, add a webcontent display portlet to your page. Open the configuration of this portlet and click on a webcontent, then on the "save" button. After this the content of the portlet is reloaded and the webcontent is visible in the portlet.

I looked at the source but I can't figure out how it works!

For the configuration I override processAction and render in my own class which implements "com.liferay.portal.kernel.portlet.ConfigurationAction".
Oliver Bayer, modificado 12 Anos atrás.

RE: Reload the portlet after configuration change

Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
Hi Loic,

I think you should set the redirect parameter as a hidden parameter in your form or set it in java as an action url of your form (e.g. done in asset publisher configuration in 5.2.3) or set it via portlet:param.

HTH Oli
thumbnail
Tanweer Ahmed ., modificado 1 Ano atrás.

RE: Reload the portlet after configuration change

Expert Postagens: 322 Data de Entrada: 11/03/10 Postagens Recentes
Hi Loic,

Follow this link . Not very sure , but it may help you.

Regards,
Tanweer Ahmed Ansari,
mPowerian-BoschLer
Thu Nguyen, modificado 12 Anos atrás.

RE: Reload the portlet after configuration change

New Member Mensagem: 1 Data de Entrada: 27/05/11 Postagens Recentes
Hi Loïc,

Would you please try to add this line into the processAction method of your Configuration class.

SessionMessages.add(form.getActionRequest(), config.getPortletName() + ".doConfigure");
...

The message must be 'config.getPortletName() + ".doConfigure" ' exactly.

Regards,

Thu
thumbnail
Guillaume Lhermitte, modificado 12 Anos atrás.

RE: Reload the portlet after configuration change

New Member Postagens: 13 Data de Entrada: 02/11/10 Postagens Recentes
Could you describe the mechanics behind this (looking) simple line ?

Because this worked for me fine.

For what I see

package my.portlet.package.configuration;
[many other irrelevant imports]
import com.liferay.portal.kernel.portlet.ConfigurationAction;

public class myConfigurationAction implements ConfigurationAction {

	public void processAction(PortletConfig cfg, ActionRequest req, ActionResponse rsp) throws Exception {

		String res = ParamUtil.getString(req, "portletResource");
		PortletPreferences prf = PortletPreferencesFactoryUtil.getPortletSetup(req, res);
		prf.setValue("pref1", ParamUtil.get(req, "pref1", "default1"));
		prf.setValue("pref2", ParamUtil.get(req, "pref2", "default2"));
		prf.store();

		SessionMessages.add(req, cfg.getPortletName() + ".doConfigure");

		rsp.sendRedirect(ParamUtil.getString(req, "redirect"));
	}
}


This simple line
SessionMessages.add(req, cfg.getPortletName() + ".doConfigure");

Enable the redraw of the currently configured portlet and displays an "all ok" message on top of your configuration pane saying that config were successfull.

This mechanism can not be associated with this only line.

What are the other capabilities of this line ? Does anyone have a wlue how one could redraw other (still specific) portlets ? Or how to send warning and/or error messages ? What are the best practices about this ?

Thanks in advance !
thumbnail
Loïc Dumont, modificado 11 Anos atrás.

RE: Reload the portlet after configuration change

Junior Member Postagens: 43 Data de Entrada: 27/04/10 Postagens Recentes
That was exactly what I was looking for, thanks!