Spring boot and vuejs web app implementation approach - spring

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.

Related

Spring Boot, do I even need a model with vuejs?

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

Spring MVC view technology: what to choose?

I want to create web-site with Spring back-end, but I can't choose what view technology to use: JSP, Velocity, or I should try to integrate JSF with my app. Which of this technologies is the most popular?
Looks like that JSP is a quite deprecated technology, but I hasn't found a proof of this thesis yet. Should I learn JSP, or try some another framework?
I´d use JSP+JSTL+Tiles, but mainly because everybody knows them. I could consider to use Freemarker or Velocity (Specially the first). However, I think Spring MVC and JSF are technologies that overlap, and using them together could be useless and dangerous.
I recommend you to take a look at this: http://docs.spring.io/autorepo/docs/spring/3.2.x/spring-framework-reference/html/view.html
And also at this: http://ihatejsf.com/

Reusable component in SpringMVC

I'm coming to SpringMVC from the world of PHP, precisely I was working with Symfony for several years.
For your information, in Symfony, there are plugins and bundles that are created by other developers so that you could use them in your project. When I come to Spring, I don't find these notions or may be I've missed something !?.
For example, I'm looking for a component that does the registration and login form, which I think that must be done many times already, and I don't want to reinvent the wheels certainly.
So, my question is, I wonder if in Spring, are there possibilities to have and how to use reusable components?
Authentication is directly supported by the Java EE spec. You don't even need any particular framework for that. Every web container supports it out of the box. If you want some additional functionalities (like remember-me, etc.), loot at spring-security.

Spring MVC 3 and Ajax library advice

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.

Spring MVC View

What are you guys using for your view in Spring MVC.
I know Spring MVC has a wide support for views but I'm having trouble finding what works well, what view to use when, etc.
Any insight would be great!
JSP, of course.
Sometimes PDF; Excel when necessary.
BlazeDS makes Flex integration with Spring possible. That's a great way to go if you use Flex.
"...I'm having trouble finding what works well..." - they all work well from Spring's point of view.
What to use when? Use the technology that you know best. Spring can deal with all of them just fine.
UPDATE: Since this was written three years ago, I'll amend it by saying that I would recommend just using Velocity templates to marry with dynamic data. Templates should use HTML, CSS, JavaScript, and jQuery. I think that provides the best flexibility you can have. You "future proof" your design if you can generate responsive HTML 5 pages.
We are using the following templating languages
Apache Velocity: Most of our old projects are using apache velocity to render the view. This is a very easy to learn and use language. But here xml operations are very limited.
Freemarker: Now we are migrating our project to Freemarker. This is a very good templating language. Advantage over velocity is that it has a very good support for xml data processing
You can use jsp with struts tiles to give good and uniform experience. You can refer to "Spring in Action" Book to find out how to do it. I have used this combination for developing my website www.propertymela.net. Have a look.
I am using Thymeleaf, because it has static prototyping which is very useful when there are two teams doing web design and server side development. I believe JSP is a fairly old technology, and I've had some problems with using HTML5 with it, which is why I opted to use a different view technology.
Also, Velocity is a competitor of Thymeleaf but I haven't really touched on Velocity aside from creating email templates.
JSTL is my option. JSTL has all the functional component which we can achieve through the use of scriplets in JSP. The avoidance of the scriptlet code in JSP is key to move into JSTL
In scriplet code if anything wrong whole page breaks. But it is not in the case of JSTL

Resources