Fórum

Automatically Update a Portlet after saved configuration

Mohd Asyraf, modificado 11 Anos atrás.

Automatically Update a Portlet after saved configuration

New Member Postagens: 19 Data de Entrada: 04/01/12 Postagens Recentes
Hi,

Does anyone know how to update/ refresh a portlet automatically after saved the new configuration?
thumbnail
Jignesh Vachhani, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

Liferay Master Postagens: 803 Data de Entrada: 10/03/08 Postagens Recentes
Can you post some of code which you have written in your *ConfigurationImpl.java ?
Might be you will have extended wrongclass.
You may have to extend DefaultConfigurationAction

Hope this will resolve your problem
Jignesh
Mohd Asyraf, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

New Member Postagens: 19 Data de Entrada: 04/01/12 Postagens Recentes
public class ConfigurationActionImpl extends DefaultConfigurationAction {

@Override
public void processAction(PortletConfig portletConfig,
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
System.out.println("***Inside processaction of Config****");
String url = actionRequest.getParameter("url");
int height = Integer.parseInt(actionRequest.getParameter("height"));
int maxHeight = Integer.parseInt(actionRequest.getParameter("maxHeight"));
PortletPreferences preferences = actionRequest.getPreferences();

String portletResource = ParamUtil.getString(actionRequest, "portletResource");

if (Validator.isNotNull(portletResource)) {
preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);
}
preferences.setValue("url", url);
preferences.setValue("height", Integer.toString(height));
preferences.setValue("maxHeight", Integer.toString(maxHeight));
preferences.store();

// TODO Auto-generated method stub
super.processAction(portletConfig, actionRequest, actionResponse);
}


I already expand the DefaultConfigurationAction but the portlet still not update automatically.
thumbnail
Jignesh Vachhani, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

Liferay Master Postagens: 803 Data de Entrada: 10/03/08 Postagens Recentes
Which version of Liferay you are using.
I checked this with Liferay 6.1CE in my local and its working properly.
Mohd Asyraf, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

New Member Postagens: 19 Data de Entrada: 04/01/12 Postagens Recentes
I'm using Liferay 6.1CEa and it is not working on my portal.
Is there anything that i'm missing?
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
What is not working?

Are you saying you have two browsers, and browser A is sitting there w/ the portlet that is misconfigured. Browser B is open and you configure the portlet there so that in browser B it is working right, but because you haven't done anything in browser A it is still sitting there as misconfigured? And that not until you do a page refresh will A actually show the portlet correctly?

I'm thinking you expect that when the config is updated in browser B that browser A should magically come alive and update itself to reflect the right thing.

Portlets don't work like that. As I said, unless you implement some sort of javascript push, browser A will just sit there and show the portlet as misconfigured until you refresh or submit a page.
Mohd Asyraf, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

New Member Postagens: 19 Data de Entrada: 04/01/12 Postagens Recentes
I'm not using two browsers. The browsers have its own cache and history.
All I want is the portlet update automatically after configured.
In other words the portlet update its content automatically.
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Nothing happens automatically, unless you code it as such.
Mohd Asyraf, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

New Member Postagens: 19 Data de Entrada: 04/01/12 Postagens Recentes
Of course i need to code it.. However, i do not know how to do that.
That's why I asked for help and need some hint on how to do that.
bo li, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

Junior Member Postagens: 38 Data de Entrada: 14/11/11 Postagens Recentes
Have you found the solution for this yet?
Mykola M, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

New Member Postagens: 4 Data de Entrada: 20/01/11 Postagens Recentes
From DefaultConfigurationAction:

			SessionMessages.add(
				actionRequest,
				portletConfig.getPortletName() +
					SessionMessages.KEY_SUFFIX_REFRESH_PORTLET,
				portletResource);
thumbnail
Randy Parsons, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

Junior Member Postagens: 33 Data de Entrada: 04/01/11 Postagens Recentes
Thanks. This indeed does update my portlet when I hit save. Unfortunately I don't get any success message. Here is a summary of what I have found from the community and testing.

To Get a Success Message on Submit
To get a success message when you submit add the following in your ConfigurationActionImpl.java file, but it will not refresh the portlet
Imports
import com.liferay.portal.kernel.servlet.SessionMessages;

Code
SessionMessages.add(actionRequest, "success");

and add the following to your configuration.jsp file
<liferay-ui:success key="success" message="Configuration saved successfully!" />
...
<aui:button name="saveButton" type="submit" value="save" />

To Refresh Portlet on Submit
To refresh the portlet on the submit, use the code from Mykola M above:
Imports
import com.liferay.portal.kernel.servlet.SessionMessages;

Code
SessionMessages.add(
	                actionRequest,
	                portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET,
	                portletResource);

And use the same <aui:button> as before.

Now, if someone knows how to combine the two, could they please reply with the answer. I believe it has something to do with how the second parameter in the Session.add is used.
thumbnail
Vishal Panchal, modificado 9 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

Expert Postagens: 289 Data de Entrada: 20/05/12 Postagens Recentes
Dear Randy,

Thanks for all details and explanation.
I am able to combine these both.

1. Thing is below code is used to display a success message.
SessionMessages.add(actionRequest, "configuration-saved");

2. Below code is to refresh a page after we save configuration.
SessionMessages.add(actionRequest,
portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET,portletResource);

So, what I did is I wrote below code. I wrote both lines together in sequence.
Now, when I save configuration It is showing me a success message and after that I is also refreshing page.

Lines of Code to combine both success message and page refresh.

SessionMessages.add(actionRequest, "configuration-saved");
SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET,portletResource);

Many Thanks,
Vishal Panchal
vslpanchal@gmail.com
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Automatically Update a Portlet after saved configuration

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Unless you've implemented a javascript push mechanism, the portlet will not refresh until the user refreshes their browser.