Scaffolding has been significantly rewritten to use a new static Metawidget. This allows Forge to output pure JSF tags, with no runtime dependencies on any non-Java EE libraries. The UI includes creating, updating, deleting, pagination and searching. It also supports one-to-many, many-to-many, many-to-one and one-to-one relationships:
<h:panelGrid columnClasses="label,component,required" columns="3">
<h:outputLabel for="customerBeanCustomerFirstName" value="First Name:"/>
<h:panelGroup>
<h:inputText id="customerBeanCustomerFirstName" value="#{customerBean.customer.firstName}"/>
<h:message for="customerBeanCustomerFirstName" styleClass="error"/>
</h:panelGroup>
...
<h:outputLabel for="customerBeanCustomerFirstName" value="First Name:"/>
<h:panelGroup>
<h:inputText id="customerBeanCustomerFirstName" value="#{customerBean.customer.firstName}"/>
<h:message for="customerBeanCustomerFirstName" styleClass="error"/>
</h:panelGroup>
...
Behind the scenes, Forge is still using the same Metawidget pipeline as before - the same Inspectors, WidgetBuilders, WidgetProcesors and Layouts. This means the scaffolding is pluggable to adapt to your needs - including custom UI libraries, custom layouts, even custom langauges (Ceylon, anyone?).
The new static Metawidget is also used to generate Java code for the JSF backing beans. Again using WidgetBuilders and outputting very clean code:
String firstName = this.search.getFirstName();
if (firstName != null && !"".equals(firstName)) {
predicatesList.add(builder.like(root.<String>get("firstName"), '%' + firstName + '%'));
}
String lastName = this.search.getLastName();
if (lastName != null && !"".equals(lastName)) {
predicatesList.add(builder.like(root.<String>get("lastName"), '%' + lastName + '%'));
}
if (firstName != null && !"".equals(firstName)) {
predicatesList.add(builder.like(root.<String>get("firstName"), '%' + firstName + '%'));
}
String lastName = this.search.getLastName();
if (lastName != null && !"".equals(lastName)) {
predicatesList.add(builder.like(root.<String>get("lastName"), '%' + lastName + '%'));
}
Please give it a try!
- Download Forge Beta4
- Install it
- Run it
- Copy and execute this command:$ run-url https://raw.github.com/forge/core/master/showcase/posale.fsh
9 comments:
Is this implemented in a similar manner to the GWT integration which uses some sort of compile-time code generation to workaround the lack of runtime-reflection in GWT? Also, I'm curious if SeamForge supports GWT?
There are a few dimensions to your answer:
1. The runtime GWT Metawidget, which works at runtime and does not use any static code generation: yes, it uses 'some sort of compile-time code generation to workaround the lack of runtime reflection'.
2. The static JSF generation (described in this blog): no, is purely a static solution, so it just generates normal JSF tags
3. Forge supporting GWT: not yet. Please get involved!
Regards,
Richard.
the download link doesn't work
Apologies. Link now fixed.
Richard, the UI looks really nice. I saw it for the first time while giving a demo of it (yes, you heard that right, preparation is a luxury).
I immediately appreciated the smooth transition from search criteria to creating a new entity. I've never seen that workflow before (that I can remember), and yet it felt very natural. The expandable form for creating a new related entity was also a nice surprise.
I was also pleasantly surprised by the select menu fields in the search query. Typically search fields are much less helpful. I can see dropping in a RichFaces component to get autocomplete for mile long lists.
Keep up the great work! The quality of your work is being more than noticed.
Thanks Dan for your kind words.
It's easy to do a nice job when the people you're working with make it so much fun!
Thx for the gerat post, the gerat implementation to get clean jsf code. Forke and metawidget is a great combination!
If not putting the metwidgets annotations into the bean (so no dependencies are in runtime) where shold I put some metawidgets layout hints for attributes/items (e.g. PlaceAfter, etc) during the scafford?
This area of Forge still needs a bit of work. https://issues.jboss.org/browse/FORGE-425 will make it much easier to hook into Metawidget. At the moment you will need to extend the scaffold plugin.
But, once hooked in, you can use metawidget-metadata.xml as usual. For more information, please take a look at the Metawidget tutorial: http://metawidget.org/doc/reference/en/html/ch01.html
Thx for you answer and the link. Just can proove what you mentioned there: "This idea of combining multiple Inspectors to inspect different characteristics of your existing architecture is very powerful!" Thats the right way foreward,
Post a Comment