Foren

Reload the portlet after configuration change

thumbnail
Loïc Dumont, geändert vor 13 Jahren.

Reload the portlet after configuration change

Junior Member Beiträge: 43 Beitrittsdatum: 27.04.10 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: Reload the portlet after configuration change

Junior Member Beiträge: 43 Beitrittsdatum: 27.04.10 Neueste Beiträge
No idea on this?
thumbnail
Luis Rodríguez Fernández, geändert vor 12 Jahren.

RE: Reload the portlet after configuration change

Junior Member Beiträge: 86 Beitrittsdatum: 26.06.09 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: Reload the portlet after configuration change

Junior Member Beiträge: 43 Beitrittsdatum: 27.04.10 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: Reload the portlet after configuration change

Liferay Master Beiträge: 894 Beitrittsdatum: 18.02.09 Neueste Beiträge
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 ., geändert vor 1 Jahr.

RE: Reload the portlet after configuration change

Expert Beiträge: 322 Beitrittsdatum: 11.03.10 Neueste Beiträge
Hi Loic,

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

Regards,
Tanweer Ahmed Ansari,
mPowerian-BoschLer
Thu Nguyen, geändert vor 12 Jahren.

RE: Reload the portlet after configuration change

New Member Beitrag: 1 Beitrittsdatum: 27.05.11 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: Reload the portlet after configuration change

New Member Beiträge: 13 Beitrittsdatum: 02.11.10 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: Reload the portlet after configuration change

Junior Member Beiträge: 43 Beitrittsdatum: 27.04.10 Neueste Beiträge
That was exactly what I was looking for, thanks!