Thymeleaf vs Tiles - java

I plan to port a MVC app from Spring 3 to Spring 4 using Spring Boot.
This webapp use Apache Tiles.
I'm a bit confused considering Thymeleaf seems to be the new standard with Spring, with nice integration.
Tiles was a pain to configure in this app.
We've got like 20 JSP pages in this app.
Questions :
Does Thymeleaf and Tiles are similar concepts ? (template engine ?)
I've seen that Thymeleaf could be used with Tiles... I can't see how and why
Would it be better to keep Tiles and make it working with a Spring 4 / Boot application ?
Would it be better to port Tiles/JSP to Thymeleaf templates ?

I would suggest eventually porting Tiles to Thymeleaf, but you don't have to do it all at once.
Your intermediate strategy could be to start using layouts and integrating existing Tiles where it makes sense. New development can be straight Thymeleaf and you can fully port existing Tiles when it makes sense to you.
Please see the following article (you can jump to the "Thymeleaf Tiles Integration" section) and the associated example code on github.

Related

Is there any annotation based version for spring web flow?

I have been working on an infrastructure project that has a myriad of pages that used in numerous flow based scenarios. I eager to use a standard framework for facilitating this flows. I have a glance on spring web flow and I realize it is difficult to deal with all of the XML stuff like flow files. Could you please tell me is there an annotation base version instead of these XML files? Or Is there any other frameworks that use annotation based approach for this purpose. Moreover, I saw Seam framework, but like Spring Web Flow it has an XML based feature. Additionally, I read some articles about Netui Page Flows. Even though it has annotation based flows, as you know it is a very old framework and discontinued now.
I use this links:
spring web flow support in intellij idea 12
Spring Web Flow Ref Book
spring web flow
As I need this xml based file for create a web flow for my JSP pages into my enterprise application, after month looking for best solutions and frameworks, finally I find Spring Statemachine for my porpuse. I put that here for someone in future that looks for object-oreinted state machine that can be used in her/his page flow.
Thank you Spring :)

Spring MVC & Apache Tiles port to AngularJS/Backbone

I'm stuck with a mess of a web application. The previous developer started porting the Spring MVC/Apache Tiles application to Backbone, there wasn't a RESTful API to support the port however and it's stuck in this funky state where JSPs are rendering the HTML and some JS which then loads a Backbone View. About half the API has been ported to REST but the application is still far being a true SPA and even further from being done properly.
I've got a strong background in Angular and little with Backbone but next to nothing with Spring & Apache Tiles. The application either needs to go back to server side templating or be rewritten to truly become a SPA with proper organization/testing.
If I start (properly) porting to Angular or Backbone, is it possible for the two frameworks to work together (Spring / Angular or Backbone)? I've done a port like this in the past from Django to Angular on Google App Engine and it wasn't too bad but the application has significantly smaller. Has anyone done something similar to this, if so I've been unable to find anything on how to go about doing so or if I should even try.
Well, if you don't have a background in Spring & Tiles, it'll be difficult to learn & then port.
But if you're up for it :
1. Read about Spring (Dependency Injection & Configuration)
2. Read about Spring-MVC
3. Read about Tiles
Since, you already know about Django, you should be able to spot the similarities very soon. Once you become comfortable with Spring & Tiles, follow this approach :
1. Take a controller
2. Convert the JSP (which is returned by this controller) to a html template (used by Angular/Backbone)
3. Convert the model (data sent to the JSP) to JSON & start returning this JSON instead of the JSP
4. Create a route & test
5. Pick another controller
JSP is just a template & then model(data) is passed to create the actual html response, same as we do in case of Backbone (underscore template & then pass data to create the actual html).
This should be enough to start.

Is Spring webflow a good portlet technology choice?

I am working on a porlet app and it looks like the "main" portlet will be pretty complex, with some wizard-type functionality in it. I started with plain Spring MVC but it's clear that the backing controller will become very big and unwieldy over time (to my eye). I like to keep my classes small and static through the lifetime of an app.
I was considering the use of Spring Web flow, but a lot of the documentation on it seems to be from 08-timeframe - my question is, is this still a good technology choice for a modular portlet architecture? Is there a way to redirect to standard MVC in certain use-cases within the same portlet/mode..? I.e. to use SWF where it makes sense, but use MVC for other use-cases..?
Spring MVC supports portlets and so does webflow . We had an AbstractWizardFormController earlier in Spring for process ing data in a Step-By-Step approach which was replaces by Web flow . These store a Flow Id in every screen which decides the movement of the flow . Consider webflow if you have the following scenarios
There is a clear start and an end point.
The user must go through a set of screens in a specific order.
The changes are not finalized until the last step.
Once complete it shouldn't be possible to repeat a transaction accidentally.
As per the documentation here . It does support portlets. The portlet intergration reference is here . Check here for spring mvc integration .

