can I show form in scout on specific date/time?
For example: I have reminders in app. I want to show reminder form on specific time to user.
I know I can use timer in form, but then I need to add that "timer code" to all forms I have in app, so timer can be fired.
Is there another way to add it in one place, not to all forms?
Thanks
Yes, please check the technical guide for Eclipse Scout. In chapter 9, JobManager you should find everything about jobs and also code examples for how to schedule a job.
For your case you must schedule a ModelJob and create a JobInput with an ExecutionTrigger that uses the #withStartAt(Date)
method. This should work:
Date reminderDate = new Date();
ModelJobs.schedule(() -> {
new ReminderForm().start();
}, ModelJobs.newInput(ClientRunContexts.copyCurrent())
.withName("Open reminder form")
.withExecutionTrigger(Jobs.newExecutionTrigger()
.withStartAt(reminderDate))
.withExceptionHandling(new ExceptionHandler() {
@Override
public void handle(Throwable t) {
System.err.println(t);
}
}, true));
Maybe you should also check out the "desktop notification" concept, which allows to notify users with a less intrusive widget than a form. You'll find an example here, click on the "Show notification" button.