Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Loïc Dumont
Reload the portlet after configuration change
April 20, 2011 8:17 AM
Answer

Loïc Dumont

Rank: Junior Member

Posts: 43

Join Date: April 27, 2010

Recent Posts

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?
Loïc Dumont
RE: Reload the portlet after configuration change
May 2, 2011 1:16 AM
Answer

Loïc Dumont

Rank: Junior Member

Posts: 43

Join Date: April 27, 2010

Recent Posts

No idea on this?
Luis Rodríguez Fernández
RE: Reload the portlet after configuration change
May 2, 2011 2:13 AM
Answer

Luis Rodríguez Fernández

Rank: Junior Member

Posts: 86

Join Date: June 26, 2009

Recent Posts

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
Loïc Dumont
RE: Reload the portlet after configuration change
May 4, 2011 12:04 AM
Answer

Loïc Dumont

Rank: Junior Member

Posts: 43

Join Date: April 27, 2010

Recent Posts

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
RE: Reload the portlet after configuration change
May 4, 2011 1:20 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 885

Join Date: February 18, 2009

Recent Posts

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
Tanweer .
RE: Reload the portlet after configuration change
May 4, 2011 2:54 AM
Answer

Tanweer .

Rank: Expert

Posts: 319

Join Date: March 11, 2010

Recent Posts

Hi Loic,

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

Regards,
Tanweer Ahmed Ansari,
mPowerian-BoschLer
Thu Nguyen
RE: Reload the portlet after configuration change
May 26, 2011 8:45 PM
Answer

Thu Nguyen

Rank: New Member

Posts: 1

Join Date: May 26, 2011

Recent Posts

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
Guillaume Lhermitte
RE: Reload the portlet after configuration change
September 29, 2011 1:32 AM
Answer

Guillaume Lhermitte

Rank: New Member

Posts: 13

Join Date: November 2, 2010

Recent Posts

Could you describe the mechanics behind this (looking) simple line ?

Because this worked for me fine.

For what I see

 1package my.portlet.package.configuration;
 2[many other irrelevant imports]
 3import com.liferay.portal.kernel.portlet.ConfigurationAction;
 4
 5public class myConfigurationAction implements ConfigurationAction {
 6
 7    public void processAction(PortletConfig cfg, ActionRequest req, ActionResponse rsp) throws Exception {
 8
 9        String res = ParamUtil.getString(req, "portletResource");
10        PortletPreferences prf = PortletPreferencesFactoryUtil.getPortletSetup(req, res);
11        prf.setValue("pref1", ParamUtil.get(req, "pref1", "default1"));
12        prf.setValue("pref2", ParamUtil.get(req, "pref2", "default2"));
13        prf.store();
14
15        SessionMessages.add(req, cfg.getPortletName() + ".doConfigure");
16
17        rsp.sendRedirect(ParamUtil.getString(req, "redirect"));
18    }
19}


This simple line
1SessionMessages.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 !
Loïc Dumont
RE: Reload the portlet after configuration change
April 11, 2012 1:15 AM
Answer

Loïc Dumont

Rank: Junior Member

Posts: 43

Join Date: April 27, 2010

Recent Posts

That was exactly what I was looking for, thanks!