2013/10/25

Add jQuery to a Vaadin 7 application

To add jQuery (or any other javascript library) to a Vaadin 7 application, follow these easy steps:
  1. Create a Vaadin project either using your favorite IDE or the vaadin maven archetype (or both). Create a new class that extends from VaadinServlet, and override the servletInitialized method:
  2. Add the reference to the servlet in your web.xml or annotate the class with the @WebServlet annotation.
  3. Create your jQuery snippet and invoke it using the JavaScript class, for example:
You can download a complete example here.

13 comments:

  1. thanks, it helped a lot...

    ReplyDelete
  2. you can also use the @Stylesheet and @Javascript annotations. its much simpler.

    @StyleSheet({
    /*
    * JQuery UI
    */
    "vaadin://jquery/jquery-ui-1.9.2.custom/css/ui-darkness/jquery-ui-1.9.2.custom.min.css",
    })


    @JavaScript({
    /*
    * JQuery
    */
    "vaadin://jquery/jquery-1.11.1.min.js",

    /*
    * JQuery UI
    */
    "vaadin://jquery/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js",
    })

    public class MyUI extends UI {
    ...
    }

    ReplyDelete
  3. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me..Best Devops Training in pune
    Microsoft azure training in Bangalore
    Power bi training in Chennai
    .

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Good Post! it was so good to read and useful to improve my knowledge as an updated one, keep blogging. After seeing your article, I want to say that also a well-written article with some very good information which is very useful for the AWS Cloud Practitioner Online Training

    ReplyDelete