Hello,
Here's some background, medium-length only because it's slightly interesting in itself. Some years ago now, in my pre-WebObjects phase, I needed an application to implement a really simple model for billing time and creating invoices. Not knowing any better, I picked up a book on Ruby on Rails, and made a very basic web application, relying largely on what Rails calls "scaffolding", which is somewhat reminiscent of D2W. The app had some minimally customised controller classes, and that was it. I've been using it for about 6 years. Having no interest in maintaining or updating the app, or keeping up with Ruby or Rails, though, the app breaks with every OS X upgrade (because Ruby and/or Rails changes). Previously I've jumped in and fixed the broken bits, but I can no longer be bothered. Yesterday I figured I would see how long it takes to create an ERModern D2W application from the existing database. Answer: 13 minutes. Admittedly I knew what I was doing, but it took me 13 minutes to reverse engineer a model and bring up a basic D2W application, and several of those were spent downloading the MySQL JDBC driver, and discovering "zeroDateTimeBehavior=convertToNull". 13 minutes—that's pretty cool.
Anyway, the subject above is probably a misnomer: I'm not trying to create particularly complex objects, but I am trying to do something outside CRUD, which is pretty much all I've ever done with D2W before. In the model, a Billable object has an optional to-one relationship to Invoice. When I create a Billable, it initially has no related Invoice. Later I will create an Invoice for a client, and collect together some set of Billables, and the relationship is created at that time. And that's the bit I need a pattern for: Invoice creation. Billable also has a mandatory relationship to Practice (i.e., a client), and a startTime timestamp. When I go to create an Invoice, I'd give the Invoice a date and select a Practice, and then I want to add, say, all of the Billables that (a) belong to no other Invoice, (b) point to the same Practice, and (c) have a startTime that falls before the new Invoice.date.
My first thought was to create tabs on the wizard creation page for Invoice, such that I set the date and Practice in the first tab, and then on the next tab I get the billables relationship pre-populated with the Billables that match the criteria above. Is this the approach? And if so, in which method do I select those Billables and add them—Invoice.setDate(), or Invoice.setPractice() seemed like candidates, but (a) I need both of those to be set before selecting the Billables, and (b) I only want this for new object creation. I actually think I can do it, but it seemed like a bit of work, so I figured it would be a good place to pause and see whether this is the right pattern anyway.
What do other people do? Any comments would be appreciated.
|