From Vaadin pages / foorum and google tutorials I have understood that I should be able to call Java-function from hand writen JavaScript using this method:
You can only call Java methods that are compiled to the client side part of the application (GWT widgetset). And GWT expects all client side classes to be found under package named *.client, with the widgetset XML file residing before in the hierarchy:
com
example
vaadin
MyWidgetSet.gwt.xml
client
MyUtilityClass.java
Thanks for the reply and pointing me to right direction.
Now Im able to get my classes compiled atleast. But Im still having problem. I cant get call to my Client side Java method to work from hand writen JavaScript.
I used Vaadin Eclipse plugins “Create Widget” functionality. And named my widget to MyComponent.
Now I have client side class VMyComponent.java and server side class MyComponenet.java.
I added previously mentioned exportStaticMethod()- and computeLoanInterest()- methods to VMyComponenet class and call exportStaticMethod()-method from VMyComponet classes onLoad()-method.
Widget works and it counts my clicks and shos the count at client side.
From hand writen JavaScript Im trying to call computeLoanInterest() just by running alert(‘Works:’+computeLoanInterest() )
Im doing something wrong but dont know what. Im totally newbie when it comes to Vaadin. Any fast ideas what Im doing wrong?
Now it works. My problem was that I had added my Widget to TabSheets second tab. And When Vaadin application was loaded I tried to call My Widgets method from JavaScript at applications init metod.
Because widget was at second tab it was never loaded during application init, thus method was never registered. I moved widget to first page of my application and now it got loaded before I called its function from JavaScript.