On 14/01/2011 05:57, Schultz, Gary T - COMMERCE wrote:
> Thanks for the information, I have read the Tomcat jdni resources how to. I 
> also found the following to help myself understand:
> 
> http://www.datadisk.co.uk/html_docs/java_app/tomcat6/tomcat6_jdbc.htm
> 
> http://www.mulesoft.com/tomcat-mysql
> 
> I guess my confusion stills exists in how Click is actually referencing the 
> data source. In looking at the examples I can't figure it out. Maybe my lack 
> of knowledge in ORM is hindering my ability to comprehend this.

Just to clarify, Click is only a view layer and doesn't do any DB work for you. 
It doesn't reference
the data source. But I think what you mean is how do you lookup the data source 
yourself?

In your second link they have this:

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/[YourResourceName]");
// Here you can use ds

Also note that Click is built on the Servlet API. You can get access to the 
Servlet API through the
org.apache.click.Context object. In a page do:

Context ctx = getContext();
ctx.getRequest();
ctx.getResponse();
etc.

In a Service object you can get access to the Context object like so:
Context ctx = Context.getThreadLocalContext();
getContext().getRequest();
getContext().getResponse();


Hope this helps.

Kind regards

Bob

Reply via email to