<meta name='google-adsense-platform-account' content='ca-host-pub-1556223355139109'/> <meta name='google-adsense-platform-domain' content='blogspot.com'/> <!-- data-ad-client=ca-pub-4320963827702032 --> <!-- --><style type="text/css">@import url(//www.blogger.com/static/v1/v-css/navbar/3334278262-classic.css); div.b-mobile {display:none;} </style> </head><body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d7256432\x26blogName\x3dThe+Frustrated+Programmer\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLACK\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://frustratedprogrammer.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttps://frustratedprogrammer.blogspot.com/\x26vt\x3d-1687486435376088425', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>
| Sunday, August 01, 2004

One of the beautiful features of Hibernate is that you can finally work with objects in your persistence layer. Once your mappings are setup, you can keep playing with object oriented code. Why don't we have anything like this with UI frameworks?

Currently if I have the following classes in my object model. Cat is a nomal object/table, and gender is an enumeration/lookup table.

public class Cat {
private Integer id;
private String name;
private Integer age;
private Gender gender;
[...]
}
public class Gender {
private Interger id;
private String label;
}

And I have the form:

Cat Name: ___________
Cat Age: ___________
Cat Gener: [Male ]<-
[Female]

I'm always left hand-coding some genderId field in my form and manually looking up the gender based on this in my Action, when the form is submitted. The more relationships my objects have, the mroe repetitive code I have like this. In all the frameworks I've seen, including ones that let you use your business obejcts directly (like Spring and WebWork), I can't see how I can automatically build these relationships between objects. I think the UI framework should handle all this for me. I don't even mind if they have to look in my hibernate config files.

The closest thing I've seen is the Converters in Webwork, but they are not well documented. I think OGNL might be up to the task, but I'd have to write custom converters for each type in my object model. Thats a little too much.