You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stanczak Group <ju...@stanczakgroup.com> on 2007/10/04 16:18:44 UTC

RequestCycle?

How can I access the request cycle so I can open and close a Hibernate 
session on each request?

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RequestCycle?

Posted by Stanczak Group <ju...@stanczakgroup.com>.
I see DataBinder is just casting them and using WebRequestCycle, is that 
the right way?

Stanczak Group wrote:
> If I create my own request cycle, then what class do I extend? 
> RequestCycle, WebRequestCycle or... ? RequestCycle requires you to 
> implement other methods? Is there a wrapper class?
>
> Stanczak Group wrote:
>> I'm not for sure what to use. I tried to override the 
>> newRequestCycle() but I had trouble understanding it. I'm doing 
>> something like what DataBinder does, but with 1.3. DataBinder seems 
>> to be 1.2. Either way I'd rather use my own. Does anyone have an 
>> example of providing my own request cycle, or is there an easier way?
>>
>> Sam Hough wrote:
>>> I think it is setup with ThreadLocal so you can get it easily with
>>> RequestCycle.get(). You can also provide your own version from
>>> Application.newRequestCycle which might be more what you need to 
>>> hook in
>>> start/end events.
>>>
>>>
>>>
>>> Stanczak Group wrote:
>>>  
>>>> How can I access the request cycle so I can open and close a 
>>>> Hibernate session on each request?
>>>>
>>>> -- 
>>>> Justin Stanczak
>>>> Stanczak Group
>>>> 812-735-3600
>>>>
>>>> "All that is necessary for the triumph of evil is that good men do
>>>> nothing."
>>>> Edmund Burke
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>     
>>>
>>>   
>>
>

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RequestCycle?

Posted by Stanczak Group <ju...@stanczakgroup.com>.
If I create my own request cycle, then what class do I extend? 
RequestCycle, WebRequestCycle or... ? RequestCycle requires you to 
implement other methods? Is there a wrapper class?

Stanczak Group wrote:
> I'm not for sure what to use. I tried to override the 
> newRequestCycle() but I had trouble understanding it. I'm doing 
> something like what DataBinder does, but with 1.3. DataBinder seems to 
> be 1.2. Either way I'd rather use my own. Does anyone have an example 
> of providing my own request cycle, or is there an easier way?
>
> Sam Hough wrote:
>> I think it is setup with ThreadLocal so you can get it easily with
>> RequestCycle.get(). You can also provide your own version from
>> Application.newRequestCycle which might be more what you need to hook in
>> start/end events.
>>
>>
>>
>> Stanczak Group wrote:
>>  
>>> How can I access the request cycle so I can open and close a 
>>> Hibernate session on each request?
>>>
>>> -- 
>>> Justin Stanczak
>>> Stanczak Group
>>> 812-735-3600
>>>
>>> "All that is necessary for the triumph of evil is that good men do
>>> nothing."
>>> Edmund Burke
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>     
>>
>>   
>

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Re[4]: RequestCycle?

Posted by ChuckDeal <cd...@csc.com>.
Yeah, that happened to me this week as well, but it was working over the
weekend as well as this morning, so try it again.

Chuck


