I'm trying to call a javascript function from a java class in a vaadin project. In the past I've used an RPC call to do so, but this time it's only a js function that I need to call, and I thought I would be able to do it with something like JavaScript.getCurrent().execute("test()");
So I have a vaadin project and here is the class where I would like to call that function from:
package my.vaadin.project.vaadinUploader;
import com.vaadin.annotations.JavaScript;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
@JavaScript({ "https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js", "vaadin://js/script.js" })
public class UploaderComponent extends CustomComponent
{
final TextField name;
final TextField surname;
//final Label div;
final VerticalLayout formLayout = new VerticalLayout();
public UploaderComponent(){
formLayout.addStyleName("myLayout");
//div = new Label();
name = new TextField();
surname = new TextField();
name.setCaption("Type your name here:");
surname.setCaption("Type your surname here:");
formLayout.addComponents(name, surname);
}
}
The script resides in a custom folder but I'm not sure where it is that I can make the call to that js function as I seem to be getting an error all the time. Any idea?
as I seem to be getting an error all the timecare to share that error with us?public UploaderComponent(){ JavaScript.getCurrent().execute("test()"); formLayout.addStyleName("myLayout");as I had no idea where to add it in to be honest. Anyway I reckon the browser is expecting an RPC call, here is the errors in chrome console (I had to use pastebin as it's quite long)