Announcement Announcement Module
Collapse
No announcement yet.
Permanent Form with 2 buttons Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Permanent Form with 2 buttons

    hi!

    I despair...

    I have a form which is permanently displayed in the top area on my page and has 1 input field, 2 checkboxes, 2 dropDown menues and 2 buttons for searching objects.

    when the user press a button -> the search results should be displayed in the right area of my page. and the form should still be there filled out with the user input.

    the form should be permanently displayed in the top area. in addition there are many other actions on the page the user can do (e.g browsing through different information - which will be displayed in the right area ...)

    which controller will fit best? the AbstractFormController?
    and how can I handle the sping:bind tag? i read something about 2 different versions of the form.jsp in an other post - but don't know how this can work? has anyone had an similar problem? or some example code? or just can help me?



    tia, lana

  • #2
    Bumping this because it's a good question and a situation I'm faced with also.

    I have a MultiActionController to process web requests but I would like to also display the search form which is a SimpleFormController on the same page. I haven't found a good solution yet so for now I have to put the search form on another page.

    Comment


    • #3
      Partial soln

      FWIW, I have use SimpleFormController to solve the
      when the user press a button -> the search results should be displayed in the right area of my page. and the form should still be there filled out with the user input.
      as sketched below...
      I can't really think of an easy way to address
      in addition there are many other actions on the page the user can do (e.g browsing through different information - which will be displayed in the right area ...)
      without tiles, frames or similar.

      Anyway...

      I created a criteria object that was the form backing object. This criteria object held pick lists (multiple selections) and wild card based free text. This was bound to the search form at the top of the page. The onSubmit would simply add results to the ModelAndView. The JSP page always rendered the search form inputs and optionally the results (if they were present).

      Code snoppets that sorta show this

      Controller
      Code:
      public class HistoricalController extends SimpleFormController
      {
         private static final String RESULTS = "results";
      ...
        protected Object formBackingObject(HttpServletRequest request)
               throws Exception
         {
           return new SearchCriteria();
         }
      
         protected ModelAndView onSubmit(HttpServletRequest request,
               HttpServletResponse response, Object command, BindException errors)
               throws Exception
         {
            SearchCriteria criteria = (SearchCriteria) command;
            ModelAndView mav = null;
            List projects = getAdminService().getProjectDetails(criteria);
            mav = new ModelAndView(getSuccessView(), getCommandName(), criteria);
            mav.addObject(RESULTS, projects);
            return mav;
         }
      ...
      }
      The success view is set to the same value as the formView in the bean definition.

      The jsp page is like...
      Code:
        <form action="" method="post">
          <table>
            <tr>
              <td valign="top">
                <table>
                  <spring&#58;bind path="command.projectTypes">
                        <label>
                          <fmt&#58;message key="label.$&#123;status.expression&#125;"/>
                        </label>
                          <select multiple name="$&#123;status.expression&#125;">
                            <c&#58;forEach items="$&#123;command.projectTypeSelections&#125;" var="selection">
                              <option value="$&#123;selection.value&#125;" <c&#58;if test="$&#123;selection.selected&#125;"> selected </c&#58;if>>
                              $&#123;selection.name&#125;
                              </option>
                            </c&#58;forEach>
                          </select>
                  </spring&#58;bind>
      
      ...
                <input type="submit" name="submit" value="Submit" />
        </form>
      ...
        <c&#58;if test="$&#123;not empty results&#125;">
          <hr />
          <h2>
            Selected Projects
          </h2>
          <table border="2" cellpadding="2" cellspacing="0" width="100%">
            <tr>header stuff </tr>
            <c&#58;forEach items="$&#123;results&#125;" var="project">
              <tr>
                <td>
                  $&#123;project.name&#125;
                </td> etc...
              </tr>
            </c&#58;forEach>
          </table>
        </c&#58;if>
      HTH

      Comment

      Working...
      X