This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Spring and the fly likes Form for fetching data from database and displaying results on same page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Form for fetching data from database and displaying results on same page" Watch "Form for fetching data from database and displaying results on same page" New topic
Author

Form for fetching data from database and displaying results on same page

Jozo Stan
Greenhorn

Joined: Aug 18, 2012
Posts: 12
I have a sport database with country, sport, team and match tables. I'm developing a web application in Spring where users could discuss about match results, view statistics and so on.
Well, I'm stuck with head2head statistics. I have two dropdown boxes with teams. User selects host and guest. When he clicks on show, controller should fetch all the matches where the selected teams have played against each other. The results should display on the same page. Unfortunately, this isn't happening.

Here is my code.

Fetch method in HibernateDAO domacin = host, gost = guest





H2Hstat.java




h2Hstat.jsp




Is this actually possible to achieve on the same page? When I submit the form I get empty table.

Please help.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1672
    
    7

Ok my first suggestion is do not use HibernateTemplate this is no longer the accepted pattern. Please see the reference documentation for instructions on the correct way.
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/orm.html#orm-hibernate

Disclaimer - I did not even look at your jsp code.

In you controller you are doing this



You are not assigning it to anything and you are not putting it on the model before returning the view. That is why after posting you most likely have an empty view. All the view is getting after your post is empty lists. Contrast what you are doing in the post to what you have in the get. In one you populate the lists and set them on the model. In the other you just return the view.


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form for fetching data from database and displaying results on same page