I am starting out in Spring and have been attempting to design a simple web page which basically has the functionality of searching for a user and displaying their profile in the same page.
I have two separate pages with two separate forms think of them as searchPage and profilePage, each of these pages are attached to its own controller, the searchPage simply searches for data provided from a database and the profilePage presents the data found in a form (first name, last name, phone number etc). The trick here is i want to put these two forms together where the search is up the top and the form displaying the results is directly beneath it.
So i created a third page called mainPage and this simply includes searchPage first and profilePage right afterwards these are being called as
Where the searchID.htm and voiceID.htm are servletMappings defined and attached to a controller, now these pages work fine on their own, and they show up fine in the mainPage, however when i enter search criteria and press the submit button (on the searchPage) the onSubmit function of that controller is called many times in an endless loop eventually creating a stackoverflow error.
The successView of the searchPage is the mainPage so that I can display the results in the form below profilePage which in turn has its formBackingObject to retrieve the data off the session and display in the form.
I hope this makes sense i'm not sure how to stop it from continuously executing the onSubmit function does anyone have any ideas?
If any more code is needed to be posted please let me know
If the servlet mapped for searchID.htm results in passing the control to the mainPage JSP, which again contains searchID.htm, then that explains the endless loop.
You could try using the include directive instead of jsp:include.
A slightly different approach could be to have a single JSP, that always shows the search form, and conditionally shows the profile if a Profile object (or whatever object you are using) is found in the request scope. Then you only need a single controller. On 'form view', only set up the search data. And on 'form submit', set up the search data as well as the other data to be shown as a result of the search.
Yeah it sort of does make sense but what if I just wanted two different forms with two different controllers but on the same page? How do I go about doing that? For example how do I define the controllers with their form and success views? How do I write the spring binds in the jsp so that it will be able to see two different command objects? How do I use a urlmapping to those different controllers?
Any help here would be greatly appreciated
subject: Spring problem, could really use some help