use of com.webobjects.appserver.WOActionResults in project wonder-slim by undur.
the class AjaxFileUpload method uploadSucceeded.
public WOActionResults uploadSucceeded() {
AjaxUploadProgress progress = uploadProgress();
try {
boolean deleteFile = true;
if (hasBinding("filePath")) {
setValueForBinding(progress.fileName(), "filePath");
}
if (hasBinding("data")) {
NSData data = new NSData(progress.tempFile().toURI().toURL());
setValueForBinding(data, "data");
}
if (hasBinding("mimeType")) {
String contentType = progress.contentType();
if (contentType != null) {
setValueForBinding(contentType, "mimeType");
}
}
if (hasBinding("inputStream")) {
setValueForBinding(new FileInputStream(progress.tempFile()), "inputStream");
deleteFile = false;
}
if (hasBinding("outputStream")) {
try (OutputStream outputStream = (OutputStream) valueForBinding("outputStream")) {
if (outputStream != null) {
try (InputStream inputStream = new FileInputStream(progress.tempFile())) {
inputStream.transferTo(outputStream);
}
}
}
}
String finalFilePath = progress.tempFile().getAbsolutePath();
if (hasBinding("streamToFilePath")) {
File streamToFile = new File((String) valueForBinding("streamToFilePath"));
boolean renamedFile;
boolean renameFile;
if (streamToFile.exists()) {
boolean overwrite = ERXComponentUtilities.booleanValueForBinding(this, "overwrite");
if (streamToFile.isDirectory()) {
File parentDir = streamToFile;
String fileName = fileNameFromBrowserSubmittedPath(progress.fileName());
streamToFile = reserveUniqueFile(new File(parentDir, fileName), overwrite);
renameFile = true;
} else {
renameFile = overwrite;
}
} else {
renameFile = true;
}
if (renameFile && !streamToFile.isDirectory()) {
renameTo(progress.tempFile(), streamToFile);
renamedFile = true;
} else {
renamedFile = false;
progress.setFailure(new Exception("Could not rename file."));
return uploadFailed();
}
if (renamedFile) {
finalFilePath = streamToFile.getAbsolutePath();
}
deleteFile = false;
} else if (hasBinding("keepTempFile") && deleteFile) {
deleteFile = !ERXComponentUtilities.booleanValueForBinding(this, "keepTempFile");
}
if (deleteFile) {
progress.dispose();
} else if (hasBinding("finalFilePath")) {
setValueForBinding(finalFilePath, "finalFilePath");
}
} catch (Throwable t) {
t.printStackTrace();
progress.setFailure(t);
return uploadFailed();
} finally {
uploadFinished();
}
WOActionResults results = (WOActionResults) valueForBinding("succeededAction");
return results;
}
use of com.webobjects.appserver.WOActionResults in project wonder-slim by undur.
the class AjaxFlexibleFileUpload method clearFileResults.
/**
* Action called by the clear button, resets the uploader for a new file selection
*
* @return results of action
*/
public WOActionResults clearFileResults() {
clearUploadProgress();
WOActionResults results = (WOActionResults) valueForBinding("clearedAction");
return results;
}
use of com.webobjects.appserver.WOActionResults in project wonder-slim by undur.
the class AjaxFlexibleFileUpload method uploadSucceeded.
/**
* Hook for add-in action called when an upload succeeds.
*/
@Override
public WOActionResults uploadSucceeded() {
WOActionResults result = super.uploadSucceeded();
clearUploadProgress();
return result;
}
use of com.webobjects.appserver.WOActionResults in project wonder-slim by undur.
the class AjaxHyperlink method handleRequest.
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
WOComponent component = context.component();
WOActionResults results = (WOActionResults) valueForBinding("action", component);
if (results == null) {
String script = (String) valueForBinding("onClickServer", component);
if (script != null) {
WOResponse response = AjaxUtils.createResponse(request, context);
AjaxUtils.appendScriptHeader(response);
response.appendContentString(script);
AjaxUtils.appendScriptFooter(response);
results = response;
}
}
return results;
}
use of com.webobjects.appserver.WOActionResults in project wonder-slim by undur.
the class AjaxInPlace method invokeAction.
@Override
public WOActionResults invokeAction(WORequest aRequest, WOContext aContext) {
_alreadyInForm = context().isInForm();
WOActionResults results = super.invokeAction(aRequest, aContext);
// MS: see appendToResponse
_id = null;
return results;
}
Aggregations