You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steve McLeod <st...@ingena.com.au> on 2002/09/02 02:09:47 UTC

Database Connection in Logic Beans - pooling?

I am using:
Tomcat 4.0
Struts 1.0.2
 
The problem
========
 
I have successfully used the Struts database connection pooling in a trial
web app, but as far as I can tell, a reference to the datasource can only be
obtained from within an Action class (or directly within a JSP page but
let's not think about that today).
 
However I would like to have logic beans which handle database access,
rather than have this in the Action class. But I can't get a reference to
the datasource from the logic bean because it doesn't have a ServletContext
to which I can get a handle.
 
I have toyed with various ideas:
- Initialise a logic bean by passing it a reference to the Servlet
- Acquire a connection in the Action class and pass that to the bean
 
But really, I would rather the logic bean know inherently how to acquire a
database connection.
 
My current workaround is to not use the Struts connection pooling, and
rather to manually create a connection each time database access needs to be
done, then destroy it. But this is clearly not suitable for our production
environment.
 
 
The context of my problem
==================
 
I want to use some code like this in a JSP:
 
<jsp:useBean id="abean" scope="page"
class="au.com.sunesis.timesheets.ClientManager" />
<table border="1">
    <tr>
        <th>#</th>
        <th>Client</th>
        <th>Active</th>
    </tr>
<logic:iterate id="clientList" name="abean" property="clients"
type="au.com.sunesis.timesheets.Client">
    <tr>
        <td><bean:write name="clientList" property="clientID"/></td>
        <td><bean:write name="clientList" property="clientName"/></td>
        <td><bean:write name="clientList" property="active"/></td>
    </tr>
</logic:iterate>
 
 
The idea is that ClientManager is used to handle all general database tasks
for the Client bean (which maps to a Client entity in the database).
ClientManager.getClients() connects to the database, creates an ArrayList of
Client objects, one for each row in the database, and returns the ArrayList.
 
ClientManager has other methods, such as:
-         ClientManager.delete(Client c), which deletes the row in the
database entity corresponding to the specified client.
-         ClientManager.findByPrimaryKey(int ID) which returns the Client
which matches the specified ID
-         ClientManager.save(Client c), which stores the client in the
database, creating or updating as necessary
 
So an Action class can also call any of these directly, and it really
shouldn't care about how these work and how they store to/retrieve from the
database. But I can't think of the elegant way to do this and still be able
to use the Struts connection pooling.
 
Any thoughts?
 
Thanks
 
Steve McLeod
 
 
 

RE: Database Connection in Logic Beans - pooling?

Posted by Troy Hart <th...@part.net>.
A big problem that you will encounter is reliably trapping the "end" of
the request lifecycle. I haven't looked at filters to see if they
provide a 100% reliable solution for this, they may (I don't know what
happens in this scenario when some component decides to redirect the
request...), or there may be some other creative solution that fits your
needs.

However, I still think the goal should be to encapsulate as much as you
can behind a re-usable business API. Struts is great but you may have a
case for re-use elsewhere. For example, you could be tasked to implement
a messaging system that asynchronously executes business logic based on
the receipt of standard documents that come in from trading partners... 

You can pass a connection to the business components if you insist, but
if the business api is done right it should naturally encapsulate the
boundaries of your transactions. Also, by passing the connection into
the business layer you have tightly coupled the controller and model
layers. However, if this buisiness API only exposes a set of value
objects then the business tier is free to swap the relational database
for an ldap store... This API could be a session facade if you were to
use EJB Session beans, but you are certainly not tied to that approach.

My advice is to take the time to get the abstractions right. Don't
couple the tiers unnecessarily, and plan for re-use. This is just my
opinion and it may or may not be relevant (I don't know your apps
requirements).

Cheers,

Troy



On Mon, 2002-09-02 at 15:02, Frederic Laub wrote:
> Thanks to Troy,
> 
> But I read a lot of Java literature and the struts archive over the past
> weeks but in the all the examples the connection is retrieved and returned
> is the same class. I know it is the easiest and the best way to handle the
> problem.
> In most cases it provides a solution.
> I would like to implement a more flexible solution:
> - Retrieving a connection and saving it in the context (request scope) or
> saving an id associated with the connection.
> - When a connection is needed in the request, look first in the context if a
> connection has already been retrieved.
> - Based on a parameter => return the connection in the class.
> - Check at the end of the request if a connection exists, if yes return it
> to the pool.
> => Where does the request cycle ends?
> At the source I'm a database programmer so I prefer to manage the
> transactions myself.
> I think that another advantage of using a same connection through the whole
> request is the fact that in case of heavy loading, when connections are
> difficult to obtain, the request can be served as a whole. I prefer X
> requests with 100% satisfaction and y not satisfied than x+y requests with
> 30% satisfaction. If you understand what I mean?
> 
> Your help or advice will be appreciated.
> Frederic
> 
> I've excluded EJB for my project because most of the data is read only or
> linked to one user only.
> 
> -----Original Message-----
> From: Troy Hart [mailto:thart@part.net]
> Sent: Monday, September 02, 2002 9:17 PM
> To: Struts Users Mailing List
> Subject: RE: Database Connection in Logic Beans - pooling?
> 
> 
> You can solve this problem by providing a business service framework for
> your application (There has been a lot of talk about this sort of thing
> on this list...I can't think of a particular thread to reference for you
> so you may just want to go through the archives). My approach to this
> problem has been to create a set of very coarse grained business service
> components (ours is an ecommerce system so we have components like the
> following: one for cataloging, one for requisitioning, one for order
> services, and etc...), where each component provides a public API that
> mirrors the "use-cases" one-to-one (for the most part). I think you will
> find that the top level "use-cases" defined for your system provide
> natural scoping boundaries for your transactions, and resource
> management in general.
> 
> This approach will leave you with a set of re-usable business components
> that are not tied to struts and/or the servlet paradigm. Also, this API
> provides an abstraction that will allow you to hide complexity from your
> struts actions (or whatever else uses the API). For example, the
> component you expose could be a facade to an EJB Session bean
> (http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html
> ).
> 
> Anyway, my suggestion is to think about your problem a little
> differently. Sorry if I didn't provide enough details, my intention was
> simply to give a high level overview of how I see the problem and the
> solution. Once again, I would urge to lookup other threads on this topic
> to read what other people have said.
> 
> Hope this helps,
> 
> Troy
> 
> 
> On Mon, 2002-09-02 at 10:45, Frederic Laub wrote:
> > Hi,
> >
> > How do achieve the following:
> > In some cases I want to get a connection at the beginning of a request
> > (request scope), pass the same connection to all the java beans that are
> > called in the request and return the connection at the end of the request.
> > Where do I put the code to return the connection to the pool at the end of
> > the request and in case of an error be sure that the connection is
> returned
> > to the pool?
> > A same connection is required when all DML statements throughout a request
> > are part of a same transaction.
> > The commit (or rollback in case of an error) statement is issued at the
> end
> > of the request before the connection is returned to the pool.
> > Sorry if the vocabulary I used is database oriented and not 100 %
> > java/struts compatible.
> >
> > Your help will be appreciated.
> > Frederic
> >
> >
> > -----Original Message-----
> > From: thart@part.net [mailto:thart@part.net]
> > Sent: Monday, September 02, 2002 9:06 AM
> > To: Struts Users Mailing List
> > Subject: Re: Database Connection in Logic Beans - pooling?
> >
> >
> > Steve McLeod writes:
> >
> > > I am using:
> > > Tomcat 4.0
> > > Struts 1.0.2
> > >
> > > The problem
> > > ========
> > >
> > > I have successfully used the Struts database connection pooling in a
> trial
> > > web app, but as far as I can tell, a reference to the datasource can
> only
> > be
> > > obtained from within an Action class (or directly within a JSP page but
> > > let's not think about that today).
> > >
> > > However I would like to have logic beans which handle database access,
> > > rather than have this in the Action class. But I can't get a reference
> to
> > > the datasource from the logic bean because it doesn't have a
> > ServletContext
> > > to which I can get a handle.
> > >
> > > I have toyed with various ideas:
> > > - Initialise a logic bean by passing it a reference to the Servlet
> > > - Acquire a connection in the Action class and pass that to the bean
> > >
> > > But really, I would rather the logic bean know inherently how to acquire
> a
> > > database connection.
> > >
> > > My current workaround is to not use the Struts connection pooling, and
> > > rather to manually create a connection each time database access needs
> to
> > be
> > > done, then destroy it. But this is clearly not suitable for our
> production
> > > environment.
> >
> > There are a few ways to solve your problem. One way would be to bind a
> > datasource to some JNDI name that your logic beans are aware of. Then,
> using
> > that name, your logic beans can lookup the datasource completely
> independent
> > of struts.
> >
> > Give it a try,
> >
> > Troy
> >
> > >
> > >
> > > The context of my problem
> > > ==================
> > >
> > > I want to use some code like this in a JSP:
> > >
> > > <jsp:useBean id="abean" scope="page"
> > > class="au.com.sunesis.timesheets.ClientManager" />
> > > <table border="1">
> > >     <tr>
> > >         <th>#</th>
> > >         <th>Client</th>
> > >         <th>Active</th>
> > >     </tr>
> > > <logic:iterate id="clientList" name="abean" property="clients"
> > > type="au.com.sunesis.timesheets.Client">
> > >     <tr>
> > >         <td><bean:write name="clientList" property="clientID"/></td>
> > >         <td><bean:write name="clientList" property="clientName"/></td>
> > >         <td><bean:write name="clientList" property="active"/></td>
> > >     </tr>
> > > </logic:iterate>
> > >
> > >
> > > The idea is that ClientManager is used to handle all general database
> > tasks
> > > for the Client bean (which maps to a Client entity in the database).
> > > ClientManager.getClients() connects to the database, creates an
> ArrayList
> > of
> > > Client objects, one for each row in the database, and returns the
> > ArrayList.
> > >
> > > ClientManager has other methods, such as:
> > > -         ClientManager.delete(Client c), which deletes the row in the
> > > database entity corresponding to the specified client.
> > > -         ClientManager.findByPrimaryKey(int ID) which returns the
> Client
> > > which matches the specified ID
> > > -         ClientManager.save(Client c), which stores the client in the
> > > database, creating or updating as necessary
> > >
> > > So an Action class can also call any of these directly, and it really
> > > shouldn't care about how these work and how they store to/retrieve from
> > the
> > > database. But I can't think of the elegant way to do this and still be
> > able
> > > to use the Struts connection pooling.
> > >
> > > Any thoughts?
> > >
> > > Thanks
> > >
> > > Steve McLeod
> > >
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Database Connection in Logic Beans - pooling?

Posted by Frederic Laub <in...@012.net.il>.
Thanks to Troy,

But I read a lot of Java literature and the struts archive over the past
weeks but in the all the examples the connection is retrieved and returned
is the same class. I know it is the easiest and the best way to handle the
problem.
In most cases it provides a solution.
I would like to implement a more flexible solution:
- Retrieving a connection and saving it in the context (request scope) or
saving an id associated with the connection.
- When a connection is needed in the request, look first in the context if a
connection has already been retrieved.
- Based on a parameter => return the connection in the class.
- Check at the end of the request if a connection exists, if yes return it
to the pool.
=> Where does the request cycle ends?
At the source I'm a database programmer so I prefer to manage the
transactions myself.
I think that another advantage of using a same connection through the whole
request is the fact that in case of heavy loading, when connections are
difficult to obtain, the request can be served as a whole. I prefer X
requests with 100% satisfaction and y not satisfied than x+y requests with
30% satisfaction. If you understand what I mean?

Your help or advice will be appreciated.
Frederic

I've excluded EJB for my project because most of the data is read only or
linked to one user only.

-----Original Message-----
From: Troy Hart [mailto:thart@part.net]
Sent: Monday, September 02, 2002 9:17 PM
To: Struts Users Mailing List
Subject: RE: Database Connection in Logic Beans - pooling?


You can solve this problem by providing a business service framework for
your application (There has been a lot of talk about this sort of thing
on this list...I can't think of a particular thread to reference for you
so you may just want to go through the archives). My approach to this
problem has been to create a set of very coarse grained business service
components (ours is an ecommerce system so we have components like the
following: one for cataloging, one for requisitioning, one for order
services, and etc...), where each component provides a public API that
mirrors the "use-cases" one-to-one (for the most part). I think you will
find that the top level "use-cases" defined for your system provide
natural scoping boundaries for your transactions, and resource
management in general.

This approach will leave you with a set of re-usable business components
that are not tied to struts and/or the servlet paradigm. Also, this API
provides an abstraction that will allow you to hide complexity from your
struts actions (or whatever else uses the API). For example, the
component you expose could be a facade to an EJB Session bean
(http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html
).

Anyway, my suggestion is to think about your problem a little
differently. Sorry if I didn't provide enough details, my intention was
simply to give a high level overview of how I see the problem and the
solution. Once again, I would urge to lookup other threads on this topic
to read what other people have said.

Hope this helps,

Troy


On Mon, 2002-09-02 at 10:45, Frederic Laub wrote:
> Hi,
>
> How do achieve the following:
> In some cases I want to get a connection at the beginning of a request
> (request scope), pass the same connection to all the java beans that are
> called in the request and return the connection at the end of the request.
> Where do I put the code to return the connection to the pool at the end of
> the request and in case of an error be sure that the connection is
returned
> to the pool?
> A same connection is required when all DML statements throughout a request
> are part of a same transaction.
> The commit (or rollback in case of an error) statement is issued at the
end
> of the request before the connection is returned to the pool.
> Sorry if the vocabulary I used is database oriented and not 100 %
> java/struts compatible.
>
> Your help will be appreciated.
> Frederic
>
>
> -----Original Message-----
> From: thart@part.net [mailto:thart@part.net]
> Sent: Monday, September 02, 2002 9:06 AM
> To: Struts Users Mailing List
> Subject: Re: Database Connection in Logic Beans - pooling?
>
>
> Steve McLeod writes:
>
> > I am using:
> > Tomcat 4.0
> > Struts 1.0.2
> >
> > The problem
> > ========
> >
> > I have successfully used the Struts database connection pooling in a
trial
> > web app, but as far as I can tell, a reference to the datasource can
only
> be
> > obtained from within an Action class (or directly within a JSP page but
> > let's not think about that today).
> >
> > However I would like to have logic beans which handle database access,
> > rather than have this in the Action class. But I can't get a reference
to
> > the datasource from the logic bean because it doesn't have a
> ServletContext
> > to which I can get a handle.
> >
> > I have toyed with various ideas:
> > - Initialise a logic bean by passing it a reference to the Servlet
> > - Acquire a connection in the Action class and pass that to the bean
> >
> > But really, I would rather the logic bean know inherently how to acquire
a
> > database connection.
> >
> > My current workaround is to not use the Struts connection pooling, and
> > rather to manually create a connection each time database access needs
to
> be
> > done, then destroy it. But this is clearly not suitable for our
production
> > environment.
>
> There are a few ways to solve your problem. One way would be to bind a
> datasource to some JNDI name that your logic beans are aware of. Then,
using
> that name, your logic beans can lookup the datasource completely
independent
> of struts.
>
> Give it a try,
>
> Troy
>
> >
> >
> > The context of my problem
> > ==================
> >
> > I want to use some code like this in a JSP:
> >
> > <jsp:useBean id="abean" scope="page"
> > class="au.com.sunesis.timesheets.ClientManager" />
> > <table border="1">
> >     <tr>
> >         <th>#</th>
> >         <th>Client</th>
> >         <th>Active</th>
> >     </tr>
> > <logic:iterate id="clientList" name="abean" property="clients"
> > type="au.com.sunesis.timesheets.Client">
> >     <tr>
> >         <td><bean:write name="clientList" property="clientID"/></td>
> >         <td><bean:write name="clientList" property="clientName"/></td>
> >         <td><bean:write name="clientList" property="active"/></td>
> >     </tr>
> > </logic:iterate>
> >
> >
> > The idea is that ClientManager is used to handle all general database
> tasks
> > for the Client bean (which maps to a Client entity in the database).
> > ClientManager.getClients() connects to the database, creates an
ArrayList
> of
> > Client objects, one for each row in the database, and returns the
> ArrayList.
> >
> > ClientManager has other methods, such as:
> > -         ClientManager.delete(Client c), which deletes the row in the
> > database entity corresponding to the specified client.
> > -         ClientManager.findByPrimaryKey(int ID) which returns the
Client
> > which matches the specified ID
> > -         ClientManager.save(Client c), which stores the client in the
> > database, creating or updating as necessary
> >
> > So an Action class can also call any of these directly, and it really
> > shouldn't care about how these work and how they store to/retrieve from
> the
> > database. But I can't think of the elegant way to do this and still be
> able
> > to use the Struts connection pooling.
> >
> > Any thoughts?
> >
> > Thanks
> >
> > Steve McLeod
> >
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Database Connection in Logic Beans - pooling?

Posted by Troy Hart <th...@part.net>.
You can solve this problem by providing a business service framework for
your application (There has been a lot of talk about this sort of thing
on this list...I can't think of a particular thread to reference for you
so you may just want to go through the archives). My approach to this
problem has been to create a set of very coarse grained business service
components (ours is an ecommerce system so we have components like the
following: one for cataloging, one for requisitioning, one for order
services, and etc...), where each component provides a public API that
mirrors the "use-cases" one-to-one (for the most part). I think you will
find that the top level "use-cases" defined for your system provide
natural scoping boundaries for your transactions, and resource
management in general.

This approach will leave you with a set of re-usable business components
that are not tied to struts and/or the servlet paradigm. Also, this API
provides an abstraction that will allow you to hide complexity from your
struts actions (or whatever else uses the API). For example, the
component you expose could be a facade to an EJB Session bean
(http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html).

Anyway, my suggestion is to think about your problem a little
differently. Sorry if I didn't provide enough details, my intention was
simply to give a high level overview of how I see the problem and the
solution. Once again, I would urge to lookup other threads on this topic
to read what other people have said.

Hope this helps,

Troy


On Mon, 2002-09-02 at 10:45, Frederic Laub wrote:
> Hi,
> 
> How do achieve the following:
> In some cases I want to get a connection at the beginning of a request
> (request scope), pass the same connection to all the java beans that are
> called in the request and return the connection at the end of the request.
> Where do I put the code to return the connection to the pool at the end of
> the request and in case of an error be sure that the connection is returned
> to the pool?
> A same connection is required when all DML statements throughout a request
> are part of a same transaction.
> The commit (or rollback in case of an error) statement is issued at the end
> of the request before the connection is returned to the pool.
> Sorry if the vocabulary I used is database oriented and not 100 %
> java/struts compatible.
> 
> Your help will be appreciated.
> Frederic
> 
> 
> -----Original Message-----
> From: thart@part.net [mailto:thart@part.net]
> Sent: Monday, September 02, 2002 9:06 AM
> To: Struts Users Mailing List
> Subject: Re: Database Connection in Logic Beans - pooling?
> 
> 
> Steve McLeod writes:
> 
> > I am using:
> > Tomcat 4.0
> > Struts 1.0.2
> >
> > The problem
> > ========
> >
> > I have successfully used the Struts database connection pooling in a trial
> > web app, but as far as I can tell, a reference to the datasource can only
> be
> > obtained from within an Action class (or directly within a JSP page but
> > let's not think about that today).
> >
> > However I would like to have logic beans which handle database access,
> > rather than have this in the Action class. But I can't get a reference to
> > the datasource from the logic bean because it doesn't have a
> ServletContext
> > to which I can get a handle.
> >
> > I have toyed with various ideas:
> > - Initialise a logic bean by passing it a reference to the Servlet
> > - Acquire a connection in the Action class and pass that to the bean
> >
> > But really, I would rather the logic bean know inherently how to acquire a
> > database connection.
> >
> > My current workaround is to not use the Struts connection pooling, and
> > rather to manually create a connection each time database access needs to
> be
> > done, then destroy it. But this is clearly not suitable for our production
> > environment.
> 
> There are a few ways to solve your problem. One way would be to bind a
> datasource to some JNDI name that your logic beans are aware of. Then, using
> that name, your logic beans can lookup the datasource completely independent
> of struts.
> 
> Give it a try,
> 
> Troy
> 
> >
> >
> > The context of my problem
> > ==================
> >
> > I want to use some code like this in a JSP:
> >
> > <jsp:useBean id="abean" scope="page"
> > class="au.com.sunesis.timesheets.ClientManager" />
> > <table border="1">
> >     <tr>
> >         <th>#</th>
> >         <th>Client</th>
> >         <th>Active</th>
> >     </tr>
> > <logic:iterate id="clientList" name="abean" property="clients"
> > type="au.com.sunesis.timesheets.Client">
> >     <tr>
> >         <td><bean:write name="clientList" property="clientID"/></td>
> >         <td><bean:write name="clientList" property="clientName"/></td>
> >         <td><bean:write name="clientList" property="active"/></td>
> >     </tr>
> > </logic:iterate>
> >
> >
> > The idea is that ClientManager is used to handle all general database
> tasks
> > for the Client bean (which maps to a Client entity in the database).
> > ClientManager.getClients() connects to the database, creates an ArrayList
> of
> > Client objects, one for each row in the database, and returns the
> ArrayList.
> >
> > ClientManager has other methods, such as:
> > -         ClientManager.delete(Client c), which deletes the row in the
> > database entity corresponding to the specified client.
> > -         ClientManager.findByPrimaryKey(int ID) which returns the Client
> > which matches the specified ID
> > -         ClientManager.save(Client c), which stores the client in the
> > database, creating or updating as necessary
> >
> > So an Action class can also call any of these directly, and it really
> > shouldn't care about how these work and how they store to/retrieve from
> the
> > database. But I can't think of the elegant way to do this and still be
> able
> > to use the Struts connection pooling.
> >
> > Any thoughts?
> >
> > Thanks
> >
> > Steve McLeod
> >
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tree Folder navigation

Posted by "V. Cekvenich" <ne...@att.net>.
(Ted would have to offer.) I can offer to add commiters to an area I can get
to.
Vic

"James Mitchell" <jm...@telocity.com> wrote in message
news:LCEIJAGMKHNNONJFELILAECEDFAA.jmitchtx@telocity.com...
> Why don't you just use the struts project there?
>
> http://sourceforge.net/projects/struts/
>
> James Mitchell
> Software Engineer\Struts Evangelist
> Struts-Atlanta, the "Open Minded Developer Network"
> http://www.open-tools.org/struts-atlanta
>
>
>
>
> > -----Original Message-----
> > From: news [mailto:news@main.gmane.org]On Behalf Of V. Cekvenich
> > Sent: Wednesday, September 04, 2002 9:48 AM
> > To: struts-user@jakarta.apache.org
> > Subject: Re: Tree Folder navigation
> >
> >
> > Regardles I will be writing a tree that talks to some kind of a
> > bean. (looks
> > like 3 people doing similar, if we can coordinate).
> > Can we coordinate?
> > I can provide temporary CVS (on sf.net - opensource). Then we can offer
it
> > to the Jakarta tags project if you want.
> > If sf.net is a good way for you, then sign up for sf.net user id (free).
> >
> > vicc@users.sourcefroge.net.
> >
> > Vic
> >
> >
> > "Parveen Kumar Hooda" <ph...@ggn.aithent.com> wrote in message
> > news:018e01c25332$73f5bd30$2a0310ac@phooda...
> > > Hi Alex
> > >
> > > Are you looking for a tree type control? If so,then
> > > I have almost developed a tree tag(needs some polishing..) .
> > > This component expects a collection of nodes(the node can have Id ,
> > > parentId , name etc.)
> > > This tag can be used  with struts as well as with plain JSP's.
> > > It is a pure server side component.If  yu want to use it , I
> > can share it.
> > >
> > >
> > > regards
> > >
> > > Pary
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "alex hun" <ji...@singnet.com.sg>
> > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > Sent: Monday, September 02, 2002 9:50 PM
> > > Subject: Tree Folder navigation
> > >
> > >
> > > >
> > > > Hi all,
> > > >
> > > >     I would like to implement tree folder navigation for my project.
> > > However, i
> > > > am quite clueless as to how this is to be done via struts. Has
anyone
> > > tried that
> > > > before or anyone know any resources tat i can refer to? thanks.
> > > >
> > > > regards
> > > > alex
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > >
> > > >
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Tree Folder navigation

Posted by James Mitchell <jm...@telocity.com>.
Why don't you just use the struts project there?

http://sourceforge.net/projects/struts/

James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://www.open-tools.org/struts-atlanta




> -----Original Message-----
> From: news [mailto:news@main.gmane.org]On Behalf Of V. Cekvenich
> Sent: Wednesday, September 04, 2002 9:48 AM
> To: struts-user@jakarta.apache.org
> Subject: Re: Tree Folder navigation
>
>
> Regardles I will be writing a tree that talks to some kind of a
> bean. (looks
> like 3 people doing similar, if we can coordinate).
> Can we coordinate?
> I can provide temporary CVS (on sf.net - opensource). Then we can offer it
> to the Jakarta tags project if you want.
> If sf.net is a good way for you, then sign up for sf.net user id (free).
>
> vicc@users.sourcefroge.net.
>
> Vic
>
>
> "Parveen Kumar Hooda" <ph...@ggn.aithent.com> wrote in message
> news:018e01c25332$73f5bd30$2a0310ac@phooda...
> > Hi Alex
> >
> > Are you looking for a tree type control? If so,then
> > I have almost developed a tree tag(needs some polishing..) .
> > This component expects a collection of nodes(the node can have Id ,
> > parentId , name etc.)
> > This tag can be used  with struts as well as with plain JSP's.
> > It is a pure server side component.If  yu want to use it , I
> can share it.
> >
> >
> > regards
> >
> > Pary
> >
> >
> >
> > ----- Original Message -----
> > From: "alex hun" <ji...@singnet.com.sg>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Monday, September 02, 2002 9:50 PM
> > Subject: Tree Folder navigation
> >
> >
> > >
> > > Hi all,
> > >
> > >     I would like to implement tree folder navigation for my project.
> > However, i
> > > am quite clueless as to how this is to be done via struts. Has anyone
> > tried that
> > > before or anyone know any resources tat i can refer to? thanks.
> > >
> > > regards
> > > alex
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
>
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tree Folder navigation

Posted by "V. Cekvenich" <ne...@att.net>.
Regardles I will be writing a tree that talks to some kind of a bean. (looks
like 3 people doing similar, if we can coordinate).
Can we coordinate?
I can provide temporary CVS (on sf.net - opensource). Then we can offer it
to the Jakarta tags project if you want.
If sf.net is a good way for you, then sign up for sf.net user id (free).

vicc@users.sourcefroge.net.

Vic


"Parveen Kumar Hooda" <ph...@ggn.aithent.com> wrote in message
news:018e01c25332$73f5bd30$2a0310ac@phooda...
> Hi Alex
>
> Are you looking for a tree type control? If so,then
> I have almost developed a tree tag(needs some polishing..) .
> This component expects a collection of nodes(the node can have Id ,
> parentId , name etc.)
> This tag can be used  with struts as well as with plain JSP's.
> It is a pure server side component.If  yu want to use it , I can share it.
>
>
> regards
>
> Pary
>
>
>
> ----- Original Message -----
> From: "alex hun" <ji...@singnet.com.sg>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, September 02, 2002 9:50 PM
> Subject: Tree Folder navigation
>
>
> >
> > Hi all,
> >
> >     I would like to implement tree folder navigation for my project.
> However, i
> > am quite clueless as to how this is to be done via struts. Has anyone
> tried that
> > before or anyone know any resources tat i can refer to? thanks.
> >
> > regards
> > alex
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tree Folder navigation

Posted by BaTien Duong <ba...@dbgroups.com>.
Sounf interesting. I am also interested in making the tree view easier and
faster at client side. Our model is constructed from swing
DefaultMutableTreeNode and DefaultTreeModel using Jndi. Users will have
different views of the tree. I looked at MonkeyTree. If we can bring the
user full view content to the client and use dhtml to control the opening
and closing the nodes, the solution will be more elegant and faster. Let's
share the codes.

----- Original Message -----
From: "alex hun" <ji...@singnet.com.sg>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, September 03, 2002 7:22 AM
Subject: Re: Tree Folder navigation


> Thanks alot. And also to Jacob.  Am working on the code now.  Parveen, i
would
> also like to have a copy of your code. Would like to see how much can i
synergise
> the two codes.  Right now am working towards implementing access control
via
> enabling the user to view only folder which they are able to view.
> cheers
>
>
> "K.Viswanathan" wrote:
>
> > Sounds good! When do you expect it to be ready? Is there a provision for
> > client side scripting too( via say dhtml) ?
> >
> > Thanks
> > Vishy
> >
> > ----- Original Message -----
> > From: "Parveen Kumar Hooda" <ph...@ggn.aithent.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Tuesday, September 03, 2002 3:42 PM
> > Subject: Re: Tree Folder navigation
> >
> > > Hi Alex
> > >
> > > Are you looking for a tree type control? If so,then
> > > I have almost developed a tree tag(needs some polishing..) .
> > > This component expects a collection of nodes(the node can have Id ,
> > > parentId , name etc.)
> > > This tag can be used  with struts as well as with plain JSP's.
> > > It is a pure server side component.If  yu want to use it , I can share
it.
> > >
> > >
> > > regards
> > >
> > > Pary
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "alex hun" <ji...@singnet.com.sg>
> > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > Sent: Monday, September 02, 2002 9:50 PM
> > > Subject: Tree Folder navigation
> > >
> > >
> > > >
> > > > Hi all,
> > > >
> > > >     I would like to implement tree folder navigation for my project.
> > > However, i
> > > > am quite clueless as to how this is to be done via struts. Has
anyone
> > > tried that
> > > > before or anyone know any resources tat i can refer to? thanks.
> > > >
> > > > regards
> > > > alex
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tree Folder navigation

Posted by alex hun <ji...@singnet.com.sg>.
Thanks alot. And also to Jacob.  Am working on the code now.  Parveen, i would
also like to have a copy of your code. Would like to see how much can i synergise
the two codes.  Right now am working towards implementing access control via
enabling the user to view only folder which they are able to view.
cheers


"K.Viswanathan" wrote:

> Sounds good! When do you expect it to be ready? Is there a provision for
> client side scripting too( via say dhtml) ?
>
> Thanks
> Vishy
>
> ----- Original Message -----
> From: "Parveen Kumar Hooda" <ph...@ggn.aithent.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, September 03, 2002 3:42 PM
> Subject: Re: Tree Folder navigation
>
> > Hi Alex
> >
> > Are you looking for a tree type control? If so,then
> > I have almost developed a tree tag(needs some polishing..) .
> > This component expects a collection of nodes(the node can have Id ,
> > parentId , name etc.)
> > This tag can be used  with struts as well as with plain JSP's.
> > It is a pure server side component.If  yu want to use it , I can share it.
> >
> >
> > regards
> >
> > Pary
> >
> >
> >
> > ----- Original Message -----
> > From: "alex hun" <ji...@singnet.com.sg>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Monday, September 02, 2002 9:50 PM
> > Subject: Tree Folder navigation
> >
> >
> > >
> > > Hi all,
> > >
> > >     I would like to implement tree folder navigation for my project.
> > However, i
> > > am quite clueless as to how this is to be done via struts. Has anyone
> > tried that
> > > before or anyone know any resources tat i can refer to? thanks.
> > >
> > > regards
> > > alex
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tree Folder navigation

Posted by "K.Viswanathan" <kv...@ggn.aithent.com>.
Sounds good! When do you expect it to be ready? Is there a provision for
client side scripting too( via say dhtml) ?

Thanks
Vishy

----- Original Message -----
From: "Parveen Kumar Hooda" <ph...@ggn.aithent.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, September 03, 2002 3:42 PM
Subject: Re: Tree Folder navigation


> Hi Alex
>
> Are you looking for a tree type control? If so,then
> I have almost developed a tree tag(needs some polishing..) .
> This component expects a collection of nodes(the node can have Id ,
> parentId , name etc.)
> This tag can be used  with struts as well as with plain JSP's.
> It is a pure server side component.If  yu want to use it , I can share it.
>
>
> regards
>
> Pary
>
>
>
> ----- Original Message -----
> From: "alex hun" <ji...@singnet.com.sg>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, September 02, 2002 9:50 PM
> Subject: Tree Folder navigation
>
>
> >
> > Hi all,
> >
> >     I would like to implement tree folder navigation for my project.
> However, i
> > am quite clueless as to how this is to be done via struts. Has anyone
> tried that
> > before or anyone know any resources tat i can refer to? thanks.
> >
> > regards
> > alex
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tree Folder navigation

Posted by Keven <hi...@yahoo.ca>.
Pary

I am alos interested in your tree tag. Could you please share it?

Thank you very much.

Keven

----- Original Message -----
From: "Parveen Kumar Hooda" <ph...@ggn.aithent.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, September 03, 2002 6:12 AM
Subject: Re: Tree Folder navigation


> Hi Alex
>
> Are you looking for a tree type control? If so,then
> I have almost developed a tree tag(needs some polishing..) .
> This component expects a collection of nodes(the node can have Id ,
> parentId , name etc.)
> This tag can be used  with struts as well as with plain JSP's.
> It is a pure server side component.If  yu want to use it , I can share it.
>
>
> regards
>
> Pary
>
>
>
> ----- Original Message -----
> From: "alex hun" <ji...@singnet.com.sg>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, September 02, 2002 9:50 PM
> Subject: Tree Folder navigation
>
>
> >
> > Hi all,
> >
> >     I would like to implement tree folder navigation for my project.
> However, i
> > am quite clueless as to how this is to be done via struts. Has anyone
> tried that
> > before or anyone know any resources tat i can refer to? thanks.
> >
> > regards
> > alex
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Tree Folder navigation

Posted by jzakarian <jz...@crossstreettrade.com>.
Can you put it on the web so others can also use it?
I would be interested since the collection of nodes could be read in
from a database or other store (XML). This would make the menu very
dynamic.

jack

-----Original Message-----
From: Parveen Kumar Hooda [mailto:phooda@ggn.aithent.com] 
Sent: Tuesday, September 03, 2002 6:13 AM
To: Struts Users Mailing List
Subject: Re: Tree Folder navigation

Hi Alex

Are you looking for a tree type control? If so,then
I have almost developed a tree tag(needs some polishing..) .
This component expects a collection of nodes(the node can have Id ,
parentId , name etc.)
This tag can be used  with struts as well as with plain JSP's.
It is a pure server side component.If  yu want to use it , I can share
it.


regards

Pary



----- Original Message -----
From: "alex hun" <ji...@singnet.com.sg>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, September 02, 2002 9:50 PM
Subject: Tree Folder navigation


>
> Hi all,
>
>     I would like to implement tree folder navigation for my project.
However, i
> am quite clueless as to how this is to be done via struts. Has anyone
tried that
> before or anyone know any resources tat i can refer to? thanks.
>
> regards
> alex
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tree Folder navigation

Posted by Parveen Kumar Hooda <ph...@ggn.aithent.com>.
Hi Alex

Are you looking for a tree type control? If so,then
I have almost developed a tree tag(needs some polishing..) .
This component expects a collection of nodes(the node can have Id ,
parentId , name etc.)
This tag can be used  with struts as well as with plain JSP's.
It is a pure server side component.If  yu want to use it , I can share it.


regards

Pary



----- Original Message -----
From: "alex hun" <ji...@singnet.com.sg>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, September 02, 2002 9:50 PM
Subject: Tree Folder navigation


>
> Hi all,
>
>     I would like to implement tree folder navigation for my project.
However, i
> am quite clueless as to how this is to be done via struts. Has anyone
tried that
> before or anyone know any resources tat i can refer to? thanks.
>
> regards
> alex
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Tree Folder navigation

Posted by Jacob Hookom <ho...@uwec.edu>.
I think there's a struts menu at source forge, I'm not sure of the link,
but it would be easy to search.

| -----Original Message-----
| From: alex hun [mailto:jitboon@singnet.com.sg]
| Sent: Monday, September 02, 2002 11:20 AM
| To: Struts Users Mailing List
| Subject: Tree Folder navigation
| 
| 
| Hi all,
| 
|     I would like to implement tree folder navigation for my project.
| However, i
| am quite clueless as to how this is to be done via struts. Has anyone
| tried that
| before or anyone know any resources tat i can refer to? thanks.
| 
| regards
| alex
| 
| 
| 
| --
| To unsubscribe, e-mail:   <mailto:struts-user-
| unsubscribe@jakarta.apache.org>
| For additional commands, e-mail: <mailto:struts-user-
| help@jakarta.apache.org>
| 
| ---
| Incoming mail is certified Virus Free.
| Checked by AVG anti-virus system (http://www.grisoft.com).
| Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/2002
| 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/2002
 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Tree Folder navigation

Posted by alex hun <ji...@singnet.com.sg>.
Hi all,

    I would like to implement tree folder navigation for my project.  However, i
am quite clueless as to how this is to be done via struts. Has anyone tried that
before or anyone know any resources tat i can refer to? thanks.

regards
alex



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Database Connection in Logic Beans - pooling?

Posted by Frederic Laub <in...@012.net.il>.
Hi,

How do achieve the following:
In some cases I want to get a connection at the beginning of a request
(request scope), pass the same connection to all the java beans that are
called in the request and return the connection at the end of the request.
Where do I put the code to return the connection to the pool at the end of
the request and in case of an error be sure that the connection is returned
to the pool?
A same connection is required when all DML statements throughout a request
are part of a same transaction.
The commit (or rollback in case of an error) statement is issued at the end
of the request before the connection is returned to the pool.
Sorry if the vocabulary I used is database oriented and not 100 %
java/struts compatible.

Your help will be appreciated.
Frederic


-----Original Message-----
From: thart@part.net [mailto:thart@part.net]
Sent: Monday, September 02, 2002 9:06 AM
To: Struts Users Mailing List
Subject: Re: Database Connection in Logic Beans - pooling?


Steve McLeod writes:

> I am using:
> Tomcat 4.0
> Struts 1.0.2
>
> The problem
> ========
>
> I have successfully used the Struts database connection pooling in a trial
> web app, but as far as I can tell, a reference to the datasource can only
be
> obtained from within an Action class (or directly within a JSP page but
> let's not think about that today).
>
> However I would like to have logic beans which handle database access,
> rather than have this in the Action class. But I can't get a reference to
> the datasource from the logic bean because it doesn't have a
ServletContext
> to which I can get a handle.
>
> I have toyed with various ideas:
> - Initialise a logic bean by passing it a reference to the Servlet
> - Acquire a connection in the Action class and pass that to the bean
>
> But really, I would rather the logic bean know inherently how to acquire a
> database connection.
>
> My current workaround is to not use the Struts connection pooling, and
> rather to manually create a connection each time database access needs to
be
> done, then destroy it. But this is clearly not suitable for our production
> environment.

There are a few ways to solve your problem. One way would be to bind a
datasource to some JNDI name that your logic beans are aware of. Then, using
that name, your logic beans can lookup the datasource completely independent
of struts.

Give it a try,

Troy

>
>
> The context of my problem
> ==================
>
> I want to use some code like this in a JSP:
>
> <jsp:useBean id="abean" scope="page"
> class="au.com.sunesis.timesheets.ClientManager" />
> <table border="1">
>     <tr>
>         <th>#</th>
>         <th>Client</th>
>         <th>Active</th>
>     </tr>
> <logic:iterate id="clientList" name="abean" property="clients"
> type="au.com.sunesis.timesheets.Client">
>     <tr>
>         <td><bean:write name="clientList" property="clientID"/></td>
>         <td><bean:write name="clientList" property="clientName"/></td>
>         <td><bean:write name="clientList" property="active"/></td>
>     </tr>
> </logic:iterate>
>
>
> The idea is that ClientManager is used to handle all general database
tasks
> for the Client bean (which maps to a Client entity in the database).
> ClientManager.getClients() connects to the database, creates an ArrayList
of
> Client objects, one for each row in the database, and returns the
ArrayList.
>
> ClientManager has other methods, such as:
> -         ClientManager.delete(Client c), which deletes the row in the
> database entity corresponding to the specified client.
> -         ClientManager.findByPrimaryKey(int ID) which returns the Client
> which matches the specified ID
> -         ClientManager.save(Client c), which stores the client in the
> database, creating or updating as necessary
>
> So an Action class can also call any of these directly, and it really
> shouldn't care about how these work and how they store to/retrieve from
the
> database. But I can't think of the elegant way to do this and still be
able
> to use the Struts connection pooling.
>
> Any thoughts?
>
> Thanks
>
> Steve McLeod
>
>
>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Database Connection in Logic Beans - pooling?

Posted by th...@part.net.
Steve McLeod writes: 

> I am using:
> Tomcat 4.0
> Struts 1.0.2
>  
> The problem
> ========
>  
> I have successfully used the Struts database connection pooling in a trial
> web app, but as far as I can tell, a reference to the datasource can only be
> obtained from within an Action class (or directly within a JSP page but
> let's not think about that today).
>  
> However I would like to have logic beans which handle database access,
> rather than have this in the Action class. But I can't get a reference to
> the datasource from the logic bean because it doesn't have a ServletContext
> to which I can get a handle.
>  
> I have toyed with various ideas:
> - Initialise a logic bean by passing it a reference to the Servlet
> - Acquire a connection in the Action class and pass that to the bean
>  
> But really, I would rather the logic bean know inherently how to acquire a
> database connection.
>  
> My current workaround is to not use the Struts connection pooling, and
> rather to manually create a connection each time database access needs to be
> done, then destroy it. But this is clearly not suitable for our production
> environment.

There are a few ways to solve your problem. One way would be to bind a 
datasource to some JNDI name that your logic beans are aware of. Then, using 
that name, your logic beans can lookup the datasource completely independent 
of struts. 

Give it a try, 

Troy 

>  
>  
> The context of my problem
> ==================
>  
> I want to use some code like this in a JSP:
>  
> <jsp:useBean id="abean" scope="page"
> class="au.com.sunesis.timesheets.ClientManager" />
> <table border="1">
>     <tr>
>         <th>#</th>
>         <th>Client</th>
>         <th>Active</th>
>     </tr>
> <logic:iterate id="clientList" name="abean" property="clients"
> type="au.com.sunesis.timesheets.Client">
>     <tr>
>         <td><bean:write name="clientList" property="clientID"/></td>
>         <td><bean:write name="clientList" property="clientName"/></td>
>         <td><bean:write name="clientList" property="active"/></td>
>     </tr>
> </logic:iterate>
>  
>  
> The idea is that ClientManager is used to handle all general database tasks
> for the Client bean (which maps to a Client entity in the database).
> ClientManager.getClients() connects to the database, creates an ArrayList of
> Client objects, one for each row in the database, and returns the ArrayList.
>  
> ClientManager has other methods, such as:
> -         ClientManager.delete(Client c), which deletes the row in the
> database entity corresponding to the specified client.
> -         ClientManager.findByPrimaryKey(int ID) which returns the Client
> which matches the specified ID
> -         ClientManager.save(Client c), which stores the client in the
> database, creating or updating as necessary
>  
> So an Action class can also call any of these directly, and it really
> shouldn't care about how these work and how they store to/retrieve from the
> database. But I can't think of the elegant way to do this and still be able
> to use the Struts connection pooling.
>  
> Any thoughts?
>  
> Thanks
>  
> Steve McLeod
>  
>  
>  
 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Database Connection in Logic Beans - pooling?

Posted by Miguel Angel Mulero Martinez <mi...@mad.tecsidel.es>.
You can too use the DBCP from jakarta, I'm using it and works perfectly:

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how
to.html



-----Mensaje original-----
De: Steve McLeod [mailto:steve.mcleod@ingena.com.au]
Enviado el: lunes, 02 de septiembre de 2002 2:10
Para: 'struts-user@jakarta.apache.org'
Asunto: Database Connection in Logic Beans - pooling?

I am using:
Tomcat 4.0
Struts 1.0.2

The problem
========

I have successfully used the Struts database connection pooling in a
trial
web app, but as far as I can tell, a reference to the datasource can
only be
obtained from within an Action class (or directly within a JSP page but
let's not think about that today).

However I would like to have logic beans which handle database access,
rather than have this in the Action class. But I can't get a reference
to
the datasource from the logic bean because it doesn't have a
ServletContext
to which I can get a handle.

I have toyed with various ideas:
- Initialise a logic bean by passing it a reference to the Servlet
- Acquire a connection in the Action class and pass that to the bean

But really, I would rather the logic bean know inherently how to acquire
a
database connection.

My current workaround is to not use the Struts connection pooling, and
rather to manually create a connection each time database access needs
to be
done, then destroy it. But this is clearly not suitable for our
production
environment.


The context of my problem
==================

I want to use some code like this in a JSP:

<jsp:useBean id="abean" scope="page"
class="au.com.sunesis.timesheets.ClientManager" />
<table border="1">
    <tr>
        <th>#</th>
        <th>Client</th>
        <th>Active</th>
    </tr>
<logic:iterate id="clientList" name="abean" property="clients"
type="au.com.sunesis.timesheets.Client">
    <tr>
        <td><bean:write name="clientList" property="clientID"/></td>
        <td><bean:write name="clientList" property="clientName"/></td>
        <td><bean:write name="clientList" property="active"/></td>
    </tr>
</logic:iterate>


The idea is that ClientManager is used to handle all general database
tasks
for the Client bean (which maps to a Client entity in the database).
ClientManager.getClients() connects to the database, creates an
ArrayList of
Client objects, one for each row in the database, and returns the
ArrayList.

ClientManager has other methods, such as:
-         ClientManager.delete(Client c), which deletes the row in the
database entity corresponding to the specified client.
-         ClientManager.findByPrimaryKey(int ID) which returns the
Client
which matches the specified ID
-         ClientManager.save(Client c), which stores the client in the
database, creating or updating as necessary

So an Action class can also call any of these directly, and it really
shouldn't care about how these work and how they store to/retrieve from
the
database. But I can't think of the elegant way to do this and still be
able
to use the Struts connection pooling.

Any thoughts?

Thanks

Steve McLeod




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>