All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.fhframework.docs.event.FileDownloadEventDocumentationUC Maven / Gradle / Ivy

The newest version!
package pl.fhframework.docs.event;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;

import pl.fhframework.core.security.annotations.SystemFunction;
import pl.fhframework.core.uc.IInitialUseCase;
import pl.fhframework.core.uc.UseCase;
import pl.fhframework.core.uc.url.UseCaseWithUrl;
import pl.fhframework.docs.DocsSystemFunction;
import pl.fhframework.docs.event.model.FileDownloadEventModel;
import pl.fhframework.annotations.Action;
import pl.fhframework.event.EventRegistry;
import pl.fhframework.events.ViewEvent;

@UseCase
@UseCaseWithUrl(alias = "docs-event-download")
//@SystemFunction(DocsSystemFunction.FH_DOCUMENTATION_VIEW)
public class FileDownloadEventDocumentationUC implements IInitialUseCase {

    @Autowired
    private EventRegistry eventRegistry;

    @Override
    public void start() {
        showForm(FileDownloadEventForm.class, new FileDownloadEventModel());
    }

    @Action
    private void downloadByResource(ViewEvent event) {
        final FileDownloadEventModel model = event.getSourceForm().getModel();
        //below resource does not have to be bound to model, it is only example
        final Resource resource = model.getModelBindingResource();
        eventRegistry.fireDownloadEvent(resource);
    }

    @Action
    private void downloadByBinding(ViewEvent event) {
       eventRegistry.fireDownloadEventByBinding(event.getSourceObject(), "modelBindingResource");
    }

    @Action
    private void downloadByFormElement(ViewEvent event){
        eventRegistry.fireDownloadEvent(event.getSourceForm().getFormElement("fileUploadId1"));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy