Posts

javafx, wow, it's still kindof hard

I've been looking to do a real UI in javafx and compared to WPF, I am still finding it to be alot of work. In particular, creating tables and customizing everything for my domain objects. In WPF, I built a reasonably interesting interface in 5 days without knowing WPF and that includes working on the domain object. In JavaFX I am finding it slow going on doing controls that need cell factories and other apparatus that apparently is only available to be created through code, XAML was just easier for me. I wrote almost no UI code in WPF. I did write XAML files directly in XAML because they had a nice editor that showed you the results of your XAML file as you typed it. The JavaFX team really needs to sit down and crunch on making it easier to build UIs and bind to my domain objects to get the content into the controls. I do not think its an issue with the relatively complex Callback interfaces either. I think its because they are not thinking of how to create something easy to ...

groovy and javafx 2.2: MapChangeListener

javafx does have groovy support through groovyfx (or something like that). But here's another small way to help tame some of the large API base in javafx with some groovy help. Take listening to a map. Since I store alot of resources in the Node's maps, I need to know whey are changing. Here's a simple class that helps you with detecting changes and firing off some closures: /** * Map change listener that takes closures. By default, it does nothing when a change occurs in the map. * The closures are called with the tuple {@code (map, key, value-added/removed)}. * @author Mr. Java * */ class SimpleMapChangeListener implements MapChangeListener { Closure added Closure removed public Closure getAdded() { return added; } public Closure getRemoved() { return removed; } public void setAdded(Closure added) { this.added = added; } public void setRemoved(Closure removed) { this.removed = removed; } public SimpleMapChangeListener(Closure added= {}, Closure rem...

javafx 2.x

Javafx is looking pretty good. I still have concerns about its innovativeness especially when it comes to programming productivity. Regardless, some notes for programmers.... When trying to locate resources, it is often necessary to search the node tree, which I think is the logical node tree, for resources. A couple of functions, similar to what you find in WPF are useful. /** * Find a resource. Throw an illegal argument exception if its not found. */ public static Object findResource(Node start, Object key) { if (start == null) return null; if (start.getProperties().containsKey(key)) { return start.getProperties().get(key); } if (start.getParent() != null) return findResource(start.getParent(), key); throw new IllegalArgumentException("Could not find resource with key " + key + " starting at node " + start); } /** * Try and find a resource. Do NOT throw an exception if its not found. * * @param key * @param start * @return ...

jsf2 – splitter composite component

I was playing with the composite component capability of jsf2. It essentially allows you to build up “templates” of reusable layouts and content. One component that I did  not find in the jsf component library I am using (richfaces) is a splitter. I know its in the openfaces component library, but I was wondering how easy it would be to create something quickly. So, without regard for colors and layout requirements, I put together: 1: <? xml version ="1.0" encoding ="UTF-8" ? > 2: <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 3: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > 4: < ui:component xmlns ="http://www.w3.org/1999/xhtml" 5: xmlns:h ="http://java.sun.com/jsf/html" 6: xmlns:f ="http://java.sun.com/jsf/core" 7: xmlns:ui ="http://java.sun.com/jsf/facelets" 8: xmlns:a4j ="http://richfaces.org/a4j...

JSF2.0 and web applications

Well…after poking around a bit on web frameworks I decided to take a deeper look into JSF2.0. Why? Wasn’t the 1.x series of JSF standards pretty brutal? Well yes, from the looks of it. JSF2.0 is, however, a nice component based web framework. Oracle has ADF, JBoss has RichFaces, and there are many component libraries available for JSF. Even the ZK framework (which has a heritage in the GWT thinking) has some taglibs to leverage inside of JSF if you want to. Why JSF? Well, it has a nicely defined lifecycle, it allows you to bundle things up into a declarative syntax nicely and the available toolkits look pretty good. You can avoid some deeper tinkering with javascript if you like. Because JSF2.0 is ajax enabled, you can still get good partial page rendering support when you need it. A couple of the parts that I like about JSF is that it has: Templates: You can define page templates in xhtml and reuse them. Composite Components: It has composite components that allow you to build wh...

javafx 2.0 - great progress, some thoughts...

I looked at javafx 2.0 beta and I am very pleased with the progress. I think Oracle could make a great steward for some java technologies especially if they can make it economic so that more investments in java can be made. I took a look at the programming model, which is based on the idea of directly programming a scenegraph, and here are some thoughts: I liked the programming model as compared to Swing. There are significantly fewer "model" constraints" I am a fan of less API for models. Swing always had complicated models for more complex controls. fx2 has fewer. More integrated thinking about effects and rich media. That's all good. CSS: I'm not a big fan of CSS for UI presentation specifications. Why? Well, first, you are typically using another "language" even if it is a DSL. I think WPF had it right in that that built the CSS-like stylers directly into the language and XAML supports the same "syntax" for specifying CSS-like effects. You...

hibernate 3.6.0.FINAL and OSGi

Hibernate does not come OSGi enabled from jboss. That’s okay. We can use bundlor to fix that. Grab bundlor from springsource and execute the following commands to make them available in maven. You can also add these to a maven pom.xml to have them automatically run. Note that the commands below assume the jar is in a specific subdirectory and the output goes to another subdirectory. Just replace yourprefix with the prefix you want to use. Springsource likes to use com.springsource but pick your own. Then just use your maven dependency declaration as you normally would. bundlor.bat -i nonosgilibs/hibernate3.jar -o ./libs/hibernateuser.org.hibernate-3.6.0.Final.jar -m template-hibernate3.mf mvn install:install-file -Dfile=libs/hibernateuser.org.hibernate-3.6.0.Final.jar -DgroupId=org.hibernate -DartifactId=hibernateuser.org.hibernate -Dversion=3.6.0.Final -Dpackaging=jar bundlor.bat -i nonosgilibs/hibernate-jpa-2.0-api-1.0.0.Final.jar -o libs/hibernateuser.javax.persistence2-1.0.0.Final....