Time for action – a file browser
Follow these steps and see how easy it is to create a basic file browser with Vaadin:
Launch your IDE and create a new Vaadin project named treetable. Come on! Do it! Invest five minutes (maybe less) in this exercise.
Let's start with this empty layout:
public class TreetableUI extends UI { protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); } }
We are implementing a file browser, so we need the root directory to be shown:
public class TreetableUI extends UI { protected void init(VaadinRequest request) { // ... File folder = VaadinService.getCurrent().getBaseDirectory(); } }
Note
VaadinService.getCurrent().getBaseDirectory()
returns a File instance pointing to the directory where the application has been deployed. You can use another location if you want. Just make sure that the process running the application has permission to access the location...