I'm having trouble understanding and then deciding how I want setup the frontend of my spring boot application. My question is do I even need thymeleaf or rather do I lose something if I only use vuejs?
First things first I am mostly into backend stuff and barely know a lot about current frontend technologies etc. However I tried out vuejs and liked it a lot.
I used to use thymeleaf and serve static html pages with thymeleaf markup. After playing around a bit with vuejs I want to use that instead.
So far I've managed to set it up two ways:
I keep thymeleaf and use it together with vuejs. This allows me to keep the model that I can pass in my view controllers.
I only use vuejs and get all information through REST from the spring boot app. However I am asking myself if there isnt a way to access the model from here? If that would be the case I wouldnt need thymeleaf right?
I really think that I'm having some kind of architectural misunderstanding and would appreciate it if I could get it cleared up.
Thank you in advance
Related
So I Want to build projects using spring Boot directly as I'm under a bit of time crunch. Please help me out.
What you need to know about JSP: nothing. JSP is old and clunky, use Thymeleaf instead. But if you're building single page web apps you don't need any templates, you just need to know how to accept and return JSON.
Servlets: you need to understand the threading model, that there's only one servlet being traversed by multiple threads, and any instance variables will be accessed by all the http request threads. More than servlets you need to know filters, because Spring Security uses them.
I wrote a spring boot application and I want to use Vuejs for the front-end. I found online two ways to do this:
1 - store my html+vuejs in the resources/folder and use Thymeleaf and a controller to serve them.
2 - expose my spring rest-controllers and have my Vuejs application running separately and accessing the rest-api.
My question is: what is the difference between both approaches? and what approach is the most common?
Both approaches are equivalent it's just a question of choice.
With thymeleaf you work with HTML/CSS/JS in and old fashioned way : you write your HTML, your CSS (or use your prefered css framework) and probably use jQuery as you know how to use it.
With VueJS things are a little complicated at first. You should learn a standart like ECMAScript (which will compile in to JavaScript with the help of Babel), the integration with your favorite css framework will be a litlle more complicated and the use of plugins is very different than you would do it with jQuery.
So it depends, if you want to grow as developer, learn some fun things and be "on top" you should take a look on VueJS but if you just need to "send something fast to production" you should make it with thymeleaf.
But let me underline that you can make everything you want with both approaches.
I've been trying to implement a sever-side pagination for my project using Spring and Thymeleaf, I was able to read things about how I can make this posible, one is through the use of dandelion datatables wherein I was able to make the integration successful but only in the client side. The second one i tried is using an example I found at http://www.opencodez.com/java/datatable-with-spring-boot.html which was successful but was a bit complicated. Other examples I find are from this and other sites are old, I need a recent example on how I could implement server-side pagination in Spring using thymeleaf and JPA. It would also a big help if it would involve the use of JQuery datatables because of its features.
I was able to do this with Spring-Data's pagination and the Thymeleaf dialect here https://github.com/jpenren/thymeleaf-spring-data-dialect/
Should do exactly what you want I think.
I'm developing a webapp with Hibernate+Spring 3 (Spring MVC, JSP): I'd like to create some divs with AJAX style (i.e. no need to refresh all the page, independent update of each div).
I'd like a good advice about which AJAX library to use (in conjunction with Spring 3 MVC + JSP) and, if possible, where to find some code snippets.
I know very little of AJAX libraries, JSONs and how to integrate them, but I have good knowledge of Javascript and Spring (and how callbacks work). I'd like to write as less code as possible, particularly in the jsps.
My Webapp will display an updated (every 5 minutes) POJO in a div and perform some operations between different domain objects in the other div when user press a button.
This is correct use JQuery
Here
http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/
you can find working examples to use Jquery+JSON+Spring MVC.
and this question can help you with server side configuration:
JQuery, Spring MVC #RequestBody and JSON - making it work together
I would suggest jQuery. It is very easy to use and has very good ajax support.
In addition to that it has quite a lot of plugins and components.
I am new to Spring as well as Dojo. I need to use Dojo with one of my mvc project in Spring 3.0
I came accross below link which talks about using spring-js with Dojo.spring-js part of spring framework?
http://static.springsource.org/spring-webflow/docs/2.0.x/reference/html/ch11.html
I could not really follow that link, is there any step by step tutorial which will show me how to use dojo with spring framework 3.0 ?
I need to start with simple things with Dojo like client side validation of forms.
Thanks in advance!
This is a tough question to answer, because it turns out you don't really need to worry about how Dojo and Spring interact. Your client and your back end server are completely unrelated until you decide to send data back & forth.
So for dojo, you probably want to look at how to use some of the form validation. Take a look at this link for some help on that:
http://o.dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/form-validation-specialized-input
Once you have some validation in place, your form can use the normal form post to post your data to the server, same as how you would do it without javascript.
On the other hand, if you want to add some nice Ajax to your application, take a look at this link which explains how to implement Jackson marshalling/unmarshalling to send JSON data to Spring & handle responses correctly.
http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/
Spring Roo uses Dojo, so you can create a Roo Project and have a look like they did it.
For Spring, You can follow this tutorial (Its the most compact and covers all basics):
http://www.tutorialspoint.com/spring/index.htm
And for Dojo The best tutorial is at: http://dojotoolkit.org/features/desktop
(in Create Beautiful User Interfaces subheading youll find all the APIs and their examples)
Its the way I learnt it. :)
Cheers