We have a server application that exposes a certain model, and set of services built on that model, to a particular client UI through a number of protocols. This is the kind of server application where, once it's set-up, there's not much manual intervention required. However, once in a while (particularly when the solution is first deployed), there will have to be some creation and linking of certain model objects.
This solution is built on Spring, Spring MVC and Hibernate (amongst other things) using JPA annotations for the ORM stuff.
My question: does anyone know of a framework that will allow me to very quickly set-up (ideally purely through configuration) a web interface to manage (CRUD) entities? This doesn't have to be fancy, and doesn't need to have fancy security (I can handle security from within the application server). It would however need to be able to handle complex relations between entities (collection mappings, enums, etc.).
For example: the application has an entity User, which has the typical Role entity associated with it (each user has 1 Role). Right now, the only way to define this without creating our own web layer from scratch is:
- Create SQL statements to import new users (and their roles)
- Have some kind of script (using Ant, for example) that uses the Spring/Hibernate configuration to associate and save a new Role() and User() object
Obviously it would be easier if we had a basic web interface (that we don't need to develop ourselves) that comes with the server to handle these kind of tasks (creating, updating, deleting, ...).
Naked Objects, OpenXava and Spring Roo, all can do what you are looking for.
Looks like LightAdmin pluggable administration interface for Spring/JPA based applications would be a good choice for you. It has a built-in Java DSL for interface configuration and the only thing you need to do is to download a jar or declare Maven dependency, enable your domain administration through web.xml (point to package containing your JPA entities) and create @Administration configuration for the entity.
Here is an example of configuration:
@Administration( User.class )
public class UserAdministration {
public static EntityMetadata configuration(EntityMetadataBuilder configurationBuilder ) {
return configurationBuilder.nameField( "firstname" ).build();
}
public static ScreenContext screenContext( ScreenContextBuilder screenContextBuilder ) {
return screenContextBuilder
.screenName( "Users Administration" )
.menuName( "Users" ).build();
}
public static FieldSet listView( final FieldSetBuilder fragmentBuilder ) {
return fragmentBuilder
.field( "firstname" ).caption( "First Name" )
.field( "lastname" ).caption( "Last Name" ).build();
}
I'd try Grails to do this. It's built for fast development of CRUD web applications. It's based on Groovy, Spring, and Hibernate.
To elaborate on @duffymo , Grails has a bootstrapping mechanism where you can insert the reference data you need on application startup. You can write the code such that you can detect if the reference data in bootstrap and only insert if you need it; its very hands off once its done.
Its particularly elegant in the code can detect the environment in which it is running on do different things in different environments, if you need to.
Finally, if you use Grail's scaffolding machinery, it will generate default Crud screens for you. You can have CRUD operations up in running in literally minutes.
For CRUD screens generation you can use Telosys Tools.
It allows to generate web app CRUD screens from an existing database model with customizable Velocity templates : https://sites.google.com/site/telosystools/
See the tutorials : https://sites.google.com/site/telosystutorial/ (you can use Spring MVC + JPA for example)
来源:https://stackoverflow.com/questions/4479828/spring-hibernate-entity-management-web-interface-ui