Announcement Announcement Module
Collapse
No announcement yet.
newbie SimpleFormController - onSubmit(POST), Get ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • newbie SimpleFormController - onSubmit(POST), Get ?

    Hi,
    I have newbie question about SimpleFormController. I need to place on single page a FORM and LISTOFITMES.

    When I am submitting form it is possible to make this with:
    Code:
         public ModelAndView onSubmit(....) {
                ....
                return new ModelAndView("itemSearchList", "itemList", items);
         }
    But it is executed only with form submitting and now I am struggling on how can I make the same on GET method.

    Many thanks for any help.

  • #2
    You need to override isFormSubmission

    Comment


    • #3
      Don't override isFormSubmission as many things will break and it is not "the right thing to do"

      If all you want to do is make some data available on your jsp, override "referenceData" as that is what you are looking to do.

      Keep the form clean and override referenceData.

      Comment


      • #4
        yatesco is right - I only read the "When I am submitting form...how can I make the same on GET method".

        referenceData is the correct place for retrieving reference data

        Comment


        • #5
          anieshuk, I will reply to your message here so everyone can see

          It is very easy to override referenceData():
          Code:
          	protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception;
          Basically, override this method and put all your reference data into the map that you return, then in your jsp you can access them via "${key}", so if the Map contains a Collection under the key "LISTOFITMES":

          Code:
          	public Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception {
                    Map map = new HashMap();
                    map.put("LISTOFITMES", getMyListOfItems());
                    return map;
                 }
          then in your jsp you would access them:

          Code:
            <c&#58;forEach items="$&#123;LISTOFITMES&#125;" var="item">
            </c&#58;forEach>
          Your FORM will already be accessible on your jsp under the value returned by getFormName().

          Hope this helps.

          Comment


          • #6
            Error in referenceData()

            Hai users,

            I am having a jsp file which is called through a submit action by a link.

            then it uses a controller to show the form view.

            my doubt is in myreference data method i used the following code
            {
            map.put("Name","aniesh");
            }

            in my jsp i have
            <c:out value="${Name}"/>

            i am not getting any errord but there is no output displayed.

            should i use any bind tag.

            can anyone help me

            thanks
            anieshuk

            Comment


            • #7
              Re: Error in referenceData()

              Originally posted by anieshuk
              Hai users,

              I am having a jsp file which is called through a submit action by a link.

              then it uses a controller to show the form view.

              my doubt is in myreference data method i used the following code
              {
              map.put("Name","aniesh");
              }

              in my jsp i have
              <c:out value="${Name}"/>

              i am not getting any errord but there is no output displayed.

              should i use any bind tag.

              can anyone help me

              thanks
              anieshuk
              No. You don't need any binding. Binding is only for HTML <input ...> tags

              Regards.

              Comment


              • #8
                weird it only exectues when having

                protected Object formBackingObject(HttpServletRequest request)

                and not when having

                protected Object formBackingObject(HttpServletRequest request,Object command)

                Comment

                Working...
                X