I am looking for some framework in java which can directly create html forms from database tables for crud operations on DB?
Spring Roo builds entities, pages and controllers based on Spring MVC,JPA. It can detect changes in the database. It is interesting that leaves no dependencies at runtime so, elements can be modified as regular Spring MVC elements, or you can add your own controllers, views, etc.
It has its limitations, of course, but it can be useful.
Would this work for you? http://incubator.apache.org/isis/index.html
Telosys Tools (an Eclipse plugin) can generate a full Spring MVC web application
from an existing database.
See the tutorials : https://sites.google.com/site/telosystutorial/
( if necessary the templates are customizable )
Maybe Spring Roo can help you:
http://www.springsource.org/spring-roo
http://static.springsource.org/spring-roo/reference/html/base-dbre.html
I think this is a big missing type framework in java. Roo works quite well, but it generates many files for each entity and seems to hava problems when you want to edit/remove some of them (at least it happened when I was trying).
I would like something like django admin, it should generate the page dynamically for each entity, probably with a view class describing the view.
For customizing a view even further it should follow a convention like:
views/domain/Entity.jsp -> replaces the whole view for the entity
views/domain/Entity_fieldname.jsp -> used as template for the field
Same thing for controllers, in roo there are many class that do almost the same thing. Why not use a default controller, and if the user defines a controller related to a entity, he could override the methods.
Of course this is not detailed enough, but I think pure java can improve a lot in making simple CRUD screens easy.
At least, this is the open source side. Inside business there are frameworks for CRUD, sometimes similara to this I describe. The hard part is making this framework decoupled from the other tools.
NetBeans can generate JSF pages based on your entities to do basic CRUD operations.
How-To: Generating a JavaServer Faces 2.x CRUD Application from a Database
try this:
barahisolutions.com/code-generator.htm
Its a Swing based code generator to reverse engineer databases and generate HTML forms ,entities,daos.
I have created a java based tool called Enfacade, that will generate CRUD screens from your DB tables.
The screens are data grid based and they will allow multiple grids to give one-to-many functionality.
You can then deploy to any java web application server using the runtime engine.
Related
I am trying to create web application that allow its users to create new forms and tables (many ERP applications have such feature). It is clear about generating and saving HTML forms and it is clear about generating new tables in database as well. But what about entities, e.g. Spring #Entity and #Repository classes.
One can try to compile then on the fly and save into the web application deployment directory, that should be possible. But is there need to update some kind of internal Spring registry of existing beans, repositories and controllers. Does Java JPA have such registry as well?
Is it possible to do such kind of thing? It is clear that it is possible to do this in php, e.g. to dynamically update yii framework application, because there is no compiled code (except, maybe, cached code) and with each new request the available paths are scanned anew. But how this happens in Enterprise Java and Spring applications?
Maybe I should look for Groovy Grails or Scala Play - they may be more dynamic languages.
More "object java storages" compatible with JPA (ObjectDB and Co) promise smoother, more natural migration with extra fields and classes. I haven't personal opinion.
EDIT: good perspective has, I think, philosophy ActiveRecord and similar. Few solutions in Java are ready. I have tried such solutions with partial success, but my project was not too dynamic (classes were stable) and we switched to clear JPA.
some ERP applications (in different languages f.e.C,Java.C#) have an idea "kernel class and additional fields", ie. Customer with all typical fields plus "Preffered color" (usually implemented in extra hidden tables). This is OK if they don't need new relations
Eclipselink has similar concept 'extra fields' in JPA area (not strict standard JPA but extension) https://wiki.eclipse.org/EclipseLink/Examples/JPA/Dynamic
At project level, seems to be OK enter non-critical data
3 Ist hard to imagine create high count of dynamic important/central classes (tables) without radically redesigned application (proverbially version 2.0 ;) )
Sometimes I try stop and restart EMFactory with different Persistence Units (in Tomcat environment) with Hibernate and Eslipselink, but not use in production. Reset & start seems be ok, this is like rupture and new life of JPA engine. Its more like application 2.0 than small patch.
Creating multiple gemmini table sets (for different companies in the same database) is good in Hibertate and Eslipselink (prefix before table name), few dedicated lines by start, normal clean JPA use. Tested, all OK.
Once again, adding single/few tables is poorly reworked in the community.
It is an interesting discussion to "glue" together common JPA modules (code+JPA), this is done often by OSGI programmers.
Theoretically so it has to module give your tables, strongly connected in the same PU.
At the ERP application level it can be anything from "add CRM module" to "kernel + sales".
I'm an interested spectator, but i have not seen any success.
If you look in the google integrate persistence unit from parts, composite persistence unit, many programers try to reach such target.
It is like a fishing rod rather than fish (as the old adage goes).
Persistence Unit conception isn't friendly for such ideas (and is blocked in standard JPA).
I'm learning Spring Roo and my purpose is to add some logic in generation time. In other words, I want to add some logic not to just generated project but with commands, before generation.
For example, standard things, like authentification, adding or listing entities can be done by roo commands. Imagine, that I want to modify list items page as the following - show only such entries which have even ID field. Also, I know that it's possible to add page mapping to custom page. But is it possible to preset this custom view with command line? I mean setting form action to generated handlers, ajax quesries - making view with command not by programmers' hands.
My understanding of Roo sounds like
Roo allows you only to rapidly start standart web app's parts but any complex custom logic should be implemented by yourself, after generation.
Is my understanding correct?
Important note - I understand, that generating business logic is very bad idea. My purpose is generating custom components with Roo which is already available but my custom components more custom than currently provided authentification+CRUD. So, I'm not going to generate enterprise application I just want to generate more complex components for future using it in other complex applications.
I want to be able to do the following - remove AOP from generated app, make it simple Spring MVC app, insert pre-hardcoded requestHandlers, JSP pages with POST/GET/AJAX requests to pre-coded requests. I know, that I can write simple program which simply opens .java file and inserts my pre-coded request mappings/handlers but is there any approach to do it with Roo commands?
You can create your custom Spring MVC add-on which generates all you want, as you wish. Examples about it are the add-ons for GTK or Flex.
So the answer is: yes but, to archive this, you must build your own MVC add-on. Also, if you do it, you could share it to community ;-)
Good luck!
I am trying to build a basic CRUD application with NetBeans 7.4, JSF, PrimeFaces and JPA using MySQL.
I have successfully done this by using the NetBeans wizards. I want to do this from scratch, no wizards.
There seems to be a lack of support for the combo of JSF, PrimeFaces and JPA. When I say "lack", I mean a full example (I might be asking too much), without using the CRUD auto-gen templates/classes AND shows actual queries coded and passed to the datatables(primefaces). YouTube is full of non-English speaking examples using Hibernate (not JPA) and other examples that show flashy GUI's with no code.
So far I understand you need an #Entity class (provides the physical build of the tables), a Controller (serializable) and the .xhtml web page to show the datatable.. what else? Also, I'm not seeing any posts or examples where queries are using with JPA/JSF and how they are tied together (in one place). I need to connect the dots here so that I can leverage JSF/JPA to create simple queries to populate my PF DataTables. I've read the blogs and I've googled the intranets until I'm blue in the face. Sending me a list of URL's to read to learn about each product is something I've already done. I get what they do independently, but am looking for the "How do they all connect" answer with maybe some basic code examples!! :)
Since version 11, PrimeFaces comes with a JpaLazyDataModel which you can use with your p:dataTable. In its simplest form to be used like:
new JpaLazyDataModel<>(MyEntity.class, () -> entityManager);
See also:
DataTable documentation on JpaLazyDataModel
Source code
I think this should help you:
http://www.tutorialspoint.com/jsf/jsf_tutorial.pdf
Tung
look.If you need an example about CRUD operation using JPA/EJB as Model layer and JSF as view layer,you can see the follwing example:
http://uaihebert.com/?p=834
also my own blog is based on many examples explaining this.These examples are using JPA2/EJB3 as model and JSF2 and primfaces as view you can see
http://jsfspotlight.blogspot.com/2013/05/jsf2ejb3-preparing-your-environment.html (this post for explaining how to prepare your environment before developing EJB/JSF Applications
http://jsfspotlight.blogspot.com/2013/05/ejbjsf-master-detail-web-application-in_25.html
(in this post i explain in details how to create EJB/JSF master_detail Application including what you need about connecting model and view layers)
explore the blog for more examples
Try this archetype which will create you an example and then check how it is implemented: https://github.com/ignl/happyfacescrud. You will learn about Spring, Spring security, Spring WS, JPA and Hibernate, Spring data and QueryDsl for easier querying, and custom JSF components which will make you very productive jsf developer.
I watched some videos, demos of Roo and I kind of liked it. However before starting using it, I'd like to ask few things more experienced programmers with Roo.
Roo uses lot of AOP. Is it okay to write custom Java code and let Roo generated files just "be alone"? Or does whole Roo structure require some AOP knowledge. In other words, if I want to customize Roo project (add non CRUD functions), do I need to mess with AOP?
I've seen console approach of generating entities. Can Roo convert my database that already runs into Roo code (generate entities for me)?
Sometimes I have big entities. I don't want to show certain columns to UI. Is this kind of customization easily achievable?
Getting current views - I'd like to do some exports of what user sees right now in UI (say to XML). Auto export would be great, but at least can I easily fetch current data in UI view? (say user is seeing 10% of data in DB table, I'd like to store them in XML)
My database often changes. How does Roo go by with changing entities? That's dynamically adding/removing certain columns ...
Importing data (or whole new databases). I need to drop&create database on-the-fly. So UI might change a bit (new columns) and data will change for sure. Will it work with simple "run script and refresh"?
Rollbacks. Undo any changes you did. Does it provide built-in support for such a thing?
Reporting or at least integrating with popular reporting tools.
So what do you think? Does Roo match these? Should I give it a try? Or am I better to start from scratch using say plain GWT, JSF, whatever?
OT: seeing this requirements, feel free to leave comment what kind of Java framework would you choose. I am now thinking of GWT (kind of know that), JSF or Spring Roo (no, I am not planning to write JavaScript UI myself) ;-)
Here are the answers per my knowledge of Roo:
1.Roo uses lot of AOP. Is it okay to write custom Java code and let Roo
generated files just "be alone"? Or
does whole Roo structure require some
AOP knowledge. In other words, if I
want to customize Roo project (add non
CRUD functions), do I need to mess
with AOP?
No, you don't need to mess with AOP. Most of the Roo generated files (like .aj etc.) can be "left alone" apart from the files where you will put some code.
2.I've seen console approach of generating entities. Can Roo convert
my database that already runs into Roo
code (generate entities for me)?
Yes, [check out the Roo reverse engineering steps][1].
3.Sometimes I have big entities. I don't want to show certain columns to
UI. Is this kind of customization
easily achievable?
Yes.
4.Getting current views - I'd like to do some exports of what user sees
right now in UI (say to XML). Auto
export would be great, but at least
can I easily fetch current data in UI
view? (say user is seeing 10% of data
in DB table, I'd like to store them in
XML)
Yes.
5.My database often changes. How does Roo go by with changing entities?
That's dynamically adding/removing
certain columns ...
Refer my answer to question 2.
6.Importing data (or whole new databases). I need to drop&create
database on-the-fly. So UI might
change a bit (new columns) and data
will change for sure. Will it work
with simple "run script and refresh"?
Yes
7.Rollbacks. Undo any changes you did. Does it provide built-in support for
such a thing?
No. There is no support for rollback. There is a feature request pending for the same. However, there are work arounds.
8.Reporting or at least integrating with popular reporting tools.
This wouldn't be any different than any of your normal Java application just because you use Roo.
So what do you think? Does Roo match
these? Should I give it a try? Or am I
better to start from scratch using say
plain GWT, JSF, whatever?
Hope the above answers clarify!
Is there any java cms for websites which uses spring hibernate annotation , which can make building sites easy.
Like user registration from with fields , login with spring security and some basic functioanlity.
Actually i am not sure what product i want but i will tell you the bsic requirement.
I am looking for something where i can select e.g registration form fields , login with spring security , user can edit those fields as weel .
forgot password thing , confirm email address and a model all java spring files are created automatically and from there i can add my new features.
Because these things are basic in every web application and there has to be easy method to generate those things
The Magnolia CRM (Magnolia Community wiki) has a module called Blossom that provides Spring integration for Magnolia. (That works for Spring 3 too)
Magnolia store its Content in Java Content Repository and not in a Data Base. That works very well for the cms content, because Mangolia provides a good Api for accessing it.
If you have your own business domain model and want to store it in a Data Base, you can add your JPA / Hibernate functionality like you do in "normal" Spring applications. (or like Sean Patrick Floyd suggested: invoke an other layer/server via for example Web Service).
I have running such a System (Magnolia, Blossom, Magnolis JCR, Spring 3, Hibernate) with a small domain model stored "outside" of Magnolia in a seperate Database, and it worked very well. (But at the moment I am thinking of integrate the Domain Database in the JCR, not because of technical problems, but to reduce the amount used technologies/systems.)
Anyway: Magnolia, Blossom, Magnolis JCR, Spring 3, Hibernate is worth to have a look at.
I don't think there should be one. Persistence Layer and Web Layer are two separate concerns, and it would be smelly to tie one to the other. The standard way to connect those two is through a service layer, and that is usually where the application's most important logic is. A CMS could simply not provide an abstraction that makes a service layer unnecessary without seriously restricting your application.
That said: Spring Roo goes in the right direction, it automatically creates Web Controllers from your entity classes. I'd say that's probably the best you can hope for.