hmm, thats pretty interesting. let me show you how it is done with a fully transparent orm - maybe it will give you some ideas


class EntityModel<T> extends LoadableDetachableModel<T> {
   private final Class clazz;
   private final Serializable id;

   public EntityModel(Class clazz, Serializable id) { this.clazz=clazz; this.id=id; }

   public T load() {
      Session session=getSession() // <=== implemented however you mange session
      return session.load(clazz, id);
    }
}

the above model knows how to load any entity from some session - the model will also cache the loaded enitty for the duration of the request.

class PersonModel extends EntityModel<Person> {
   public PersonModel(Person p) {
        super(Person.class, p.getId());
   }
}

the above model gives you an easy way to pass the person object around and have it loaded safely across requests.

now for populating a listview you would do it in a somewhat similar manner

populateItem(ListItem<Person> item) {
    // wrap whatever model the item has with a compound prop model
    item.setModel(new CompoundPropertyModel<Person>( item.getModel()));
   
    item.add(new Label("firstName"));
    item.add(new Label("lastName"));
}

and in your markup

<tr wicket:id="listview"><td><span wicket:id="firstName"></span> <span wicket:id="lastName"></span></td></tr>

the above doesnt have the automatic "loop" to populate properties - but i dont see the point since you still have to manually write out the ids in the markup.

also this can be accomplished automatically by using a bean panel that will work on any pojo.

not saying one way is better then the other - full orm or shades - just trying to give you some ideas on how to adapt wicket and hopefully get some ideas back as well.

-Igor


On 8/26/06, Geoff hendrey <[EMAIL PROTECTED]> wrote:
Shades isn't threatening to JDO, EJB, or Hibernate.
I'm a member of the JDO2 expert group, and I've built
a free JDO driver, which as far as I know was the only
non-commercial driver to pass the Sun TCK for JDO, at
the time. It was called JDOMax. I recently stopped
supporting it and I've taken the JDOMax website down.
I want to focus on Shades now.

So anyway, I really love JDO. I am also a member of
EJB 3 expert's group- I was invited to join to  bring
the JDO perspective to the work. I was never able to
be active in EJB3, but I appreciate the work they are
doing.

Anyway, if you look in my toolbox you will find square
drive screw drivers and philips head drivers. It's
great to add tools to your kit when it makes a job
easier.

Basically Shades fills a gap between SQL frameworks,
and full transparent object persistence. Shades is
neither. Shades uses an interface to dynamically do
table I/O and ORMapping, rather than an XML-driven
mapping. It turns out this dynamic mapping has all
kinds of beautiful effects. One such effect I found
immediately when using wicket was the ability to
dynamically populate all the fields of a ListItem. I
believe this can already be "automatically" by Wicket
using a bound property model, but I'm not a Wicket
expert yet.

private void addRow(ORMapping orm, User user, ListItem
item){
  for(String c: orm.getColumnNames()){
     if(orm.isPojoField(c)){
         item.add(new Label(c,
         ""+orm.getColumnFromObject(c, user)));
     }
  }
}

I used the same tehcnique to throw all the fields of a
User object into PageParameters:

    private static void setPageParameters(
                  BookmarkablePageLink link, Object
                  pojo, ORMapping orm){
        for(String c:orm.getColumnNames ()){
            if(orm.isPojoField(c)){
                link.setParameter(c,
                ""+orm.getColumnFromObject(c,pojo));
            }
        }
    }


In fact, it doesn't matter to me at all if we "need"
Shades or not. **I** needed Shades. If other people
like it, that's cool too and I hope it can be useful.

-geoff

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to