Search in sources :

Example 6 with RequestContext

use of org.primefaces.context.RequestContext in project dataverse by IQSS.

the class FileDownloadHelper method writeGuestbookAndStartDownload.

public void writeGuestbookAndStartDownload(GuestbookResponse guestbookResponse) {
    RequestContext requestContext = RequestContext.getCurrentInstance();
    boolean valid = validateGuestbookResponse(guestbookResponse);
    if (!valid) {
        JH.addMessage(FacesMessage.SEVERITY_ERROR, JH.localize("dataset.message.validationError"));
    } else {
        requestContext.execute("PF('downloadPopup').hide()");
        guestbookResponse.setDownloadtype("Download");
        fileDownloadService.writeGuestbookAndStartDownload(guestbookResponse);
    }
}
Also used : RequestContext(org.primefaces.context.RequestContext)

Example 7 with RequestContext

use of org.primefaces.context.RequestContext in project dataverse by IQSS.

the class DatasetPage method validateFilesForDownload.

public void validateFilesForDownload(boolean guestbookRequired) {
    setSelectedDownloadableFiles(new ArrayList<>());
    setSelectedNonDownloadableFiles(new ArrayList<>());
    if (this.selectedFiles.isEmpty()) {
        RequestContext requestContext = RequestContext.getCurrentInstance();
        requestContext.execute("PF('selectFilesForDownload').show()");
        return;
    }
    List<FileMetadata> allFiles = new ArrayList<>();
    if (isSelectAllFiles()) {
        for (FileMetadata fm : workingVersion.getFileMetadatas()) {
            allFiles.add(fm);
        }
        this.selectedFiles = allFiles;
    }
    for (FileMetadata fmd : this.selectedFiles) {
        if (this.fileDownloadHelper.canDownloadFile(fmd)) {
            getSelectedDownloadableFiles().add(fmd);
        } else {
            getSelectedNonDownloadableFiles().add(fmd);
        }
    }
    if (!getSelectedDownloadableFiles().isEmpty() && getSelectedNonDownloadableFiles().isEmpty()) {
        if (guestbookRequired) {
            modifyGuestbookMultipleResponse();
        } else {
            startMultipleFileDownload(false);
        }
    }
    if (getSelectedDownloadableFiles().isEmpty() && !getSelectedNonDownloadableFiles().isEmpty()) {
        RequestContext requestContext = RequestContext.getCurrentInstance();
        requestContext.execute("PF('downloadInvalid').show()");
        return;
    }
    if (!getSelectedDownloadableFiles().isEmpty() && !getSelectedNonDownloadableFiles().isEmpty()) {
        RequestContext requestContext = RequestContext.getCurrentInstance();
        requestContext.execute("PF('downloadMixed').show()");
    }
}
Also used : ArrayList(java.util.ArrayList) RequestContext(org.primefaces.context.RequestContext)

Example 8 with RequestContext

use of org.primefaces.context.RequestContext in project dataverse by IQSS.

the class DatasetPage method testSelectedFilesForRestrict.

public String testSelectedFilesForRestrict() {
    RequestContext requestContext = RequestContext.getCurrentInstance();
    if (selectedFiles.isEmpty()) {
        requestContext.execute("PF('selectFilesForRestrict').show()");
        return "";
    } else {
        boolean validSelection = false;
        for (FileMetadata fmd : selectedFiles) {
            if (!fmd.isRestricted()) {
                validSelection = true;
            }
        }
        if (!validSelection) {
            requestContext.execute("PF('selectFilesForRestrict').show()");
            return "";
        }
        testSelectedFilesForMapData();
        requestContext.execute("PF('accessPopup').show()");
        return "";
    }
}
Also used : RequestContext(org.primefaces.context.RequestContext)

Example 9 with RequestContext

use of org.primefaces.context.RequestContext in project dataverse by IQSS.

the class ThemeWidgetFragment method resetForm.

public void resetForm() {
    RequestContext context = RequestContext.getCurrentInstance();
    context.reset(":dataverseForm:themeWidgetsTabView");
}
Also used : RequestContext(org.primefaces.context.RequestContext)

Example 10 with RequestContext

use of org.primefaces.context.RequestContext in project dataverse by IQSS.

the class FileDownloadHelper method startWorldMapDownloadLink.

public String startWorldMapDownloadLink(GuestbookResponse guestbookResponse, FileMetadata fmd) {
    RequestContext requestContext = RequestContext.getCurrentInstance();
    boolean valid = validateGuestbookResponse(guestbookResponse);
    if (!valid) {
        return "";
    }
    guestbookResponse.setDownloadtype("WorldMap");
    String retVal = fileDownloadService.startWorldMapDownloadLink(guestbookResponse, fmd);
    requestContext.execute("PF('downloadPopup').hide()");
    return retVal;
}
Also used : RequestContext(org.primefaces.context.RequestContext)

Aggregations

RequestContext (org.primefaces.context.RequestContext)11 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 FacesMessage (javax.faces.application.FacesMessage)1 UploadedFile (org.primefaces.model.UploadedFile)1