Using Backbone.js with a RESTful Java Back-End

In a previous post, RESTful services with jQuery and Java using JAX-RS and Jersey, I demonstrated how to build a RESTful API using JAX-RS and Jersey, and how to build a jQuery application that leverages that API. The application used as an example was a Wine Cellar management application.

In follow-up posts, “Backbone.js Wine Cellar Tutorial” (part1, part 2, part 3), I showed how to add structure to the client-side of the Wine Cellar application using Backbone.js. But that three-part tutorial was provided with a PHP back-end.

By popular demand, here is a version of the Backbone.js Wine Cellar application powered by a Java / JAX-RS back-end using Jersey. The server-side of the application provides an example of building a complete RESTful API in Java using the different HTTP methods:

  • GET to retrieve and search wines
  • POST to add a wine
  • PUT to update a wine
  • DELETE to delete a wine

As already mentioned, the client-side of the application provides an example of adding structure to your JavaScript code using the Backbone.js Model, View and Router components. To learn more about the Backbone.js implementation, refer to the three part tutorial mentioned above: it is entirely back-end agnostic.

The source code for this application is hosted on GitHub here. It consists of the Eclipse Dynamic Web Project with the source code for both the Java back-end and JavaScript/Backbone.js client.

You can run the application (Part 3) here. The create/update/delete features are disabled in this online version.

