Upayavira
No, its not a tired drum - just potentially a very large and
maybe a "biting off more than I can chew" one. If there
was an existing, simple but *complete* project that demo'ed
this, I could at least have a solid starting point that I could
build up from. At present there are just code fragments and,
unfortunately, I'm a big picture person and I struggle to see
where all these bits fit together.
My own concerns aside, I do believe that if Cocoon is going to
thrive and grow and be adopted (if that's what we want....?)
then there does need to be some clear, direct guidance on how
to tackle fairly straightforward applications - and I would argue
that a "simple interactive database, possibly with authentication"
is one "use case" for which there will be demand.
Derek
>>> [EMAIL PROTECTED] 2004/05/18 09:25:21 AM >>>
Derek Hohls wrote:
>I am looking to try and build-up my learning on forms and flow (and
>templating!) by applying this to a simple interactive database app.
>
>In the past, I used XSP and ESQL, along with a primitive "meta forms"
>XML file to generate a generic form *and* populate it with data,
>followed
>by styling with XSLT. Database add/update/delete were then handled
by
>
>database actions in the sitemap (along with the corresponding table
>definition files). This approach may seem crude and simple but it
>worked
>and bugs (if any) were usually in a single XSP file and easy to track
>down.
>
>I am now wondering what combination of "new" options to adopt in
order
>to replicate this approach in the simplest possible manner - I know
>there has been lots of discussion on persistence frameworks; DTO's,
>DAO's and business objects - but all this seems very much like over-
>kill just to tackle a few tables with a few users (in other words, a
>normal in-house, customised database app). I have seen flow samples
>with binding to beans and XML files, but nothing in terms of building
>up
>forms dynamically and then hooking then to a normal relational
database
>
>to read/write data.
>
>
I know that people keep harking back to O/R mapping. I've just done my
first bit of hibernate, which I've always been mildly scared of ("isn't
it overkill???"). I couldn't believe it was that easy. You create an
object, and then persist it. Easy:
Here's the code to create a new User object:
net.sf.hibernate.Session session =
sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
User user = new User();
user.setEmail("[EMAIL PROTECTED]");
user.setName("Upayavira");
session.save(user);
transaction.commit();
That is it. And then that user object and persist it. You can make an
object like that, and bind it to a form. The object is yours, it is of
your design.
Or to check whether a user exists or not with a simple query from a
login form:
try {
transaction = session.beginTransaction();
Query query = session.createQuery("from
com.yoursite.formModels.User as user where user.email= :email and
user.password=:password");
query.setString("email",
aForm.getChild("email").getValue().toString());
query.setString("password",
aForm.getChild("password").getValue().toString());
result= (query.list().size()!=0);
transaction.commit();
} catch (Exception e){
transaction.rollback();
throw e;
} finally {
session.close();
}
return result;
That's how easy it is in Hibernate. Don't know about OJB. I've got a
feeling I'll be using O/R mapping for all sites I work on now that have
a relational DB involved, it seems that easy.
Hope I'm not banging a tired drum!
Regards, Upayavira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]