Forums de discussion
Automatically Update a Portlet after saved configuration
Mohd Asyraf, modifié il y a 11 années.
Automatically Update a Portlet after saved configuration
New Member Publications: 19 Date d'inscription: 04/01/12 Publications récentes
Hi,
Does anyone know how to update/ refresh a portlet automatically after saved the new configuration?
Does anyone know how to update/ refresh a portlet automatically after saved the new configuration?
Jignesh Vachhani, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
Liferay Master Publications: 803 Date d'inscription: 10/03/08 Publications récentes
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
Might be you will have extended wrongclass.
You may have to extend DefaultConfigurationAction
Hope this will resolve your problem
Jignesh
Mohd Asyraf, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
New Member Publications: 19 Date d'inscription: 04/01/12 Publications récentespublic 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.
Jignesh Vachhani, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
Liferay Master Publications: 803 Date d'inscription: 10/03/08 Publications récentes
Which version of Liferay you are using.
I checked this with Liferay 6.1CE in my local and its working properly.
I checked this with Liferay 6.1CE in my local and its working properly.
Mohd Asyraf, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
New Member Publications: 19 Date d'inscription: 04/01/12 Publications récentes
I'm using Liferay 6.1CEa and it is not working on my portal.
Is there anything that i'm missing?
Is there anything that i'm missing?
David H Nebinger, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
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.
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, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
New Member Publications: 19 Date d'inscription: 04/01/12 Publications récentes
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.
All I want is the portlet update automatically after configured.
In other words the portlet update its content automatically.
David H Nebinger, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Nothing happens automatically, unless you code it as such.
Mohd Asyraf, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
New Member Publications: 19 Date d'inscription: 04/01/12 Publications récentes
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.
That's why I asked for help and need some hint on how to do that.
bo li, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
Junior Member Publications: 38 Date d'inscription: 14/11/11 Publications récentes
Have you found the solution for this yet?
Mykola M, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
New Member Publications: 4 Date d'inscription: 20/01/11 Publications récentes
From DefaultConfigurationAction:
SessionMessages.add(
actionRequest,
portletConfig.getPortletName() +
SessionMessages.KEY_SUFFIX_REFRESH_PORTLET,
portletResource);
Randy Parsons, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
Junior Member Publications: 33 Date d'inscription: 04/01/11 Publications récentes
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
Code
and add the following to your configuration.jsp file
To Refresh Portlet on Submit
To refresh the portlet on the submit, use the code from Mykola M above:
Imports
Code
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.
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.
Vishal Panchal, modifié il y a 9 années.
RE: Automatically Update a Portlet after saved configuration
Expert Publications: 289 Date d'inscription: 20/05/12 Publications récentes
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
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
David H Nebinger, modifié il y a 11 années.
RE: Automatically Update a Portlet after saved configuration
Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Unless you've implemented a javascript push mechanism, the portlet will not refresh until the user refreshes their browser.