addFieldError(new FactoryURL(getComponentName(), "file"), null, file);
GraphicElement galleryToAddTo = UIServices.lookup().getResourceGalleryManager().getDefaultElement();
ResourceName resName = galleryToAddTo.getResourceName(name);
Resource resource = galleryToAddTo.getResource(resName, null);
if (resource != null)
addFieldError(new FactoryURL(getComponentName(), "name"), null, file);
if (this.getFieldErrors().isEmpty()) {
UIServices.lookup().getResourceGalleryManager().addFileToResource(name, file, galleryToAddTo, ResourceGallery.DESCRIPTOR_FILENAME);
setName(null);
operationSuccess = true;
resource = galleryToAddTo.getResource(resName, null);
lastResourceUrl = resource.getResourceUrl(request.getRequestObject(), request.getResponseObject(), true);
//Make sure it is a relative url like Controller?mvchandler=...
if (lastResourceUrl.startsWith(request.getRequestObject().getContextPath())) {
lastResourceUrl = lastResourceUrl.substring((request.getRequestObject().getContextPath()).length());
}
while (lastResourceUrl.startsWith("/")) lastResourceUrl = lastResourceUrl.substring(1);