Is there any annotation based version for spring web flow? - java

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 :)

Related

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 .

Struts + Spring + Hibernate integration

For example, we have the next bunch: Struts, Spring, Hibernate. Can you help me understand the role played by each of the elements?
I know that Hibernate is responsible for all on the database.
But, what role Struts and Spring in this case?
Thanks.
Struts is web application framework - used to give you the possibility to expose your application through web interface without dealing with low level classes. When using struts you should be careful as there often bad advices on using you application logic inside struts classes. Don't do this, struts is just web front-end.
Spring is general application framework that in first place helps you decouple classes from one another using dependency injection. But this is not the only reason for using spring, it provides tons of other features: http security, aspect oriented programming, out-of-the-box integrations and support of different frameworks. So this gives you a fast start on using different technologies.
Hibernate is object relational mapping. Using it you map your classes to database relations and avoid working with SQL requests.
My guess:
Struts is used for presentation purposes. Spring is used for AOP, and Depency Injection. Hibernate is obvious: persistence.
Spring:
Dependancy injection
Transaction Management.
Open Session in View Filters
Spring Security.
or in other words nice clue to between application layers.
Struts:
Model and view Design pattern.
Simplifies web flow.
Struts is for webapplication preparation. It has great form validation f/w, and tiles f/w to create webapplication in a great way.
Spring has 6 modules. It provides abstraction on the java-j2ee application. Spring MVC provides abstraction for struts.

Does Java Spring 3.0 MVC support annotation/attribute based client side validation like Asp.net MVC 2.0?

In Asp.Net MVC 2.0, at least in the beta, you could decoration your model classes with data annotation attributes and enable client side validation that leverages that criteria defined in your model data annotation attibutes. Is there anything similar for Java Spring MVC 3.0?
Is it possible to inject a component into the response pipeline that can inspect the model's annotated properties and render client side validation logic to complement the server side validation logic that is invoked prior to the controller handling the request?
Actually, there is something a little bit like it, based on the JSR-303 Bean Validation spec, which is now final and fully supported by Spring 3.0.
Recently, as part of Spring Webflow, Springsource has released Spring JS (javascript) which uses Dojo. You can use that for your client side validation. Check out this howto
Obviously, component-frameworks such as Wicket (like fraido mentioned) have better support for this kind of usecase. So if you have to implement a lot of similar usecases, that is probably a better fit for your project. However, if it is sporadic, Spring JS / Bean validation could be the way to go.
Spring MVC is a fairly low level framework. It doesn't extend to doing client side validation.
There are other Java Web frameworks that do this such as Tapestry, Wicket and JSF (IceFaces, etc). These are what I tend to call "component frameworks".
In Spring MVC 3.0 there's nothing like that at the moment. As cletus said frameworks like Tapestry (ex), Wicket (ex) and others have some sort of Client Validation that uses JavaScript to validate forms etc.
You can write your own validation Jstl taglib maybe with the help of a JS Library (jQuery, ...) and Plugins like : jQuery Validation Plugin
edit: I've just found this: Mediawidget. Maybe it's worth having a look.
It says: "Metawidget reads Bean Validation annotations and generates forms with
widgets that are pre-configured for minimum/maximum values, lengths etc."
Spring integration Link1, Link2
This project looks to be exactly what you're looking for: http://kenai.com/projects/jsr303js
2011-12-06: I'm just about to try it myself
2013-12-09: Update on this answer: I did try the library out, and it worked very well. It needed some tweaking (it's a prototype patch for Spring, not a finished plugin), but it was the best solution I could find at the time. Perhaps there is a new solution, or perhaps someone has finished off this prototype since I posted? If not, I can recommend this one.
Ok, this is a variation on what's already been said, but one of the big strengths of Spring-MVC is its ability to integrate with other libraries, like the different JSF variations that do give client side validation.

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.

Can anyone recommend a Java web framework that is based on MVC and supports REST?

We are looking to host a Java Domain Model (written using DDD) inside a web application. Ideally I would like to support RESTful resources and requests, having a single site to support both users and a REST api.
Ideally the same url could be used for both end users and the RESTful API of a given feature (with HTTP content types / negotiation specifying the difference).
I have done similar apps in Ruby on Rails and Asp.mvc, but have no experience doing anything like this in Java. Anybody have an experience or advice on where to start ? (Googling suggests that Spring v3 might be an answer, anybody have any thoughts on Spring 3 ?)
Spring 3 is not quite ready yet, but the current milestone build (M3) is stable enough to use for real. We're using its REST support in a production application already. It's pretty goodm, and integrates very nicely with Spring MVC. It's not JAX-RS compliant, but I don't see that as a problem.
Restlets Framework http://www.restlet.org/
I've used this framework extensively, easy to use, really flexible and supports loads of features and more you'd expect from file upload to gzipping responses.
This module has Spring support too, really easy. For example:
web.xml
<servlet>
<servlet-name>webapi</servlet-name>
<servlet-class>
com.noelios.restlet.ext.spring.RestletFrameworkServlet
</servlet-class>
</servlet>
spring context
<bean id="root" class="org.restlet.ext.spring.SpringRouter">
<property name="attachments">
<map>
<entry key="/{variable}/your/restful/call/{variable2}">
<bean class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource" bean="yourBean" />
</bean>
</entry>
</map>
</bean>
Framework also has a great documentation, first steps for newbies and a great WIKI.
This framework is very mature and actively improved, checkout the up and coming features.
It's also very easy to unit test your Restlet Resource endpoints using jmock.
Hope that helps.
For web services, Jersey is nice and easy. Spring 3 sounds like it will be good, but it's not out yet, and Jersey is full featured and supports SOAP and JSON out of the box. It's all annotation based aside from adding the servlet to your web.xml file which makes it probably easier to configure than even Spring plug-ins, but to avoid getting yelled at, I'll say maybe not.
For (MVC) web pages (user UI), I use Spring MVC or Struts.
Spring is great. I've used it for some projects and recently also together with Liferay portal server for developing a portlet.
Why is Spring good?
It is a non-invasive framework: This means your application code doesn't depend on the framework (uses the IoC - Inversion of Control - concept). Spring does just what a good framework should do: support the development and not create further dependencies.
Dependency Injection: Spring uses the dependency injection concept which is great for avoiding dependencies on your code. You will define the dependencies in a spring xml configuration file where you define your beans and connections/relations among beans. This greatly facilitates reuse, lowers strong coupling among your objects which leads to better maintainability of your code.
It's not just a web framework: Spring MVC provides a lot of different controllers which are suitable in different contexts. But it isn't just a web framework but it supports the development on all the different layers (presentation, service and data access layers). For instance on the data access layers it nicely integrates with ORM mappers like Hibernate and it uses Aspect-oriented approaches for providing transaction management.
Lower-coupling -> increases testability: By avoiding strong coupling, the testability of your code will be increased. You can nicely inject mock objects for testing the different layers.
All in all, I just had positive experiences, because Spring really promotes best practices.
I m a monorail MVC user ( castleproject.org), so i guess we come from a similar background.
A few months ago we started working on the java stack in a different project, particularly with Spring.
Feature wise it s got 90% of what I m used to in monorail, however It is much more flexible, the downside to that is that there is a lot of configuration to get used to.
Documentation is extensive sometimes too much so you dont know where to find something.
Hope it helps

Categories

Resources