I’m making a Task Manager Vaadin application in a school project. In this project, for simplicity’s sake I’m not using a database but simple xml files instead to store and retrieve data (in this case tables that have tasks as rows and task properties as columns). I’ve already managed to open xml-files to fill the tables in my task manager app. I’ve also managed to save the current table contents as xml-files to my computer.
However, I want my Vaadin application to be able to create xml-files to a specified location on the server. So, that all the files would be stored on the server and not on user’s hard disk. I’m a complete greenhorn on TomCat, or servers in general. I noticed that I can’t save stuff on WEB-INF folder for example.
So, where can I “save” the table contents as a xml-file to, so that the user can see the stored xml-files each time he uses the application. This is just for demoing it in class, so security etc. is not an issue.
I don’t have a direct answer on this, but if you have to go into making a new solution for this (if it proves impossible to use XML), you might want to look into JPAContainers. It was not a hardship to install the h2 database, and connecting to it is rather easy.
What I usually do if I have a small project and just want to have a file based data store is use something like HSQLDB (http://hsqldb.org) as a database and then point that database to a file using the
jdbc:hsqldb:file: property. Then you can use that as a normal database with JPA or whatever you want.
if you want to write into your tomcat deployment folder you can use
servletContext().getRealPath("/");
to access it. You should be careful because this folder does clear completly after you redeploy your application. But this could be the behavior you want in your case
To access the servlet context you could use the VaadinRequest object in your init() mehtod
((HttpSession)request.getWrappedSession()).getServletContext()
Sorry I didn’t try this out