How does one go about customizing the GWT user interface that Spring Roo automatically generates?
Am I supposed to change the Roo-generated source files? If so, will that not be clobbered the next time Roo runs?
Or do I need to configure something in Roo and then rebuild the GWT sources?
In this particular case, the column widths of the domain object list view need to be adjusted.
For as far as I know, this is indeed not possible yet in Spring Roo. As you rightfully stated, the by Spring Roo generated files will be regenerated by Spring Roo when you alter your entities. There are some solutions, but these all are but small workarounds and don't offer the actual programming experience you'd expect or want. The Spring Roo team (and community) has already addressed this issue though and is working hard to solve this. So expect this to be improved real soon. For more information, check the following links to the Spring Roo Forum and Spring Roo JIRA:
Spring Roo Forum thread: Roo GWT customization
Spring Roo JIRA issue: Roo update is too destructive
Spring Roo JIRA issue: Manual Created Request Interfaces get deleted
May I humbly suggest Metawidget? It generates Spring MVC, GWT and other interfaces at runtime, so there is no regeneration step (and nothing to get 'clobbered') as your entities change.
If you want to modify a ui.xml file generated by ROO, just rename it and refer to it in the .java file.
e.g You want to modify the file PizzaDetailsView.ui.xml:
Rename it to PizzaDetailsViewPrime.ui.xml
Then add this line just before the interface Binder declaration:
#UiTemplate("PizzaDetailsViewPrime.ui.xml")
Related
Please advise me a project where I can see how to use Spring MVC and Hibernate together in the right way. I'm new to these frameworks.
Appfuse has a Maven archetype for this stack.
Strongly suggest you have a peak.
Alternatively the book Spring in Action was a great resource for me in learning spring and hibernate/spring interaction - use Annotation driven transaction management as well and you have a really great start.
see here: http://appfuse.org/display/APF/Using+Spring+MVC
appfuse-basic-spring is the basic project archetype.
Using maven modules is a better practice. ie)
appfuse-modular-spring
If you install m2e (maven 2 eclipse plugin) creating a new maven project will allow you to select the archetype.
better answer:
If I was going to recommend HOW to learn these technologies, I would say learn how to build a hibernate/maven/xml project first by following this:
http://www.mkyong.com/hibernate/quick-start-maven-hibernate-mysql-example/
Then learn how to use spring for dependency injection with maven/hibernate and xml:
http://www.mkyong.com/spring/maven-spring-hibernate-mysql-example/
Take special note of layering of the bo/dao pattern and how you use interfaces but wire in implementations with spring di - this is crucial for writing quality code
Next check hibernate annotations and annotation driven transactions:
http://www.springbyexample.org/examples/hibernate-transaction-annotation-config.html
http://www.springbyexample.org/examples/hibernate-transaction-annotation-config-code-example.html
http://www.mkyong.com/hibernate/maven-hibernate-annonation-mysql-example/
Finally, you can learn your mvc framework of choice. I actually recommend struts2 but it won't matter much. use spring DI by implementing interfaces and wiring implementations at runtime for you actions/controller. If you don't understand this how, you will after the hibernate/spring tutorials. Spring in action will be a good reference to keep on your desk but will take a few weeks to digest as you learn. Good luck! You can do it - I did and am now working as a java dev!
the petclinic app includes these, and many more things
spring-roo can create a skeleton project using these technologies for you.
If you are new to Spring MVC and Hibernate, I advice you to follow the Spring MVC step by step guide. The only problem with this is the version, the guide uses version 2.5 and the current release is 3.1.x, but it's a very good starting point to accumulate knowledge.
Spring MVC quickstart archetype provide simple spring-mvc and hibernate configuration.
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.
For instance, I am using JSF + custom framework developed in our company. Now I want to use a third party validation framework that can be used as an plug-in and it should not create any dependency what ever may be the technical stack.
So my question is does spring provide any framework of that sort or if it's available how can I use that?
I am expecting a validation framework something like, which is configurable through XML.
Spring does have a validation framework, but if you want minimal dependencies, then I'd suggest that you go with a Bean validation provider. It's a new(ish) official validation standard, defined in JSR-303.
There are several implementations at the moment. I'd give Hibernate Validator a look.
I disagree. Hibernate Validator is an awful piece of software (at least the versions that were current about a year ago). Spring Validation is a nice piece of software, that goes together well with the BeanWrapper interface.
But it's true: Spring Hibernate resides inside the Spring Context jar, which is unnecessary overhead. Hopefully there will be a separate version sometime.
I am experimenting with Spring Roo in a new GWT application. The Spring Roo GWT support is some way off ready for real use just yet, so I want to build the GWT stuff by hand using as much of the GWT 2.1 MVP stuff as possible. The problem I have is that Spring Roo "notices" my MVP-related classes and generates a whole lot of extra (broken) stuff for my entities.
How can I get Spring Roo to ignore the GWT side of my project?
"I want to build the GWT stuff by hand using as much of the GWT 2.1 MVP stuff as possible"
If you're building GWT by hand, it sounds like you're interested in using Spring Roo to generate your data model code — but don't want (or need) any of Spring Roo's web controller code. If that's the case then you can separate your project into two modules:
A module containing model and persistence code that is created by Spring Roo
A GWT web application that you create by hand.
Make the first (Roo) module a dependency of the second (GWT) module. Basically you're using Roo to create a JAR library that's used by your web application. As long as you don't run the controller command the Roo won't add any web application code to your module.
I renamed my gwt.scaffold package to gwt.shell and gwt.request to gwt.req and Spring Roo is leaving my stuff alone.
What if you don't want to start a separate project for grails but instead sneak it into an existing webapp?
I have to build an admin interface/crud for some new entities and thought it would be a perfect way to learn grails.
I'm trying to make one application with a Grails app and a Spring app.
I've tried to sneak the Grails App into the Spring one, but this is "impossible". It's easier to sneak the Spring app into the Grails app. Grails knows what Spring is, but Spring has no idea of what Grails is.
In this article you can find useful information about how to use your hibernate mapping files or annotations in Grails, so you don't have to remap everything. Also you can use all your java clases (put them into src/java). You can put the beans defined in the ApplicationContext.xml in conf/spring/resources.xml. You can leave them in ApplicationContext, but I've had some problems.
I don't have ended the job (almost) and it looks good.
It would be hard to "sneak it in" unless the existing app has the correct dir structure that maps exactly to how grails likes it - after all, convention over config is where the power of grails comes from.
You can try doing the admin interface as a "seperate" app to the original/existing spring app, and map the existing database to the grails domain objects. though i m not sure how you would run them side by side easily without more information on the existing app. It is possible definitely though.
I agree that building your admin interface is a good exercise to learn Grails, and also agree with the previous answer that Grails is difficult if not impossible to integrate with an existing Spring application. You could probably get it done, but the headache would not be worth it.
Grails is built on top of Hibernate for its ORM, so if you're already using Hibernate with this Spring app you can work this to your advantage. It's not too difficult to configure a Grails app to use pre-existing Hibernate models, and this is explained well in Grails documentation.
So, I'd recommend building up your admin console as an independent Grails app but make use of the Hibernate models you already have, if in fact you've used Hibernate.