Metawidget, and the work we're doing with the JBoss Forge team, has gotten a nice mention on the latest episode of the JBoss Community Asylum podcast. Here's an excerpt (taken from 35m.22s):
Max: "Right now if you download Forge right now, you get a JSF Metawidget thing"
Lincoln: "Right you get a default scaffolding provider we call them, and that one right now is using - like you said - JSF and Metawidget which we're actually working on the next version of, so that... right now when you run the scaffold it basically looks at your database objects, your JPA objects, it runs through them all and generates a bunch of view files for the Create, Read, Update, Delete operations. You know, a simple interface."
Max: "So this is kind of like what seam-gen did before, right?"
Lincoln: "Right. Kind of like that. And when you look at the output of the scaffold that you would download, maybe from Beta 3, you will see this Metawidget tag and Metawidget is..."
Max: "Yeah why don't you just tell what Metawidget is?"
Lincoln: "Metawidget is a really cool framework actually, it..."
Emmanuel: "We should interview... er... forgot his name..."
Max: "Richard? Richard something? Kennard"
Lincoln: "Richard Kennard"
Max: "Yeah Kennard"
Lincoln: "...it's a really cool framework for, basically you just point this tag at an Object or a bean and it runs through that bean and looks at all the properties and builds up an interface that shows up on the page."
Max: "Yeah, and in your JSF you just have one [line] and say this is the bean I want to do and it builds the UI. And it does it for... er... Swing, and..."
Lincoln: "You can do Swing, you can do GWT, you can do JavaFX I think. Lots of stuff."
Max: "So actually it is pretty powerful, but it's not..."
Lincoln: "The problem is then you've got this tag in there and it's... if you want to customize that then you're learning the Metawidget framework. And so what we are doing right now actually is we're customizing Metawidget so that, using the same inspection process that Metawidget provides, generate real code. Materializes it into real XML, real JSF pages. Then you can go in and modify those pages just like you would have done by yourself."
Listen to the full podcast here.
Friday, December 23, 2011
Monday, December 19, 2011
You Can't Spell Forge Without Metawidget
JBoss have just released Beta 4 of JBoss Forge. There are a host of new features in this release. Most exciting for me being the new UI scaffolding.
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:
The code it generates is very clean:
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:
Please give it a try!
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
Sunday, December 4, 2011
Pleasing Dick Wall
In Episode 371 of the Java Posse, Dick Wall has this to say about D.R.Y. (at 47m.30s):
"That actually, I hate to say, but it's an affliction that's very very bad in the Java world. And you see developers drop it as soon as they see another programming environment and really grok the idea of Don't Repeat Yourself. A lot of the flagship libraries in Java are really bad for this.
Wicket is one that springs to mind... everybody loves Wicket, [but] now I've been exposed to a bunch of different stuff I look at it and you have to repeat things 3, 4 or 5 times sometimes. When you're adding a field on to a Web page you've gotta name it on the page and then you come into the code and you write your handle on it with the exact same kind of component that is, and the name, and even worse, you know, taking the current Java mindset of 'you should be working for the compiler' and not the other way around.
If you get it wrong, it complains at you. It doesn't try and fix it for you."
This is, of course, exactly the problem that Metawidget is designed to address. I talk about it in my JavaOne video here (at 5m.30s).
Unfortunately work has stalled on the Wicket version while I've been working on JBoss Forge integration. Wicket actually makes completely dynamic controls, like Metawidget, tricky because of its approach of 'a Java file and a static HTML file'.
However, I was fortunate to have lunch with Wicket guru Juliano Viana at JavaOne 2011. He deep dived into the Wicket internals and found MarkupContainer.getAssociatedMarkupStream for me. It looks like this can free up the requirement of a static HTML file. So hopefully there is a way to get around this Wicket limitation.
"That actually, I hate to say, but it's an affliction that's very very bad in the Java world. And you see developers drop it as soon as they see another programming environment and really grok the idea of Don't Repeat Yourself. A lot of the flagship libraries in Java are really bad for this.
Wicket is one that springs to mind... everybody loves Wicket, [but] now I've been exposed to a bunch of different stuff I look at it and you have to repeat things 3, 4 or 5 times sometimes. When you're adding a field on to a Web page you've gotta name it on the page and then you come into the code and you write your handle on it with the exact same kind of component that is, and the name, and even worse, you know, taking the current Java mindset of 'you should be working for the compiler' and not the other way around.
If you get it wrong, it complains at you. It doesn't try and fix it for you."
This is, of course, exactly the problem that Metawidget is designed to address. I talk about it in my JavaOne video here (at 5m.30s).
Unfortunately work has stalled on the Wicket version while I've been working on JBoss Forge integration. Wicket actually makes completely dynamic controls, like Metawidget, tricky because of its approach of 'a Java file and a static HTML file'.
However, I was fortunate to have lunch with Wicket guru Juliano Viana at JavaOne 2011. He deep dived into the Wicket internals and found MarkupContainer.getAssociatedMarkupStream for me. It looks like this can free up the requirement of a static HTML file. So hopefully there is a way to get around this Wicket limitation.
Thursday, December 1, 2011
Metawidget @ JavaOne 2011: JBoss Booth Video
JBoss have posted videos from sessions at their mini-theater in the JavaOne Exhibition Hall. This includes our talk on DRY UIs: Let the metadata do the work:
The video is available in High Definition, so please try the Full Screen mode if you find the coding examples difficult to read. A very similar talk, given as a JavaOne conference session, is available on Parleys.
The video is available in High Definition, so please try the Full Screen mode if you find the coding examples difficult to read. A very similar talk, given as a JavaOne conference session, is available on Parleys.
Subscribe to:
Posts (Atom)