Announcement Announcement Module
No announcement yet.
Search and results flow problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Search and results flow problem

    I've been trying for days to figure out how to do this seemingly easy and common page. I have a page that has a form where users can enter a search criteria and get the results of the search.

    I want a workflow that does the following

    1) receive GET request,
    2) populate form with querystring parameters (bindOnNewForm=true)
    3) Get the results matching the querystring parameters(done in referenceData)
    4) Display page.
    4) User can change the search crtieria and submit
    5) receive POST request
    6) bind new form values to command object
    7) in onSubmit return successView with new seach criteria as model.
    8) user can change and resubmit form over and over again (i.e.
    user can loop back to step 4 as much as they want). Each time the
    current state of the form is displayed, followed by the results
    from the query.

    Here's my implementation

    <bean id="defectListController" class="com.timestock.tess.web.controllers.DefectLi stController">
    <property name="commandClass"><value>com.timestock.tess.web. filters.DefectFilter</value></property>
    <property name="bindOnNewForm"><value>true</value></property>
    <property name="sessionForm"><value>true</value></property>
    <property name="formView"><value>defectList</value></property>
    <property name="successView"><value>redirect:defectList.html </value></property>
    <property name="bizEventDao"><ref bean="bizEventDao"/></property>
    <property name="defectDao"><ref bean="defectDao"/></property>
    <property name="tranDefGroupDao"><ref bean="tranDefGroupDao"/></property>
    <property name="tranSetDefDao"><ref bean="tranSetDefDao"/></property>

    Here's my controller it extends SimpleFormController

    protected void initBinder(HttpServletRequest request,
    ServletRequestDataBinder binder) throws Exception

    binder.registerCustomEditor(TranDefGroup.class, new TranDefGroupPropertyEditor(
    binder.registerCustomEditor(TranSetDef.class, new TranSetDefPropertyEditor(
    super.initBinder(request, binder);

    protected Object formBackingObject(HttpServletRequest request) throws Exception

    DefectFilter defectFilter = new DefectFilter();
    return defectFilter;


    protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception
    DefectFilter defectFilter = (DefectFilter)command;
    Map model = new HashMap();
    model.put("defectList", defectDao.find(defectFilter));
    return model;

    protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception
    DefectFilter defectFilter = (DefectFilter)command;
    Map model = defectFilter.getModel();
    return new ModelAndView(getSuccessView(), model);

    The problem I am having is that in step 6 the binder tries to bind both query string paramters and the form values (Post parameters) to my command object and throws an exception as a result. Is there a way to prevent the querystring parameter binding in case of a POST request??

    If not I would be interested in knowing how else can I implement this page?