• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

PostMethod not being called

 
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my applicaion I have one base entity called general,  this entity use to contain all the fields, but with normalisation in mind I seperated them in 8 different entities. All other 7 have an one to one relationship with eather general or one of the other entities which has in it's turn again a one to one to general.
I'm using seperate forms to ask the user to create the entities, but having some problems.
The genral idea was after filling in the previous form the user would automaticly be redirected to the next form. I'm struggleing to make it work.
I can't even really explain what is going wrong, so let me just post what I got and maybe you guys can give me some tips on how to tackle this problem.
The one thing I can say, because I'm sure someone will make a remark about it. The reasson why I call the getInvoices method, is because if I redirect like I tried, spring dosn't create a bean for the webform so I get an 404.
The redirecting works, but when I trie to post the invoiceform, nothing happens, I putted a system.out in the postMethod to see if it get's called and it isn't.

InvoiceForm:
newReecord.jsp (to created the generalEntity and addressEntity)

The GeneralEntity:


The Controller:


I thought of making an menu-entry for every form I use, instead of redirecting, but I still have to acces the generalentity to update it with the new entities created.
Any ideas...?
 
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the forms are on different pages, you can just make the response to receiving the first form, the second form.  If they are on the same page you can maybe use javascript to auto focus on the second form.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They're on seperate pages. I don't really know what you mean with you remark. Apperently I cant, that is what I have bin trying...
 
Ranch Foreman
Posts: 324
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried by adding a "/" ?
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The spring.mvc.view.prefix in my application.properties is specified as "/WEB-INF/jsp/", so no additional "/" needed
 
Al Hobbs
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If they are on separate jsp the  you should be able to just receive the post of the first form then for the return you just put the name of the Jsp that has the second form.  That should work if your config is all setup.  Should check through it for any small mistakes.  Do any of your jsps  load properly?
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That dosn't work.
And yes my wrapperform uused to populate the general and address table loads properly and the postmethod also works. The data is being saved correctly. But if I simply redirect to the next form from my postmethod, the next form isn't added as a n attribute to the model. I wrote the reasson here for is cause I redirect it myself spring dosn't create a bean.
And what configuration, spring boot does all the configuration, I've done just some basicstuff in application.properties
 
Al Hobbs
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok finally getting what you're saying.  Redirect to an endpoint that will put the model attribute in before returning the jsp.  Or you don't even have to use model attribute if you want a more simple way
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding the form in the generalpostmethod and redirecting instead of just calling the new form takes care of the bean problem, but still when posting the second form, the postmethod of the invoicecontroller isn't called.
 
Al Hobbs
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So when you you hit submit from the second form page nothing happens or what? Have you turned on the debug log for spring so you can see what's happening?  It will say what requests it receives and what the mapping is.  That way you can see where the problem is.
 
Al Hobbs
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which jsp file is one that is not posting? One of your jsp forms doesn't have an action which would make sense that nothing is being posted.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the one with action that isn't posting, it dosn't need the action attribute if you specify the method, the eonly reasson I put in the action is cause it wasn't posting and hope that would make a difference, but it didn't
 
Al Hobbs
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't know you could post something from a form with no action or JavaScript.  Maybe that's a function of spring form tag.  Either way you should look at the log, because if you don't know the problem, you'll be able to figure it out pretty easily.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!