Generic Bean Editing with Apache Wicket - Presentation & Code

The recent talk I did at the last London Wicket event and Wednesday’s Java Web User Group is now available on-line (12Mb, Quicktime H264, plays fine under Linux using VLC or MPlayer).

There’s also a ready to run Maven 2 + Eclipse quickstart available to accompany it (built against Wicket 1.3.0-beta2).

This entry was posted in Apache Wicket. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

14 Comments

  1. Posted August 17, 2007 at 9:31 am | Permalink

    How do you cope with toEdit.getClass().getDeclaredFields() returing the fields in a undefined order? What if I want to have my form fields ordered?

    form the javadoc: “The elements in the array returned are not sorted and are not in any particular order”

    Would you define some static final array containing fieldnames? That would kill refactoring support.
    Would you add some ordering annotation? In the end all those annotation just make your class less readable?

  2. Posted August 17, 2007 at 9:48 am | Permalink

    Sure, you could add an ordering annotation if you like. You could argue that this is a view layer thing, so you shouldn’t clutter the bean with stuff like that. Your call.

    I hadn’t thought about ordering, to be honest, as I find that the Sun JDK tends to return things in order, whether the javadoc says it does or not. ;-)

    If you’re localising your field name labels then you’ve killed refactoring support anyway.

    You say “all those annotations”, but really, there aren’t many, or if there are any, then they’ll be JPA or Hibernate annotation ones, so using this approach isn’t really adding anything extra.

    I’m not saying you can just take this code and run with it for your project. I’m giving it to you as a starting point, and to get you thinking about more abstract ways of building your web apps.

  3. Gerolf
    Posted August 19, 2007 at 6:00 pm | Permalink

    dzoned -> http://www.dzone.com/links/generic_bean_editing_with_apache_wicket_presentat.html

  4. Posted August 22, 2007 at 12:54 am | Permalink

    beautiful! i’ve been talking about doing this for a couple years now, but you actually went and did it. ;-)

    i think we ought to make it a goal for wicket 1.4 to pull together a suite we could call something like “wicket on wings” (to compete with ruby on rails). this would simply assemble a bean editor framework like this with something like the constraint annotations and feedback bubbles behaviors we’ve been developing at my workplace to make this stuff slicker and more ajaxy and as turnkey as ruby, only typesafe, refactorable, discoverable, secure, etc.

    you ought to be able to do new ObjectEditor(model) and get an excellent default which is also highly customizable.

    my personal belief is that there is a need to have both a repeater version of this that’s fully automatic but also a version which allows full manual html layout of the editor panel. that could be a different class, a subclass or just a flag, but it ought to exist.

  5. Posted August 22, 2007 at 12:59 am | Permalink

    for the manual layout mode, i think there ought to be a way to output the markup that would be generated by the repeater as a starting point. that way i can just insert add(new ObjectEditorForm(model)) into my code, run some little tool to create the markup and hand it off to the designer to finish it.

  6. Posted August 22, 2007 at 10:03 am | Permalink

    Yep. I’ve been thinking about that too. I have a generic listing component, but it’s too tightly coupled to the project it’s in at the moment.

    I’m almost tempted to mandate a particular way of DAO access working (like Rails does with ActiveRecord) and write some components around that, so we really do have something Rails-like, only type-safe, faster and more flexible.

  7. Posted August 22, 2007 at 5:51 pm | Permalink

    At some point we should skype about this.

  8. Posted August 24, 2007 at 8:05 pm | Permalink

    You should dump that BeanEditor.mov into Youtube and get it embedded in your blog page so that people can get instant gratification.

  9. Posted August 29, 2007 at 2:15 pm | Permalink

    That reminds of Tapestry’s BeanEditForm - ok it has less functionality yet, but I really like it. I played around a bit and added the order annotation discussed above within minutes (as a wicket-newbie) :-) Now I’m thinking about adding a generic validation of the fields. E.g. @Validate(minValue=5) … I think your introduction infected me with the wicket-virus ;-)

  10. Johannes
    Posted August 31, 2007 at 10:05 pm | Permalink

    somatik:

    Just sort the Fields array according to their getName().

  11. Posted September 3, 2007 at 9:34 am | Permalink

    I would embed it into YouTube, but there seem to be some issues encoding the thing - they don’t like initially static frames or something. I’ll set up the next one so it works properly there.

  12. Posted September 10, 2007 at 6:41 pm | Permalink

    Perfect. This video is perfect.

  13. Posted September 13, 2007 at 1:45 am | Permalink

    You may want to check out my project, Wicket Web Beans. I release 1.0-rc1 today. You can find it at: http://wicketwebbeans.sourceforge.net .

  14. Ken
    Posted January 19, 2008 at 1:10 pm | Permalink

    nice, we have been looking into wicket for such functionality to replace our current infra. One more thing you might want to look at is the actions like onSubmit, onClick to push your bean to a generic web service interface perhaps

One Trackback

  1. By links for 2007-08-27 « Object neo = neo Object on August 27, 2007 at 11:24 pm

    [...] Here Be Beasties » Generic Bean Editing with Apache Wicket - Presentation & Code Al Maw ’s wicket bean editor. (tags: wicket java widget) [...]

Post a Comment

Your email is never published nor shared.