Taranenko wrote:
> 
> Yeah web server is alive... what about svn server? I can not update
> sources :( 
> 
> 
> C:\opensource\net\databinder\trunk&gt;svn update 
> svn: Can't connect to host 'databinder.net': A connection attempt failed
> because the connected party did not properly respond after a period of
> time, or established connection failed because connected host has failed
> to respond. 
> 
> svn checkout svn://databinder.net/databinder/trunk does not respond too. 
> 
> 
> 
> MD&gt;&nbsp;Works&nbsp;for&nbsp;me...&nbsp;Apparently&nbsp;Nathan&nbsp;(or&nbsp;his&nbsp;ISP)&nbsp;has&nbsp;shut&nbsp;down&nbsp;the 
> MD&gt;&nbsp;pingd.&nbsp;The&nbsp;website&nbsp;is&nbsp;still&nbsp;alive! 
> 
> MD&gt;&nbsp;Martijn 
> 
> MD&gt;&nbsp;Result&nbsp;of&nbsp;the&nbsp;page&nbsp;in&nbsp;my&nbsp;browser: 
> 
> MD&gt;&nbsp;Toolkit&nbsp;overview 
> MD&gt;&nbsp;Databinder&nbsp;is&nbsp;a&nbsp;Java&nbsp;programming&nbsp;toolkit&nbsp;for&nbsp;data&#8211;driven&nbsp;Web 
> MD&gt;&nbsp;applications.&nbsp;It's&nbsp;based&nbsp;upon&nbsp;the&nbsp;Wicket&nbsp;Web&nbsp;component&nbsp;framework&nbsp;and 
> MD&gt;&nbsp;Hibernate&nbsp;object-relational&nbsp;mapping&nbsp;service.&nbsp;Generally&nbsp;preferring 
> MD&gt;&nbsp;creativity&nbsp;over&nbsp;convention,&nbsp;Databinder's&nbsp;aim&nbsp;is&nbsp;to&nbsp;facilitate&nbsp;database 
> MD&gt;&nbsp;programming&nbsp;for&nbsp;the&nbsp;Web&nbsp;that&nbsp;is&nbsp;straightforward,&nbsp;pleasant,&nbsp;and 
> MD&gt;&nbsp;flexible. 
> MD&gt;&nbsp;How&nbsp;it&nbsp;works 
> MD&gt;&nbsp;Databinder&nbsp;provides&nbsp;you&nbsp;with&nbsp;Wicket&nbsp;models&nbsp;that&nbsp;populate&nbsp;themselves 
> MD&gt;&nbsp;using&nbsp;a&nbsp;lightly&nbsp;managed&nbsp;Hibernate&nbsp;session,&nbsp;and&nbsp;a&nbsp;collection&nbsp;of&nbsp;view 
> MD&gt;&nbsp;components&nbsp;that&nbsp;bind&nbsp;to&nbsp;them&nbsp;automatically.&nbsp;In&nbsp;your&nbsp;application, 
> MD&gt;&nbsp;instances&nbsp;of&nbsp;annotated&nbsp;data&nbsp;classes&nbsp;rest&nbsp;in&nbsp;these&nbsp;models,&nbsp;rendering 
> MD&gt;&nbsp;(and&nbsp;updating)&nbsp;through&nbsp;a&nbsp;view&nbsp;component&nbsp;tree&nbsp;and&nbsp;plain&nbsp;HTML&nbsp;templates. 
> MD&gt;&nbsp;Screencasts 
> 
> 
> 
> 
> --&nbsp; 
> Best&nbsp;regards, 
> &nbsp;Oleg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> mailto:OlegTaranenko@web.de 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/RequestCycle--tf4569125.html#a13094718
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Re[2]: RequestCycle?

Posted by Martijn Dashorst <ma...@gmail.com>.
Works for me... Apparently Nathan (or his ISP) has shut down the
pingd. The website is still alive!

Martijn

Result of the page in my browser:

Toolkit overview
Databinder is a Java programming toolkit for data–driven Web
applications. It's based upon the Wicket Web component framework and
Hibernate object-relational mapping service. Generally preferring
creativity over convention, Databinder's aim is to facilitate database
programming for the Web that is straightforward, pleasant, and
flexible.
How it works
Databinder provides you with Wicket models that populate themselves
using a lightly managed Hibernate session, and a collection of view
components that bind to them automatically. In your application,
instances of annotated data classes rest in these models, rendering
(and updating) through a view component tree and plain HTML templates.
Screencasts

-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RequestCycle?

Posted by ChuckDeal <cd...@csc.com>.
I don't know that 1.1 has a tar.  My project uses maven, so it was a snap to
add the Databinder bits to our pom.

Here is the page that gives the databinder snapshot repo info:
http://databinder.net/site/show/faq#updates

If you don't use maven, I could always send a 1.1-SNAPSHOT directly to
you...

FYI, The databinder site has some examples that help with learning how to
use and adapt the code to your own project.

Chuck


Stanczak Group wrote:
> 
> Probably not. I'll probably use it when I get a chance. I just 
> downloaded the 1.0 tar and saw it's using 1.2 Wicket. Shot me the link 
> and I'll see if I can give it a shot tonight.
> 
> ChuckDeal wrote:
>> Stanczak Group wrote:
>>   
>>> I'm not for sure what to use. I tried to override the newRequestCycle() 
>>> but I had trouble understanding it. I'm doing something like what 
>>> DataBinder does, but with 1.3. DataBinder seems to be 1.2. Either way 
>>> I'd rather use my own. Does anyone have an example of providing my own 
>>> request cycle, or is there an easier way?
>>>
>>> Sam Hough wrote:
>>>     
>>>> I think it is setup with ThreadLocal so you can get it easily with
>>>> RequestCycle.get(). You can also provide your own version from
>>>> Application.newRequestCycle which might be more what you need to hook
>>>> in
>>>> start/end events.
>>>>
>>>>
>>>>
>>>> Stanczak Group wrote:
>>>>   
>>>>       
>>>>> How can I access the request cycle so I can open and close a Hibernate 
>>>>> session on each request?
>>>>>
>>>>> -- 
>>>>> Justin Stanczak
>>>>> Stanczak Group
>>>>> 812-735-3600
>>>>>         
>>
>> DataBinder (1.1-SNAPSHOT) definitely works with 1.3.  Databinder also
>> does a
>> pretty good job of integrating Hibernate into the Wicket models.  Is
>> there a
>> use case for which Databinder does not work for you?
>>
>> Chuck
>>   
> 
> -- 
> Justin Stanczak
> Stanczak Group
> 812-735-3600
> 
> "All that is necessary for the triumph of evil is that good men do
> nothing."
> Edmund Burke
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/RequestCycle--tf4569125.html#a13047854
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RequestCycle?

Posted by Stanczak Group <ju...@stanczakgroup.com>.
Probably not. I'll probably use it when I get a chance. I just 
downloaded the 1.0 tar and saw it's using 1.2 Wicket. Shot me the link 
and I'll see if I can give it a shot tonight.

ChuckDeal wrote:
> Stanczak Group wrote:
>   
>> I'm not for sure what to use. I tried to override the newRequestCycle() 
>> but I had trouble understanding it. I'm doing something like what 
>> DataBinder does, but with 1.3. DataBinder seems to be 1.2. Either way 
>> I'd rather use my own. Does anyone have an example of providing my own 
>> request cycle, or is there an easier way?
>>
>> Sam Hough wrote:
>>     
>>> I think it is setup with ThreadLocal so you can get it easily with
>>> RequestCycle.get(). You can also provide your own version from
>>> Application.newRequestCycle which might be more what you need to hook in
>>> start/end events.
>>>
>>>
>>>
>>> Stanczak Group wrote:
>>>   
>>>       
>>>> How can I access the request cycle so I can open and close a Hibernate 
>>>> session on each request?
>>>>
>>>> -- 
>>>> Justin Stanczak
>>>> Stanczak Group
>>>> 812-735-3600
>>>>         
>
> DataBinder (1.1-SNAPSHOT) definitely works with 1.3.  Databinder also does a
> pretty good job of integrating Hibernate into the Wicket models.  Is there a
> use case for which Databinder does not work for you?
>
> Chuck
>   

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RequestCycle?

Posted by ChuckDeal <cd...@csc.com>.

Stanczak Group wrote:
> 
> I'm not for sure what to use. I tried to override the newRequestCycle() 
> but I had trouble understanding it. I'm doing something like what 
> DataBinder does, but with 1.3. DataBinder seems to be 1.2. Either way 
> I'd rather use my own. Does anyone have an example of providing my own 
> request cycle, or is there an easier way?
> 
> Sam Hough wrote:
>> I think it is setup with ThreadLocal so you can get it easily with
>> RequestCycle.get(). You can also provide your own version from
>> Application.newRequestCycle which might be more what you need to hook in
>> start/end events.
>>
>>
>>
>> Stanczak Group wrote:
>>   
>>> How can I access the request cycle so I can open and close a Hibernate 
>>> session on each request?
>>>
>>> -- 
>>> Justin Stanczak
>>> Stanczak Group
>>> 812-735-3600
> 

DataBinder (1.1-SNAPSHOT) definitely works with 1.3.  Databinder also does a
pretty good job of integrating Hibernate into the Wicket models.  Is there a
use case for which Databinder does not work for you?

Chuck
-- 
View this message in context: http://www.nabble.com/RequestCycle--tf4569125.html#a13046998
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RequestCycle?

Posted by Stanczak Group <ju...@stanczakgroup.com>.
I'm not for sure what to use. I tried to override the newRequestCycle() 
but I had trouble understanding it. I'm doing something like what 
DataBinder does, but with 1.3. DataBinder seems to be 1.2. Either way 
I'd rather use my own. Does anyone have an example of providing my own 
request cycle, or is there an easier way?

Sam Hough wrote:
> I think it is setup with ThreadLocal so you can get it easily with
> RequestCycle.get(). You can also provide your own version from
> Application.newRequestCycle which might be more what you need to hook in
> start/end events.
>
>
>
> Stanczak Group wrote:
>   
>> How can I access the request cycle so I can open and close a Hibernate 
>> session on each request?
>>
>> -- 
>> Justin Stanczak
>> Stanczak Group
>> 812-735-3600
>>
>> "All that is necessary for the triumph of evil is that good men do
>> nothing."
>> Edmund Burke
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>>     
>
>   

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RequestCycle?

Posted by Sam Hough <sa...@redspr.com>.
I think it is setup with ThreadLocal so you can get it easily with
RequestCycle.get(). You can also provide your own version from
Application.newRequestCycle which might be more what you need to hook in
start/end events.



Stanczak Group wrote:
> 
> How can I access the request cycle so I can open and close a Hibernate 
> session on each request?
> 
> -- 
> Justin Stanczak
> Stanczak Group
> 812-735-3600
> 
> "All that is necessary for the triumph of evil is that good men do
> nothing."
> Edmund Burke
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/RequestCycle--tf4569125.html#a13041123
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RequestCycle?

Posted by Stanczak Group <ju...@stanczakgroup.com>.
Ok, thanks. This is what I did.

public class RequestCycleImpl extends WebRequestCycle {

    private Session hibernateSession;

    public RequestCycleImpl(Application application, Request request, 
Response response) {
        super(application, (WebRequest) request, response);
    }

    @Override
    protected void onBeginRequest() {
        this.hibernateSession = 
HibernateUtil.getSessionFactory().openSession();
    }

    @Override
    protected void onEndRequest() {
        if (this.hibernateSession != null) {
            this.hibernateSession.close();
        }
    }

    public Session getHibernateSession() {
        return hibernateSession;
    }
}

Eelco Hillenius wrote:
> On 10/4/07, Stanczak Group <ju...@stanczakgroup.com> wrote:
>   
>> How can I access the request cycle so I can open and close a Hibernate
>> session on each request?
>>     
>
> In your application class:
>
> 	@Override
> 	public RequestCycle newRequestCycle(Request request, Response response)
> 	{
> 		return new WebRequestCycle(this, (WebRequest)request, response)
> 		{
> 			@Override
> 			protected void onBeginRequest()
> 			{
> 				// open session
> 			}
>
> 			@Override
> 			protected void onEndRequest()
> 			{
> 				// close session
> 			}
> 		};
> 	}
>
> If you use Spring for instance, you could just configure the hibernate
> session filter that comes with it instead.
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>   

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RequestCycle?

Posted by Eelco Hillenius <ee...@gmail.com>.
On 10/4/07, Stanczak Group <ju...@stanczakgroup.com> wrote:
> How can I access the request cycle so I can open and close a Hibernate
> session on each request?

In your application class:

	@Override
	public RequestCycle newRequestCycle(Request request, Response response)
	{
		return new WebRequestCycle(this, (WebRequest)request, response)
		{
			@Override
			protected void onBeginRequest()
			{
				// open session
			}

			@Override
			protected void onEndRequest()
			{
				// close session
			}
		};
	}

If you use Spring for instance, you could just configure the hibernate
session filter that comes with it instead.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org