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/02 22:13:39 UTC
Using Hibernate in Wicket?
I'm using Hibernate with the HibernateUtil class. It all works except
when I try to use the HibernateUtil in the Application.onDestroy()
method. I want to have it close the factory when the server is shutdown.
It's an embedded database so it's saying the database is locked. This
looks to me like the Application is running in one thread and the Pages
in another. It's like the HibernateUtil static code is running twice.
Is there a better way of using Hibernate in Wicket? Here's the code I'm
using now.
###########################################################################
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new
Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed."
+ ex);
throw new ExceptionInInitializerError(ex);
}...
#############################Application#####################################
... @Override
protected void onDestroy() {
System.out.println("Killing database connection\n\n");
HibernateUtil.getSessionFactory().close();
}....
###########################################################################
--
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: Getting started with Hibernate and Wicket
Posted by Landry Soules <la...@gmail.com>.
You will find good examples here :
http://www.wicketstuff.org/wicket13/repeater/
and
http://cwiki.apache.org/WICKET/reading-from-a-database.html
Neil B. Cohen a écrit :
> I'm trying to learn both Hibernate and Wicket at the same time, and I
> could use a couple of pointers...
>
> I have managed to take the Wicket 'signin' example and added a tiny
> Hibernate database which I can access to extract a 'User' object to
> validate the user's name and password. That works fine...
>
> But now I would like to be able to pull a list of objects (Users) out
> of the database and display them in a table on a new page (with
> columns like 'userName, 'emailAddr', 'Role' etc. etc.) I think I can
> get the list of data from the database using Hibernate (although I'm
> not sure the best way to manage a table if it has thousands of rows,
> which mine will eventually have...) But I'm not sure how to set up the
> Wicket page to display that data. Can someone point me at some simple
> table examples that would do that??
>
> thanks very much,
>
> nbc
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Getting started with Hibernate and Wicket
Posted by Tauren Mills <ta...@tauren.com>.
Wicketstuff Phonebook is a good starting place for
wicket/spring/hibernate integration:
http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-phonebook
On 10/3/07, Alexandre Bairos <al...@gmail.com> wrote:
> http://databinder.net does a good job.
>
> On 10/3/07, Neil B. Cohen <nc...@verisign.com> wrote:
> >
> > I'm trying to learn both Hibernate and Wicket at the same time, and I
> > could use a couple of pointers...
> >
> > I have managed to take the Wicket 'signin' example and added a tiny
> > Hibernate database which I can access to extract a 'User' object to
> > validate the user's name and password. That works fine...
> >
> > But now I would like to be able to pull a list of objects (Users) out of
> > the database and display them in a table on a new page (with columns
> > like 'userName, 'emailAddr', 'Role' etc. etc.) I think I can get the
> > list of data from the database using Hibernate (although I'm not sure
> > the best way to manage a table if it has thousands of rows, which mine
> > will eventually have...) But I'm not sure how to set up the Wicket page
> > to display that data. Can someone point me at some simple table examples
> > that would do that??
> >
> > thanks very much,
> >
> > nbc
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Dumb question about page transfer
Posted by "Neil B. Cohen" <nc...@verisign.com>.
Igor Vaynberg wrote:
> onsubmit() {
> setresponsepage(MyPage.class);
> or
> setresponsepage(new MyPage(...));
> }
>
> -igor
>
Thanks for the quick response...
Much obliged,
nbc
>
> On 10/3/07, Neil B. Cohen <nc...@verisign.com> wrote:
>
>> Ok - I'm feeling kind of stupid at the moment, but I'm missing something
>> basic here...
>>
>> I have a Wicket web page displayed with a button on it. When I click the
>> button, the onSubmit routine fires
>> and my java code logs a message so I know it is working. But from there,
>> I want to transfer to another
>> page, and I don't see how to specify that. I'm sure I'm looking at the
>> forest and missing the tree, but I'd appreciate it if someone would aim
>> me in the right direction...
>>
>> thanks,
>>
>> nbc
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Dumb question about page transfer
Posted by Igor Vaynberg <ig...@gmail.com>.
onsubmit() {
setresponsepage(MyPage.class);
or
setresponsepage(new MyPage(...));
}
-igor
On 10/3/07, Neil B. Cohen <nc...@verisign.com> wrote:
>
> Ok - I'm feeling kind of stupid at the moment, but I'm missing something
> basic here...
>
> I have a Wicket web page displayed with a button on it. When I click the
> button, the onSubmit routine fires
> and my java code logs a message so I know it is working. But from there,
> I want to transfer to another
> page, and I don't see how to specify that. I'm sure I'm looking at the
> forest and missing the tree, but I'd appreciate it if someone would aim
> me in the right direction...
>
> thanks,
>
> nbc
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Dumb question about page transfer
Posted by Nick Heudecker <nh...@gmail.com>.
You're looking for the setResponsePage(...) methods.
On 10/3/07, Neil B. Cohen <nc...@verisign.com> wrote:
>
> Ok - I'm feeling kind of stupid at the moment, but I'm missing something
> basic here...
>
> I have a Wicket web page displayed with a button on it. When I click the
> button, the onSubmit routine fires
> and my java code logs a message so I know it is working. But from there,
> I want to transfer to another
> page, and I don't see how to specify that. I'm sure I'm looking at the
> forest and missing the tree, but I'd appreciate it if someone would aim
> me in the right direction...
>
> thanks,
>
> nbc
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Nick Heudecker
Professional Wicket Training & Consulting
http://www.systemmobile.com
Eventful - Intelligent Event Management
http://www.eventfulhq.com
Dumb question about page transfer
Posted by "Neil B. Cohen" <nc...@verisign.com>.
Ok - I'm feeling kind of stupid at the moment, but I'm missing something
basic here...
I have a Wicket web page displayed with a button on it. When I click the
button, the onSubmit routine fires
and my java code logs a message so I know it is working. But from there,
I want to transfer to another
page, and I don't see how to specify that. I'm sure I'm looking at the
forest and missing the tree, but I'd appreciate it if someone would aim
me in the right direction...
thanks,
nbc
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Getting started with Hibernate and Wicket
Posted by Alexandre Bairos <al...@gmail.com>.
http://databinder.net does a good job.
On 10/3/07, Neil B. Cohen <nc...@verisign.com> wrote:
>
> I'm trying to learn both Hibernate and Wicket at the same time, and I
> could use a couple of pointers...
>
> I have managed to take the Wicket 'signin' example and added a tiny
> Hibernate database which I can access to extract a 'User' object to
> validate the user's name and password. That works fine...
>
> But now I would like to be able to pull a list of objects (Users) out of
> the database and display them in a table on a new page (with columns
> like 'userName, 'emailAddr', 'Role' etc. etc.) I think I can get the
> list of data from the database using Hibernate (although I'm not sure
> the best way to manage a table if it has thousands of rows, which mine
> will eventually have...) But I'm not sure how to set up the Wicket page
> to display that data. Can someone point me at some simple table examples
> that would do that??
>
> thanks very much,
>
> nbc
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Getting started with Hibernate and Wicket
Posted by "Neil B. Cohen" <nc...@verisign.com>.
I'm trying to learn both Hibernate and Wicket at the same time, and I
could use a couple of pointers...
I have managed to take the Wicket 'signin' example and added a tiny
Hibernate database which I can access to extract a 'User' object to
validate the user's name and password. That works fine...
But now I would like to be able to pull a list of objects (Users) out of
the database and display them in a table on a new page (with columns
like 'userName, 'emailAddr', 'Role' etc. etc.) I think I can get the
list of data from the database using Hibernate (although I'm not sure
the best way to manage a table if it has thousands of rows, which mine
will eventually have...) But I'm not sure how to set up the Wicket page
to display that data. Can someone point me at some simple table examples
that would do that??
thanks very much,
nbc
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Using Hibernate in Wicket?
Posted by Stanczak Group <ju...@stanczakgroup.com>.
Thanks. They are pretty much doing the same as me. I found it was the
IDE causing the issue. From some reason Tomcat is deploying it twice.
Igor Vaynberg wrote:
> see databinder.net for ideas
>
> -igor
>
> On 10/2/07, Stanczak Group <ju...@stanczakgroup.com> wrote:
>
>> I'm using Hibernate with the HibernateUtil class. It all works except
>> when I try to use the HibernateUtil in the Application.onDestroy()
>> method. I want to have it close the factory when the server is shutdown.
>> It's an embedded database so it's saying the database is locked. This
>> looks to me like the Application is running in one thread and the Pages
>> in another. It's like the HibernateUtil static code is running twice.
>> Is there a better way of using Hibernate in Wicket? Here's the code I'm
>> using now.
>>
>>
>> ###########################################################################
>> public class HibernateUtil {
>>
>> private static final SessionFactory sessionFactory;
>> static {
>> try {
>> // Create the SessionFactory from hibernate.cfg.xml
>> sessionFactory = new
>> Configuration().configure().buildSessionFactory();
>> } catch (Throwable ex) {
>> // Make sure you log the exception, as it might be swallowed
>> System.err.println("Initial SessionFactory creation failed."
>> + ex);
>> throw new ExceptionInInitializerError(ex);
>> }...
>>
>> #############################Application#####################################
>>
>> ... @Override
>> protected void onDestroy() {
>> System.out.println("Killing database connection\n\n");
>> HibernateUtil.getSessionFactory().close();
>> }....
>>
>> ###########################################################################
>>
>> --
>> 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: Using Hibernate in Wicket?
Posted by Igor Vaynberg <ig...@gmail.com>.
see databinder.net for ideas
-igor
On 10/2/07, Stanczak Group <ju...@stanczakgroup.com> wrote:
>
> I'm using Hibernate with the HibernateUtil class. It all works except
> when I try to use the HibernateUtil in the Application.onDestroy()
> method. I want to have it close the factory when the server is shutdown.
> It's an embedded database so it's saying the database is locked. This
> looks to me like the Application is running in one thread and the Pages
> in another. It's like the HibernateUtil static code is running twice.
> Is there a better way of using Hibernate in Wicket? Here's the code I'm
> using now.
>
>
> ###########################################################################
> public class HibernateUtil {
>
> private static final SessionFactory sessionFactory;
> static {
> try {
> // Create the SessionFactory from hibernate.cfg.xml
> sessionFactory = new
> Configuration().configure().buildSessionFactory();
> } catch (Throwable ex) {
> // Make sure you log the exception, as it might be swallowed
> System.err.println("Initial SessionFactory creation failed."
> + ex);
> throw new ExceptionInInitializerError(ex);
> }...
>
> #############################Application#####################################
>
> ... @Override
> protected void onDestroy() {
> System.out.println("Killing database connection\n\n");
> HibernateUtil.getSessionFactory().close();
> }....
>
> ###########################################################################
>
> --
> 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
>
>