77 Responses to Using Backbone.js with a RESTful Java Back-End

  1. Chandi January 13, 2012 at 7:18 pm #

    Hi Christophe, I’m an ardent follower of your tutorial apps. Have you considered knockout.js as an alternative to the Backbone.js + Mustache.js combination? The data binding in knockout.js seems very natural to me being a Flex developer. It would be great to see the Wine app refactored to use Knockout.js for comparison.

  2. s May 4, 2012 at 6:32 am #

    Could you please explain, where findById is calling in java application,
    when i changed from one product to other product it is not calling any function, even
    i opened the url (http://localhost:8080/cellar/#wines/1) in other browser and it was making call to findAll().

    Please explain me the purpose of findById.
    Thanks

  3. Personal Loan January 26, 2013 at 7:35 pm #

    Thank you for the good writeup. It in fact was a amusement account it.
    Look advanced to far added agreeable from you! By the way,
    how could we communicate?

  4. ashwin74268 February 12, 2013 at 8:14 pm #

    I am trying to return a JSON response with the same code but keep getting below error:-
    Method : find all Wines in Store
    Feb 12, 2013 3:14:30 PM com.sun.jersey.spi.container.ContainerResponse write
    SEVERE: A message body writer for Java type, class java.util.ArrayList, and MIME media type, application/json, was not found
    Feb 12, 2013 3:14:30 PM com.sun.jersey.server.impl.application.WebApplicationImpl onException
    SEVERE: Internal server error
    javax.ws.rs.WebApplicationException.

    I tried everything but it did not worked. Can youplease help me.

    • Logo May 22, 2015 at 7:54 am #

      Great article, and blog, alas… tried using it, it returns blank page and FF fire bug reports exception ‘a.replace is not a function

      • efactor diet review November 27, 2015 at 1:41 am #

        I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers…..

        • download gmod free February 20, 2016 at 3:05 am #

          This is really a amazing post. I couldn’t have asked for a much better post than this. I am literally very pleased with this and I just hope that I will keep on getting such amazing posts!

      • play garry's mod for free February 19, 2016 at 3:00 am #

        I love your own publish. It’s great to determine a person explain in words in the center as well as clearness about this essential topic could be very easily noticed. more information look at website

    • property in India December 9, 2015 at 2:43 am #

      A very awesome blog post. We are really grateful for your blog post.

    • Gmod January 12, 2016 at 1:33 am #

      I definitely have to update the assembly version in the config files now. Thanks for this..

  5. RD March 9, 2013 at 8:22 am #

    sir there is problem for running the application after done all the connection , and while running the application it looks only in heading tag as Welcome to Backbone Wine Cellar
    and one empty panel on left side,sir reply me fast the complete procedure for running application

    • poonam July 19, 2013 at 3:15 am #

      Did you get the solution???? Please help me..

      • blood November 27, 2015 at 5:41 am #

        Cold in the northern part of the world have the abilty to freeze your blood instantly

    • Gayatri November 1, 2014 at 1:14 pm #

      Hey just check the web browser developer tools for debugging and checking the error in the application. If its coming blank means either you have some problem in your connection string in the sql java code..

    • St Petersburg Stump Removal December 14, 2015 at 3:34 am #

      Really appreciate this wonderful post that you have provided for us.Great site and a great topic as well

  6. poonam July 18, 2013 at 7:12 am #

    Sir,
    There is problem for running the application after done all the connection , and while running the application it looks only in heading tag as Welcome to Backbone Wine Cellar
    and one empty panel on left side. My connection URL is:
    jdbc.url=jdbc:mysql://localhost:3306/cellar?user=root;password=root
    or
    jdbc.url=jdbc:mysql://localhost:3306/cellar?user=root&password=root
    I tried with both but no luck.
    Please help.
    Thanks in advance

    • Obiwan March 17, 2014 at 11:31 am #

      private ConnectionHelper()
      {
      String driver = null;
      try {
      Class.forName(“com.mysql.jdbc.Driver”);
      url = “jdbc:mysql://localhost:3306/mydb”;
      ResourceBundle bundle = ResourceBundle.getBundle(“mydb”);
      driver = bundle.getString(“jdbc.driver”);
      Class.forName(driver);
      url=bundle.getString(“jdbc.url”);
      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      public static Connection getConnection() throws SQLException {
      if (instance == null) {
      instance = new ConnectionHelper();
      }
      try {
      return DriverManager.getConnection(instance.url, “root”, “passw”);
      } catch (SQLException e) {
      throw e;
      }
      }

      • Piedmont Area Rocketry May 11, 2015 at 3:50 am #

        Great post, I have been talking with my friend about, .I would come back to you. Thanks for sharing. Thank you for your blog, very interesting, it’s very informative and useful article. And I guess that they having fun to read this post.

      • e factor diet reviews November 23, 2015 at 6:23 am #

        Thanks for share this blog it’s very helpful for me and, Welcome to the home of Sexy escorts in all over India, we have very excellent call girls, independent escorts in Ahmedabada.

    • latest offers May 29, 2015 at 6:51 am #

      It’s amazing to go to see this post and reading the views of all colleagues on the topic of this article, while I am also zealous of getting know-how.

      • theme August 17, 2015 at 7:19 am #

        I wish more authors of this type of content would take the time you did to research and write so well. I am very impressed with your vision and insight.

        • Hair loss protocol review September 8, 2015 at 2:57 am #

          Very interesting blog. Alot of blogs I see these days don’t really provide anything that I’m interested in, but I’m most definately interested in this one. Just thought that I would post and let you know.

          • free flat icons October 1, 2015 at 6:53 am #

            I was reading your article and wondered if you had considered creating an ebook on this subject. Your writing would sell it fast.

          • link February 20, 2016 at 6:02 am #

            I definitely agree with what you are saying. I have been talking about this subject a lot lately with my brother so hopefully this will get him to see my point of view. Fingers crossed!

      • Car Hire in Melbourne September 21, 2015 at 1:52 am #

        Very interesting blog. Alot of blogs I see these days don’t really provide anything that I’m interested in, but I’m most definately interested in this one. Just thought that I would post and let you know.

      • gmod free December 1, 2015 at 1:54 am #

        So happy to find good place to many here in the post, the writing is just great, thanks for the post.

    • FUMCO Youth July 10, 2015 at 6:45 am #

      These are usually the basic suggestions for successfully effectively successfully secured up delicate as well as problems together with excellent protection and also easiness.

      • plexus weight loss October 3, 2015 at 3:18 am #

        i love alternative treatments because it is simple and does not have nasty side effects*

      • panamaliving October 13, 2015 at 12:18 am #

        There’s a lot of folks that I think would really appreciate your content.
        Please let me know.

      • Treasures December 18, 2015 at 1:28 am #

        This is exactly what I needed when I moved to Dallas about a year and a half ago! I can’t wait to share this insight with newbies who I know that will be moving to the area!

    • the e factor diet November 24, 2015 at 3:09 am #

      I thinke that we neen to do more reseach on this polycystic my faimly has it and the kids my husban had it to there as to be a way that we can come up with somthing…

    • Team December 29, 2015 at 12:32 am #

      nice blog like this please visit there…

    • kik usernames December 31, 2015 at 6:11 am #

      This is really a amazing post. I couldn’t have asked for a much better post than this. I am literally very pleased with this and I just hope that I will keep on getting such amazing posts!

  7. Değişik Tarifler July 25, 2013 at 9:27 am #

    I’m an ardent follower of your tutorial apps, thanks…

    • www.perfectvisionone.com December 18, 2015 at 5:36 am #

      This is exactly what I needed when I moved to Dallas about a year and a half ago! I can’t wait to share this insight with newbies who I know that will be moving to the area!

    • ebookitsuccess.com December 19, 2015 at 5:46 am #

      I can give you the address Here you will learn how to do it correctly. Read and write something good

    • link February 23, 2016 at 2:43 am #

      Excellent stuff from you, mate. This is some great writing from your side. Without any doubt, this is the greatest article that you’ve submitted on this blog. how to get gmod for free

  8. rkoma August 27, 2013 at 4:47 pm #

    Hi,

    first of all I must say this is a great tutorial.

    However, I have tried to deploy this app on google app engine and it seems that there is a problem with REST API. Can anyone tell me is this a general problem with cloud storage? I am stuck with this Server error (500) for days…

    • garrys mod free November 25, 2015 at 5:49 am #

      It seems like many people are exploring the community for some offers. That’s a good try because the chance is so open in here.

  9. APC April 19, 2014 at 9:38 pm #

    You will have access to courses that will train you on how
    to use Quick – Books versions 2009 and 2010. Organizations does not have only one aspect accounting, there are many other aspects of an organization and as organization grow in size and business volume
    increases few more aspects come into picture or become very important like SCM, Marketing, Human
    resource, Multiple Inventory, SFA, logistics etc.
    Quite frankly, I don’t think I learned much other than bank recs, which I
    got wrong every month, and setting up a filing system for legal documents, where I color coded file folders and
    grouped them into hanging folders.

    • efactor diet review November 26, 2015 at 2:29 am #

      Thanks a lot for sharing this with all people you actually understand what you are speaking approximately!

  10. http://stephencrowder.weebly.com/ April 21, 2014 at 3:56 am #

    It is near the Glacier National Park that it will be is
    easy for you to visit the park also. Whether your kids are toddlers or teenagers, one Christmas classic is sure to please: The Nutcracker
    Ballet. ” According to Paisley Park Enterprises, the company that oversees most of Prince’s business interests, 3121 is a combination of floral scents and “mysterious” blends that capture the essence of Prince’s eclectic musical style and genius.

    • kik usernames December 31, 2015 at 1:57 am #

      Your posts are very interesting and very nice to read and write and gain more knowledge for students they needs to develop…

  11. Mehrdad April 23, 2014 at 3:07 am #

    It was better to use JPA instead!

  12. www.stephencrowder.weebly.com/ April 23, 2014 at 2:38 pm #

    Most people I knew from high school went to them all the time, but I wasn’t so
    lucky darn it. That’s why Japanese people have called him Prince since then.
    This is a perfect place for families to have
    their vacations as this little island offers a lot of paved and
    gravel roads for the hikers to enjoy.

    • link February 23, 2016 at 6:13 am #

      This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject.

  13. Rachele April 27, 2014 at 7:23 pm #

    Get a professional septic tank cleaning service
    to clean and empty the tank at affordable cost.
    There are also some requirements to meet, such as enough space and soil.
    This wastes a great deal of water as well as causes a constant influx of water into the septic system.

  14. Garland May 3, 2014 at 2:08 am #

    We have the lowest prices and the largest selection of seating for all Sports, Concerts, and Theater events.
    That’s why Japanese people have called him Prince since then.
    This is a perfect place for families to have their vacations as this little island offers a lot of paved and gravel roads for the hikers
    to enjoy.

    • real estate trends in India December 9, 2015 at 6:02 am #

      Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work

  15. Gayatri November 1, 2014 at 1:17 pm #

    hey Cristophe this tutorial and sample applictaion of yours was really helpful for me.

    I have one requirement. How can I integrate this application with my struts application when I tried to integrate it gave url resource mapping error. can you please help me out.

    Is it possible to use SPring or Strurts as backend instead of pure java classes???

  16. boogie February 12, 2015 at 12:24 pm #

    i will use js ..

  17. Laura Arango March 16, 2015 at 2:13 am #

    There is problem for running the application after done all the connection, and while running the application it looks only in heading tag as Welcome to Backbone Wine Cellar.. This is confusing me, Java tech not my style.. Thanks for support please.

  18. ali khan April 6, 2015 at 5:02 am #

    Google search engine and there are a lot of organizations out there in Internet area which declare to be able to get your web page more extremely rated later on. property valuation sydney

  19. FGJD FDJH April 14, 2015 at 4:10 am #

    If you are items or services based mostly company then you definitely must notify regarding the item, its costs and so on. polkadot.it

  20. Danielgrant April 21, 2015 at 8:00 am #

    Therefore, more variety of individuals is taking up the career, which in turn is improving the employment rate, and improving the quality of life of the individuals. link m88

  21. 123455 June 10, 2015 at 8:55 pm #

    1

  22. sree June 12, 2015 at 10:46 am #

    Hi Christophe,

    I am new to backbone and i have followed this tutorial and tried this application using Oracle as back end. Server response data is stored under following line

    this.model.models.attributes.wine // http://localhost:8080/app/wines

    instead of saving into following line

    this.model.models.
    i am mapping wines list data to this.model.models manually. please correct me to whats i am doing wrong here to get wines list json data into this.model.models.

  23. antrenman malzemeleri November 19, 2015 at 9:44 am #

    quality, reliable, cost-effectiveness and the associated jobs are done imalattan.profesyonel team

  24. Wilderness Adventure February 11, 2016 at 5:46 am #

    our blog content for the like phase! I am aware of this approach service plan which usually really helped others come up with all the truly! I mean, as to why might we have to suffer through wishing to come up with individuals Wilderness Adventure

  25. google February 16, 2016 at 2:49 am #

    Therefore, more variety of people is taking up the career, which in turn is helping the use rate, and helping the total well being of the individuals.
    Continue

  26. download gmod free February 16, 2016 at 5:48 am #

    Good Web page absolutely, you will discover some sort of several approaches right after visiting kinds submit.

  27. click to view website February 27, 2016 at 4:39 am #

    I desired to thank you for this exceptional read Thanks.

  28. go to my blog February 27, 2016 at 8:03 am #

    An important focus for SEO companies is to provide their clients with websites with some top top high quality information such as blogs and useful pages. go to my blog

  29. go to my blog February 27, 2016 at 9:44 am #

    I’m satisfied I situated this blog! Every now and then, learners want to perceptive the important factors of efficient imaginary content composing. see post

  30. gmod free demo March 2, 2016 at 2:36 am #

    I was about to say something on this topic. But now i can see that everything on this topic is very amazing and mind blowing, so i have nothing to say here.

  31. gmod free no download March 3, 2016 at 3:28 am #

    Therefore, more variety of individuals is taking up the career, which in turn is improving the employment rate, and improving the quality of life of the individuals.

  32. gambling for all March 28, 2016 at 4:18 am #

    I think this is a real great blog post.Really looking forward to read more. Keep writing.

  33. cross border investment planning May 2, 2016 at 9:11 am #

    I just found this blog and find the information on the ssae 16 audit very helpful. Keep up the great work, its hard to find good ones. I have added to my favorites

  34. rings for men May 4, 2016 at 6:57 am #

    Thanks for such an excellent post. It is such a pleasure to look forward to your blog.

  35. integrated wealth management san jose May 16, 2016 at 3:37 am #

    This is really a fascinating blog, lots of stuff that I can Get into. One thing I just want to say is that your Blog is so perfect

Trackbacks/Pingbacks

  1. Backbone.js Wine Cellar Tutorial — Part 2: CRUD - January 11, 2012

    […] UPDATE (1/11/2012): A version of this application with a Java back-end (using JAX-RS and Jersey) is also available on GitHub here. You can find more information on the Java version of this application here. […]

  2. Backbone.js Wine Cellar Tutorial — Part 1: Getting Started - January 11, 2012

    […] UPDATE (1/11/2012): A version of this application with a Java back-end (using JAX-RS and Jersey) is also available on GitHub here. You can find more information on the Java version of this application here. […]

  3. RESTful services with jQuery and Java using JAX-RS and Jersey - January 11, 2012

    […] UPDATE (1/11/2012): A version of this application using Backbone.js at the client-side is also available on GitHub here. You can find more information on the Backbone.js of this application here. […]

  4. Backbone.js Wine Cellar Tutorial — Part 3: Deep Linking and Application States - January 31, 2012

    […] UPDATE (1/11/2012): A version of this application with a Java back-end (using JAX-RS and Jersey) is also available on GitHub here. You can find more information on the Java version of this application here. […]

  5. Backbone.js酒窖教程 – 第1部分:入门 | Adobe CS6 - May 24, 2012

    […] Download a version of this application with a Java back-end (using JAX-RS and Jersey) on GitHub. Read about the Java version of this application in my blog post, Using Backbone.js with a RESTful Java Back-End. […]

  6. Backbone.js酒窖教程 – 第2部分:CRUD操作 | Adobe CS6 - May 24, 2012

    […] Download a version of this application with a Java back-end (using JAX-RS and Jersey) on GitHub. Read about the Java version of this application in my blog post, Using Backbone.js with a RESTful Java Back-End. […]

Leave a Reply

css.php