TR: [XMLForm] close XMLForm application
Status: Beta
Brought to you by:
ivelin
|
From: <Syl...@sw...> - 2003-05-20 08:13:04
|
Hi Lee,
If you implement a solution like this:
else if (formView.equals(VIEW_CONFIRM))
{
if (command.equals(CMD_NEXT))
{
Form.remove(request, FORM_ID);
dBConn.close();
// or
Form form =3D Form.lookup(request, FORM_ID);
Object model =3D form.getModel();
model.closeMyConnection();
return VIEW_END;
}
else if (command.equals(CMD_PREV))
return VIEW_SYSTEM;
}
A problem occur when, for some reasons, the user don't pass through the =
VIEW_CONFIRM -> CMD_NEXT process and the connection isn't closed (for =
example, when the user close the browser before he has finished).
It isn't easy because the XMLForm action is called each time a page is =
loaded, not only when you start your application (which contains several =
pages). So you don't have a point when your application start and =
finish. That's the problem.
About the solution for a servlet's init and destroy methods, when (or =
where) could I call this methods?
Thanks for any suggestions
Regards
Sylvain
-----Message d'origine-----
De: Lee Pollington [mailto:bat...@ho...]
Date: mercredi, 14. mai 2003 19:39
=C0: Th=E9voz Sylvain, IT-DTS-ENG-SDM-DAR
Cc: fre...@li...
Objet: Re: [XMLForm] close XMLForm application
Hi Sylvain,
I have used Castor to marshall an XML file into a series of beans. I =
wasn't
perhaps completely clear, you could pass the connection object to the
constructor and keep all the data access methods in the bean, but =
control
the connection object's life outside of the bean, in your case perhaps =
in a
servlet's init and destroy methods, another approach may be to get the =
bean
back from XMLFORM using the getModel(id) method and call whatever you =
need
to.or as the one of the last operations in an action, so for example =
taking
some code from WizardAction:
else if (formView.equals(VIEW_CONFIRM))
{
if (command.equals(CMD_NEXT))
{
Form.remove(request, FORM_ID);
dBConn.close();
// or
Form form =3D Form.lookup(request, FORM_ID);
Object model =3D form.getModel();
model.closeMyConnection();
return VIEW_END;
}
else if (command.equals(CMD_PREV))
return VIEW_SYSTEM;
}
Let me know if you have success with one of these approaches and please =
post
to the group :)
Lee
----- Original Message -----
From: <Syl...@sw...>
To: <bat...@ho...>
Sent: Wednesday, May 14, 2003 8:36 AM
Subject: RE: [XMLForm] close XMLForm application
Hi Lee,
Thanks for your reply.
For some reasons it is best for me to create a connection to the dB each
time I start an XMLForm application.
You said that we shouldn't add programmatic hooks into the bean.
Where do you put them (for example methods to access to the dB)?
Regards
Sylvain
-----Message d'origine-----
De: Lee Pollington [mailto:bat...@ho...]
Date: mardi, 13. mai 2003 19:40
=C0: Th=E9voz Sylvain, IT-DTS-ENG-SDM-DAR;
fre...@li...
Objet: Re: [XMLForm] close XMLForm application
Sylvian,
It would be best if you managed your dB connection outside of the bean.
XMLForm treats your bean purely as a data model, there are no =
programmatic
hooks into it. If you manage the connection in the Servlet containers
session you can reuse it as well, rather than recreate it per request.
hope that helps,
Lee
----- Original Message -----
From: <Syl...@sw...>
To: <fre...@li...>
Sent: Tuesday, May 13, 2003 2:44 PM
Subject: [XMLForm] close XMLForm application
Hello,
I'm using XMLForm application to retrieve data from a database.
To connect to my database, I'm using an object/relationnal mapping tool
(OJB).
When I start a XMLForm application, I need to initialize the connection =
to
my database. I'm doing this in the Bean constructor. This is in the Bean
because all data stuffs are in it.
When I close the XMLForm application, I need to close this connection.
My question is: where can I do this in the Bean (or in other place)?
Thanks
Sylvain
-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com
_______________________________________________
Freebuilder-XMLForm mailing list
Fre...@li...
https://lists.sourceforge.net/lists/listinfo/freebuilder-xmlform
|