Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Customizing portlet export
I need to execute some code in a custom portlet when a user exports the portlet. I've added the following to liferay-portlet.xml:
<!-- For export/import -->
<portlet>
<portlet-name>gov_nasa_hq_sqlreporter_portlet_SqlReporterPortlet</portlet-name>
<portlet-data-handler-class>gov.nasa.hq.sqlreporter.portlet.SqlReporterExportImportLifecycleListener</portlet-data-handler-class>
</portlet>
And I've create this class:
package gov.nasa.hq.sqlreporter.portlet;
import java.io.Serializable;
import java.util.List;
import com.liferay.exportimport.kernel.lifecycle.ExportImportLifecycleEvent;
import com.liferay.exportimport.kernel.lifecycle.ExportImportLifecycleListener;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
public class SqlReporterExportImportLifecycleListener implements ExportImportLifecycleListener {
protected static Log _log = LogFactoryUtil.getLog(SqlReporterExportImportLifecycleListener.class);
@Override
public boolean isParallel() {
// TODO Auto-generated method stub
return false;
}
@Override
public void onExportImportLifecycleEvent(ExportImportLifecycleEvent exportImportLifecycleEvent) throws Exception {
String ID = "onExportImportLifecycleEvent: ";
_log.info(ID + "ENTER");
List<Serializable> attrlist = exportImportLifecycleEvent.getAttributes();
for (Serializable attr : attrlist) {
_log.info(ID + "attribute = " + attr.toString());
}
}
}
However, nothing is printed to the log when I do the export so I assume this isn't the correct way to implement this functionality. Can someone point me in the right direction? Thanks.
-Steve
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™