Results 1 to 8 of 8

Thread: newbie SimpleFormController - onSubmit(POST), Get ?

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    You need to override isFormSubmission

  3. #3
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    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.

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    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

  5. #5
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    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.

  6. #6
    Join Date
    Jul 2005
    Location
    COIMBATORE-INDIA
    Posts
    110

    Default 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
    Have a Nice day

  7. #7

    Default Re: Error in referenceData()

    Quote 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.

  8. #8
    Join Date
    Nov 2007
    Posts
    7

    Default

    weird it only exectues when having

    protected Object formBackingObject(HttpServletRequest request)

    and not when having

    protected Object formBackingObject(HttpServletRequest request,Object command)

Similar Threads

  1. SimpleFormController not do onSubmit
    By heleno_alves in forum Web
    Replies: 2
    Last Post: Oct 18th, 2005, 07:22 AM
  2. Replies: 2
    Last Post: Jul 31st, 2005, 08:50 PM
  3. SimpleFormController Issue
    By zrawley in forum Web
    Replies: 14
    Last Post: Jul 31st, 2005, 07:27 AM
  4. Replies: 3
    Last Post: Jul 8th, 2005, 09:00 AM
  5. Servlet & portlet packages (SimpleFormController)
    By mpetrashev in forum Architecture
    Replies: 0
    Last Post: Dec 2nd, 2004, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •