}
public void setState(PortletState<S> state) {
if (state != null) {
try {
PortletInvoker portletInvoker = getApplicationComponent(PortletInvoker.class);
DataStorage dataStorage = getApplicationComponent(DataStorage.class);
String applicationId = dataStorage.getId(state.getApplicationState());
ModelAdapter<S, C> adapter = ModelAdapter.getAdapter(state.getApplicationType());
PortletContext producerOfferedPortletContext = adapter.getProducerOfferedPortletContext(applicationId);
org.gatein.pc.api.Portlet producedOfferedPortlet;
try {
producedOfferedPortlet = portletInvoker.getPortlet(producerOfferedPortletContext);
} catch (Exception e) {
// Whenever couldn't invoke the portlet object, set the request portlet to null for the error tobe
// properly handled and displayed when the portlet is rendered
producedOfferedPortlet = null;
log.error(e.getMessage(), e);