In the first part of our series I’ve focused on overall reasons why we’ve chosen Vaadin as a next development platform for our future applications. The second part shows how to navigate and work with views and in the third part we went through variety of form components. Today we set the attention to Java Script components, agents and access rights. At the end is a link to our simple demo in Vaadin.
· RPC calls from client to server
· Shared state and RPC from server to client
The basic concept of agents is to run the task at specific time and interval and do some job. In Notes we used agents for that. The similar functionality you can achieve by scheduled component in Vaadin. It is a class in Java again with the code which is doing what we want. The schedule is set up very easily by annotation @Scheduled followed by time and interval. It can be fixed rate every x milliseconds or you can set up the time schedule by well know cron syntax. See examples here:
@Scheduled(fixedRate = 1*60*60*1000, initialDelay=30)
@Scheduled(cron =”0 4 * * * ?”)
That is the most challenging part when you come from Notes environment because the system does not do it for you. You have to include access rights to the application logic. But Notes experience are very handy here. We’ve implemented those rules:
1. Every document has multivalued fields “authors” and “readers”.
2. Those fields are computed on each save and are based on the application logic. Sometimes we need to put there an author, sometime an approver etc. The same is in Notes.
3. Every request to the database to display the view, open document for reading or viewing, checks users credentials against “authors” and “readers” field. Fortunately that can be written in the basic class which is inherited to every single part, so it cannot be forgotten somewhere.
4. User’s credentials consist of login ID, his roles and groups set by admin in administration part of the application. Similar to Notes.
That seems to be quite difficult to maintain ACL but in fact, it is not. Due to centralized classes taking care about access, it is works quite straightforward. Actually it brings some benefits as well, because as a designer you can allow the user to write to the document which he can’t normally edit. For instance you need to set a new status of the document depended on user’s action (approval, comments). In Notes you need to solve that situation by agent with higher rights, because there is no other way to do this.
To see a glimpse of the application in Vaadin, go to our demo page and login with email@example.com, password: demo. It is not designed to catch all possible errors but I think that it is enough to get a flavour of applications in Vaadin.