Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to use SearchForm

    I've looked in vain for a simple example of using a SearchForm. The documentation is sparse and it seems like what I'm looking for is simple and probably default behavior, but I can't seem to figure out how to put it together. I want a simple form, based on a data source, with a Search button on it. I want to apply the form fields as search criteria to a data source and update a couple of other components (form and grid) when the user presses the Search button or just presses Enter.

    I've tried creating a simple search form with a TextItem and SubmitItem and overriding the search() method but clicking the SubmitItem doesn't invoke it. And there isn't anything equivalent to DynamicForm.setSaveOnEnter() that I have found.

    I can probably accomplish what I want with a DynamicForm by overriding saveData(), but SearchForm seems like the right way to go, but only because of the name.

    #2
    SearchForm is a subclass of DynamicForm, all the same approaches apply including saveOnEnter. The differences is just some changes in the default settings for the various items, such as whether the form respects the canFilter vs the canEdit flag to determine whether a field is displayed read-only.

    Comment


      #3
      What method do I need to override to catch the form submission. I've tried submit(), like this. Also tried search().
      Code:
      final SearchForm searchForm = new SearchForm() {
      	@Override
      	public void submit() {
      		orderRecap.fetchData(getValuesAsAdvancedCriteria());
      		grid.fetchData(getValuesAsAdvancedCriteria());
      	}
      };
      searchForm.setDataSource(dordhdrDS);
      searchForm.setWrapItemTitles(false);
      searchForm.setOperator(OperatorId.AND);
      TextItem orderNumber = new TextItem("DCONUM");
      orderNumber.setOperator(OperatorId.EQUALS);
      SubmitItem searchBtn = new SubmitItem("Search", "Search");
      searchForm.setSaveOnEnter(true);
      searchForm.setFields(orderNumber, searchBtn);

      Comment


        #4
        Any help? Neither submit() nor search() gets called when pressing Enter or clicking on the SubmitItem.

        The docs says for SearchForm.search(criteria, form):
        Triggered when a SubmitItem is included in the form is submitted and gets pressed.
        I've tried the override with the parameters and without.

        And for DynamicForm.submit():
        submit() is automatically called when a SubmitItem included in the form is clicked, or, if saveOnEnter is set, when the "Enter" key is pressed in a text input. Submit can also be manually called.

        Yet neither one of these is being called. Why?
        Last edited by jay.l.fisher; 10 Dec 2009, 19:50.

        Comment


          #5
          Hi Jay,

          You want to add a SubmitValuesHandler.

          Comment

          Working...
          X