Class SearchForm

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, DataBoundComponent, HasClearHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragCompleteHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropCompleteHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFetchDataHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasRuleContextChangedHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasVisibilityChangedHandlers, HasAsyncValidationReplyHandlers, HasCriteriaChangedHandlers, HasFormSubmitFailedHandlers, HasHiddenValidationErrorsHandlers, HasItemChangedHandlers, HasItemChangeHandlers, HasItemKeyPressHandlers, HasOnSearchHandlers, HasSubmitValuesHandlers, HasValuesChangedHandlers

public class SearchForm extends DynamicForm implements HasCriteriaChangedHandlers, HasOnSearchHandlers
A SearchForm is a DynamicForm specialized for a user to enter search criteria.

All DynamicForm properties and methods work on SearchForm. SearchForm extends and specializes DynamicForm for searching; for example, SearchForm sets hiliteRequiredFields false by default because fields are typically not required in a search.

A SearchForm may be bound directly to a ListGrid by applying it to ListGrid.searchForm. Doing this ensures that when search() is invoked (from a submit button click or Enter keypress), the grid will be filtered by the values from the search form.

Alternatively, developers may implement their own search handling logic.

See Also:
  • Constructor Details

    • SearchForm

      public SearchForm()
    • SearchForm

      public SearchForm(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static SearchForm getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class DynamicForm
    • setCanEditFieldAttribute

      public SearchForm setCanEditFieldAttribute(String canEditFieldAttribute) throws IllegalStateException
      This property is overridden in SearchForm to allow editing of dataSource fields marked as canFilter:true by default.

      Note : This is an advanced setting

      Overrides:
      setCanEditFieldAttribute in class DynamicForm
      Parameters:
      canEditFieldAttribute - New canEditFieldAttribute value. Default value is "canFilter"
      Returns:
      SearchForm instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getCanEditFieldAttribute

      public String getCanEditFieldAttribute()
      This property is overridden in SearchForm to allow editing of dataSource fields marked as canFilter:true by default.
      Overrides:
      getCanEditFieldAttribute in class DynamicForm
      Returns:
      Current canEditFieldAttribute value. Default value is "canFilter"
      See Also:
    • setCriteriaChangedDelay

      public SearchForm setCriteriaChangedDelay(Integer criteriaChangedDelay)
      Delay in milliseconds between user changing the criteria in the form and the SearchForm.criteriaChanged() notification method being fired. Set to zero to respond to criteria changes synchronously after DynamicForm.itemChanged().
      Parameters:
      criteriaChangedDelay - New criteriaChangedDelay value. Default value is 200
      Returns:
      SearchForm instance, for chaining setter calls
    • getCriteriaChangedDelay

      public Integer getCriteriaChangedDelay()
      Delay in milliseconds between user changing the criteria in the form and the SearchForm.criteriaChanged() notification method being fired. Set to zero to respond to criteria changes synchronously after DynamicForm.itemChanged().
      Returns:
      Current criteriaChangedDelay value. Default value is 200
    • setSearchOnEnter

      public SearchForm setSearchOnEnter(Boolean searchOnEnter)
      Causes the search() event to be triggered when the user presses the Enter key in any field of this form.

      This is the same as the saveOnEnter property of DynamicForm - setting either property to true will cause the search() event to fire on Enter keypress.

      Parameters:
      searchOnEnter - New searchOnEnter value. Default value is true
      Returns:
      SearchForm instance, for chaining setter calls
    • getSearchOnEnter

      public Boolean getSearchOnEnter()
      Causes the search() event to be triggered when the user presses the Enter key in any field of this form.

      This is the same as the saveOnEnter property of DynamicForm - setting either property to true will cause the search() event to fire on Enter keypress.

      Returns:
      Current searchOnEnter value. Default value is true
    • setShowFilterFieldsOnly

      public SearchForm setShowFilterFieldsOnly(Boolean showFilterFieldsOnly)
      If this attribute is true any canFilter:false fields specified on the dataSource will not be shown unless explicitly included in this component's fields array

      Note : This is an advanced setting

      Parameters:
      showFilterFieldsOnly - New showFilterFieldsOnly value. Default value is true
      Returns:
      SearchForm instance, for chaining setter calls
    • getShowFilterFieldsOnly

      public Boolean getShowFilterFieldsOnly()
      If this attribute is true any canFilter:false fields specified on the dataSource will not be shown unless explicitly included in this component's fields array
      Returns:
      Current showFilterFieldsOnly value. Default value is true
    • setStoreDisplayValues

      public SearchForm setStoreDisplayValues(Boolean storeDisplayValues)
      For editable fields with a specified FormItem.displayField and FormItem.optionDataSource, if the user selects a new value (typically from PickList based item such as a SelectItem), should the selected displayValue be updated on the record being edited in addition to the value for the actual item.
      Note that this only applies for fields using local display field values.

      Overriden to be false for searchForms. It is typically not necessary to have the display value as well as the data value be included in generated criteria when a user selects a new value from a field with a specified FormItem.displayField.

      See DynamicForm.storeDisplayValues for more information on this property.

      Note : This is an advanced setting

      Overrides:
      setStoreDisplayValues in class DynamicForm
      Parameters:
      storeDisplayValues - New storeDisplayValues value. Default value is false
      Returns:
      SearchForm instance, for chaining setter calls
    • getStoreDisplayValues

      public Boolean getStoreDisplayValues()
      For editable fields with a specified FormItem.displayField and FormItem.optionDataSource, if the user selects a new value (typically from PickList based item such as a SelectItem), should the selected displayValue be updated on the record being edited in addition to the value for the actual item.
      Note that this only applies for fields using local display field values.

      Overriden to be false for searchForms. It is typically not necessary to have the display value as well as the data value be included in generated criteria when a user selects a new value from a field with a specified FormItem.displayField.

      See DynamicForm.storeDisplayValues for more information on this property.

      Overrides:
      getStoreDisplayValues in class DynamicForm
      Returns:
      Current storeDisplayValues value. Default value is false
    • setUseMultiSelectForValueMaps

      public SearchForm setUseMultiSelectForValueMaps(boolean useMultiSelectForValueMaps) throws IllegalStateException
      When creating a SelectItem within a Search Form for editing criteria for a field with a ValueMap, should the SelectItem default to multiple:true?

      Note that for ListGrids showing a filterEditor, this property will be derived from ListGrid.useMultiSelectForFilterValueMaps

      Note : This is an advanced setting

      Parameters:
      useMultiSelectForValueMaps - New useMultiSelectForValueMaps value. Default value is true
      Returns:
      SearchForm instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getUseMultiSelectForValueMaps

      public boolean getUseMultiSelectForValueMaps()
      When creating a SelectItem within a Search Form for editing criteria for a field with a ValueMap, should the SelectItem default to multiple:true?

      Note that for ListGrids showing a filterEditor, this property will be derived from ListGrid.useMultiSelectForFilterValueMaps

      Returns:
      Current useMultiSelectForValueMaps value. Default value is true
    • addCriteriaChangedHandler

      public HandlerRegistration addCriteriaChangedHandler(CriteriaChangedHandler handler)
      Add a criteriaChanged handler.

      Notification method fired when the criteria are modified in this SearchForm. As the user edits values, this method will be fired after a configurable delay.

      Specified by:
      addCriteriaChangedHandler in interface HasCriteriaChangedHandlers
      Parameters:
      handler - the criteriaChanged handler
      Returns:
      HandlerRegistration used to remove this handler
    • addOnSearchHandler

      public HandlerRegistration addOnSearchHandler(OnSearchHandler handler)
      Add a onSearch handler.

      Notification event fired indicating that a user is attempting to perform a search. This is fired when a SearchForm is submitted either from a click on a SubmitItem in the form, or from an Enter keypress if SearchForm.searchOnEnter or DynamicForm.saveOnEnter is true.

      Specified by:
      addOnSearchHandler in interface HasOnSearchHandlers
      Parameters:
      handler - the onSearch handler
      Returns:
      HandlerRegistration used to remove this handler
    • setDefaultProperties

      public static void setDefaultProperties(SearchForm searchFormProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      searchFormProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • search

      public void search()
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(SearchFormLogicalStructure s)
      Setter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
    • getLogicalStructure

      public LogicalStructureObject getLogicalStructure()
      Getter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
      getLogicalStructure in interface LogicalStructure
      Overrides:
      getLogicalStructure in class DynamicForm