vaadin7

Restricting file types upload component

廉价感情. 提交于 2019-12-05 18:30:35
I'm using the upload component of vaadin(7.1.9), now my trouble is that I'm not able to restrict what kind of files that can be sent with the upload component to the server, but I haven't found any API for that purpose. The only way is that of discarding file of wrong types after the upload. public OutputStream receiveUpload(String filename, String mimeType) { if(!checkIfAValidType(filename)){ upload.interruptUpload(); } return out; } Is this a correct way? No, its not the correct way. The fact is, Vaadin does provide many useful interfaces that you can use to monitor when the upload started,

Getting a NoClassDefFoundError after installing Vaadin

牧云@^-^@ 提交于 2019-12-05 16:43:17
I want to do a project using Vaadin and am facing some issues. Here's what I did. I downloaded Eclipse and installed the Vaadin for Eclipse plugin. Then, I created a new Vaadin 7 project. It downloaded some Ivy dependencies but then, when I pressed Run, I get this error: java.lang.NoClassDefFoundError:com/vaadin/server/VaadinServlet. I searched a bit on the Internet but to no avail. One thing is that in the web-app's WEB-INF/lib folder, there are no jars. I have attached a screenshot of the error and also web.xml and ivy.xml. ivy.xml: <?xml version="1.0"?> <!DOCTYPE ivy-module [ <!ENTITY

Setting Vaadin session-timeout parameter

别等时光非礼了梦想. 提交于 2019-12-05 06:02:29
I am using Vaadin 7.1.7 and I can't figure out how to set session-timeout parameter (to, say, 1min). As far as I can tell, Vaadin 7.x.x does not produce web.xml , it uses @VaadinServletConfiguration annotation but there doesn't seem to be a session-timeout parameter. Krayo As far as I know there are 2 ways to set session-timeout in Vaadin 7. In the web.xml: <session-config> <session-timeout>1</session-timeout> <!-- 1 minute --> </session-config> <servlet> <servlet-name>MyServlet</servlet-name> <servlet-class>com.xyz.web.MyServlet</servlet-class> <init-param> <description>My Main Page<

How to make only some columns editable in a Vaadin Grid?

只愿长相守 提交于 2019-12-05 05:32:12
Vaadin Grid allows to be defined as editable with grid.setEditorEnabled(true); This makes all visible columns editable. However I don't want the user to edit an specific column, but seems like the editable is an all or nothing. The next best solution I have found is to define an editor field with a disabled editor, which almost does the trick but the user is still able to select the text and move the cursor (but the field is not editable anymore). Grid.Column nameColumn = grid.getColumn("fullName"); nameColumn.setHeaderCaption("Full Name"); nameColumn.setEditorField(getNoEditableTextField());

How to get the Vaadin 7 application server IP and port?

痞子三分冷 提交于 2019-12-05 02:20:32
How can I get the protocol, IP and port of the app server running my Vaadin webapp? I'm using Vaadin 7. In vaadin 6 I doing in this way, but not work in vaadin 7: String server = ((WebApplicationContext) this.getContext()).getHttpSession().getServletContext().getServerInfo(); java.net.URL url = this.getURL(); String s = url.getHost()+":"+url.getPort()+url.getPath(); System.out.println(UI.getCurrent().getPage().getLocation().getHost()); System.out.println(UI.getCurrent().getPage().getLocation().getPath()); System.out.println(UI.getCurrent().getPage().getLocation().getPort()); I do it like this:

Vaadin - download the file / save as

五迷三道 提交于 2019-12-05 01:15:34
问题 I try to add button with function to download the file from external resource Button saveAsButton = new Button(); private FileDownloader fileDownloader; fileDownloader = new FileDownloader(new ExternalResource(........)); fileDownloader.extend(saveAsButton); This doesn't work for me :/ no errors in the background 回答1: Referred from this link. A custom file downloader can give you this functionality. Here is the custom class and demo. The main advantage of using this AdvancedFileDownloader

Getting rid of web.xml in Vaadin 7 with VaadinServlet

↘锁芯ラ 提交于 2019-12-04 17:16:52
I'm new to Java and Vaadin. A basic Vaadin project is using web.xml for all the mappings. If I want to use the @WebServlet annotation I need to create an inner class which somewhere inherits from HttpServlet . @SuppressWarnings("serial") public class VaadinplaygroundUI extends UI { @WebServlet(urlPatterns="/Helo") public static class Servlet extends VaadinServlet { } @Override protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); I know, I'm missing some overwritten methods in the inner class Servlet to get it working, but I don't know which. There

Vaadin close UI of same user in another browser/tab/system

末鹿安然 提交于 2019-12-04 16:47:04
I'm doing a project in Vaadin 7. In that I need to implement something like below for the login. A user 'A' is logged in to a system '1'. And again he logs into another system '2'. Now I want to know how to close the UI on the system '1'. I tried something and can able to close the UI, If it is the same browser. But, for different systems/browser. I don't have any idea. My Code: private void closeUI(String attribute) { for (UI ui : getSession().getUIs()) { if(ui.getSession().getAttribute(attribute) != null) if(ui.getSession().getAttribute(attribute).equals(attribute)) ui.close(); } } Can

How to display checkboxes instead of boolean in vaadin grid?

余生长醉 提交于 2019-12-04 08:48:02
I'm trying to display my boolean values as a checkbox in a vaadin grid. I can't use the multi selection mode because i need two columns with checkboxes. The columns of the Checkboxes shell have a Caption but the Checkboxes itself shell be without a caption. Does anyone have an idea ? You have to add generated columns for your checkboxes GeneratedPropertyContainer gpcontainer = new GeneratedPropertyContainer(container); gpcontainer.addGeneratedProperty("columnName", new PropertyValueGenerator<CheckBox>() { @Override public CheckBox getValue(Item item, Object itemId, Object propertyId) { // set

How to close a Vaadin subwindow on mouseclick outside of the window?

左心房为你撑大大i 提交于 2019-12-04 07:56:25
I'm using vaadin 7 and in my application I use subwindows sometimes. In one case I have a modal window with several components in it. It opens another window when clicked on some of the components inside the modal window. I'd like this window to close automatically when the user clicks outside of it (e.g. on the modal window again). In the Vaadin Sampler this behaviour seems implemented when showing the source (click on the source button in the right upper corner). Also the behaviour should be the same if not opened from a modal window, but from the UI or any other subwindow. I tried several