Hi guys,
this is my first application (maven project) using vaadin, so I’m a little lost.
Basically, so far I have one class, MyUI.java like this one
[code]
package my.vaadin.apptest;
import com.vaadin.ui.AbstractJavaScriptComponent;
import elemental.json.JsonObject;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.JavaScript;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.client.ui.*;
/**
- This UI is the application entry point. A UI may either represent a browser window
- (or tab) or some part of a html page where a Vaadin application is embedded.
-
- The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be
- overridden to add component to the user interface and initialize non-component functionality.
*/
@Theme(“mytheme”)
@Widgetset(“my.vaadin.apptest.MyAppWidgetset”)
@com.vaadin.annotations.JavaScript({“https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js”, “script.js”
})
public class MyUI extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
layout.addStyleName("myLayout");//add class to main div
Label label = new Label("Hello Vaadin user. Use this application to upload files.");
final Button button = new Button("Open popup");
JavaScript.getCurrent().execute(""
+"jsInit();"
+"");
}
}
[/code]This class calls a javascript file that creates a popup. I need to move this functionality into a new class, so I created a new class, FileUp.java which sits in its own file. I removed what I needed from the MyUI.java and moved it to the new class, but of course it’s not working, and since I’ve never done this before I’m wondering if anybody could give a quick glance over to the new class, here it is:
package my.vaadin.apptest;
import com.vaadin.ui.JavaScript;
import com.vaadin.ui.AbstractJavaScriptComponent;
import elemental.json.JsonObject;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.annotations.Widgetset;
import com.vaadin.ui.JavaScript;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
@com.vaadin.annotations.JavaScript({"https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js", "script.js"
})
public class FileUploader extends AbstractJavaScriptComponent {
javascript.getcurrent().execute(""
+"jsinit();"
+"");
}
I get java errors:
-Syntax error on token “.”, { expected
-Syntax error on token “getcurrent”, identifier expected after this token
-Syntax error, insert “}” to complete ClassBody
Any advice as I’m not really sure what I’m doing wrong?
thanks
A few points:
-this new class doesn’t have a
@Override
protected void init(VaadinRequest vaadinRequest) {}
but does it in fact need one? I have no idea.
-DO I have to somehow update my pom file?