// The only way to retrieve the information if the state is not transient is if we're within a portal context
ExoContainer container = ExoContainerContext.getCurrentContainer();
if (container instanceof PortalContainer) {
ModelDataStorage dataStorage = (ModelDataStorage) container.getComponentInstanceOfType(ModelDataStorage.class);
try {
gadget = dataStorage.load(state, ApplicationType.GADGET);
} catch (Exception e) {
throw new XMLStreamException("Could not obtain gadget state from custom context.");
}
try {