Question

on my company we are developing a ERP-like app using java and jsf, so far the design team has identified about 20 entities,each with diferent properties, usually we'll be building 20 pages of CRUD , is there any better way to do this?, we are using hibernate as db access, so we came up with the idea of a single DAO for this part of the system, have you faced a similiar situation? what are your thoughts on it?

Was it helpful?

Solution

You might consider codegenerating those 20 screens, much like scaffolding in Ruby does. As far as DAO is concerned, you might pull CUD operations to some generic IBusinessObjectDao, leaving specific R operations (querying by various parameters) to concrete DAO implementations.

OTHER TIPS

You really should look into Seam. It has a feature called Seam-Gen that will reverse engineer your entire application CRUD pages from the database. You can edit the Seam-Gen templates (which are based on Freemarker) to customise the pages that will be generated to your liking.

I use the Eclipse plugin Azzurri Clay to model my database and generate the DDL. I then run Seam-Gen and in a few seconds you have a running application. It's a very handy combination.

I know its late, but I think my little framework would fit this situation perfectly. Check out http://code.google.com/p/happyfacescrud/ . It has search out of box, custom components that recognize datatype of entity, lazy datamodel, and flexibility that code generators can not offer. Here is little sample how page with lazy datatable and search would look like:

    <hf:searchPanel columns="4" backingBean="#{accountBean}">
        <hf:searchField label="#{messages['account.accountNumber']}" field="accountNumber" />
        <hf:searchField label="#{messages['account.active']}" field="active" isMessage="true" />
        <hf:searchEntityField label="#{messages['account.customer']}" field="customer" childField="name" popup="true" />
        <hf:searchField label="#{messages['account.openingDate']}" field="openingDate" rangeSearch="false" />
    </hf:searchPanel>
    <hf:dataList label="#{messages['account.search.results']}" backingBean="#{accountBean}">
        <hf:column label="#{messages['account.accountNumber']}" field="accountNumber" />
        <hf:column label="#{messages['account.active']}" field="active" isMessage="true" />
        <hf:column label="#{messages['account.customer']}" field="customer" childField="name" entityView="/pages/customerEdit.xhtml" popupFields="email,phone,address" />
        <hf:column label="#{messages['account.openingDate']}" field="openingDate" isDate="true" />
        <hf:actionsColumn />
    </hf:dataList>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top