How to nest views in Spring

I'm still just getting my feet wet with Spring, but am curious if it would be possible to somehow build a nested hierarchy of views. The goal would be to have a parent view/JSP with the header/footer of the page, and then have descendant views that would be wrapped with the parent.
Is this possible within the context of Spring's MVC architecture? If so, what my first steps be?
I recommend using Spring MVC with Tiles. You can configure a parent 'template' tile that contains your header and footer, then have each tile extend that template. You use the name of the tile as your MVC view rather than using the JSP as a view directly.
An excellent way to see how to use Spring MVC with Tiles is to create a project with Spring Roo. Roo is a developer tool that helps you quickly start new Spring projects. It will create a new web application for you with all the views using Tiles; and those views will be hierarchical like you describe. Even if you don't use Roo to create your final project, you should find it a useful example of how you can use Tiles with Spring MVC.
To roll it yourself, using <jsp:include> you can do this. You might have a controller for an entire page, and the JSP for this page will have one or more jsp includes that refer to other controllers that render further JSPs. These can use jsp includes all the way down.
See JSP-based Templating with Spring
... I opted for a 'home brew' solution only because the project would benefit more from lightness and simplicity of that. If I could be somewhat certain that my project will cross the line where another 'straight jacket' of a presentation framework would be beneficial that would be a different story.

Spring MVC vs JSF [duplicate]

This question already has an answer here:
Difference between Request MVC and Component MVC [closed]
(1 answer)
Closed 6 years ago.
I haved used Struts framework in all my past applications and for the new application,my client has requested to use either Spring MVC or JSF? I am not familiar with these two frameworks but our timelines are strict. So, I am not sure which framework I will choose to build the application.
Can anyone please suggest me which framework will be easy to learn in quick time?
Thanks
Of course, it's going to be different for everyone, but I'd suggest Spring MVC, as it's a request-based framework like Struts. Of course, you'll want to learn about core Spring stuff like Inversion of Control / Dependency Injection (but I'd consider that a plus...) and whatever you're going to use for database access (just JDBC? Hibernate? iBatis? etc.).
JSF is component-based, which is a bit different paradigm from request-based frameworks. If you do plan to go the JSF route, I'd suggest looking at Seam from JBoss. It's more of a front-to-back framework that uses JSF as the web/presentation end and EJB as the backend. And pretty much all the people who've used it claim it makes JSF and EJB more usable than they are by themselves.
Good luck on whichever technology you choose, though. (Sounds like you'll need it - strict timelines and a client that's prescribing web frameworks?)
I'd suggest SpringMVC, because of the timeframe:
you need something with less steep learning curve. SpringMVC is more like Struts than JSF
in order to use the power of JSF you need to get familiar with many "tricks", while SpringMVC is more or less straightforward
I'd suggest JSF + Primefaces component library. I am using this combination to build most of our projects. As I remember, I spent one week to learn the technology and finished my first project in one month. The development time at least 30% faster than Struts.
SpringMVC is not a bad technology and it's quite popular.
Really depends on which one your like the most.
JSF is just the view layer of the MVC and wil need to be used with other technologies like Spring/Hibernate or EJB for a full MVC.
I have been using the Spring MVC for about 1 months now, whilst it's probably not the latyest version of SpringMVC I've found it a little annoying that we have so much XML to deal with. All the managed beans and DAO has XML config to it. Also everything seems to have to go thorugh a method called onSubmit().
JSF with something like EJB is far simplier in my opinion... Everything can be done using Annotations so simply use #ManagedBean=theBean in your backing bean and in your JSF put {thebean.param} and you have access to the backing bean's data. Also you can use the Session beans of your EJB as the backing beans for JSF then have direct acces to the DAO (Model layer) Entity bean. Again simply by using the #Entity annotation and the EntityManager class
Spring MVC is a web framework inside the Spring framework. It does provide features as those in JSF 2.0:
ajax-support
validation
dependency-injection etc
Yet, you can use Spring (not Spring MVC) together with JSF 2.0, with spring providing the dependency-injection, aop, transaction management mechanisms, and JSF providing the web layer.
Of course, you'll want to learn about core Spring stuff like Inversion of Control / Dependency Injection (but I'd consider that a plus...)
JSF is indeed based on IoC, and much simpler than the Spring learning curve.

Categories

Resources