Announcement Announcement Module
Collapse
No announcement yet.
Multiple forms Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple forms

    Hello

    I have read through most of the forum and the mailing lists and there are a great deal of posts about multiple forms on one page. But none of them match my situation I believe.
    Although this situation should be quite common.

    I want to create a site where all (or most) of the pages have a "search" form somewhere on the page. Hence when using a form on a specific page, that page will contain both the search from and the form on that specific page.

    What is the best practice method of having such a search form on all pages?
    The searchresult page ALSO have the search form on it.

    I guess all my controllers should be aware of search form somehow, since the search command object needs to be on the request. Should I put that in an abstract parent class for all my controllers?
    And should all my controllers - even though they don't themselves include a form - be a form controller?

  • #2
    I would just post the search to a different controller. There is no rule that sais that all forms on a page need to post to the same controller. So you would have 2 forms on your page:

    Code:
    <FORM name="searchForm" action="search">
      ...
    </FORM>
    
    ...
    
    <FORM name="doStuffForm" action="doStuff">
      ...
    </FORM>
    Erwin

    Comment


    • #3
      Yes .. but what about the command objects?

      The two form controllers need to know each others command objects - right?

      else I will get the "Error 500: Neither Errors instance nor plain target object for bean name somecommand available as request attribute"

      I am using spring:bind in my jsp's btw

      Comment


      • #4
        Is the only solution not to use the web mvc framework?

        I cannot believe that this is not a common issue.

        Comment


        • #5
          personally i do this by not having a command object.

          i dont see the point on doing databinding to a object when we are talking about one or 2 fields, it doesnt add anything to the manageability of the app and just complicates things. keep it simple.

          just have a regular controller with
          request.getParameter("searchQuery")

          Comment


          • #6
            Why not just jsp include?

            page

            -include output from form controller1

            -include output from form controller2

            Comment


            • #7
              You could create a SearchInterceptor if the search fields were in the same form as your main input form and you wanted to keep the search fields separate from whatever else was on the page.

              - how many variations of your search page do you have? i.e. is it the same everywhere or customised for each page that it appears on? For example, we've got a "serial no" quick search that appears everywhere, but we've put that in a separate HTML form.

              - when doing a search, do you want the search results to appear on that page, or can it be a different "search results" page?

              - do you want to retain page state when someone does a search, or would it be ok if any data entered in the non-search fields were lost?

              Comment

              Working...
              X