コード例 #1
0
  private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 2);
    layoutSearchPane.setSpacing(true);

    group = new ValueComboBox(false, "Campaign Name", "Start Date", "End Date");
    group.select("Campaign Name");
    group.setImmediate(true);
    group.addValueChangeListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Campaign Name")) {
              addTextFieldSearch();
            } else if (searchType.equals("Start Date")) {
              addDateFieldSearch();
            } else if (searchType.equals("End Date")) {
              addDateFieldSearch();
            }
          }
        });

    layoutSearchPane.addComponent(group, 1, 0);
    layoutSearchPane.setComponentAlignment(group, Alignment.MIDDLE_CENTER);
    addTextFieldSearch();

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.BUTTON_ACTION);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            doSearch();
          }
        });
    layoutSearchPane.addComponent(searchBtn, 2, 0);
    layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layoutSearchPane);
  }
コード例 #2
0
  private void doSearch() {
    searchCriteria = new CampaignSearchCriteria();
    searchCriteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId()));

    String searchType = (String) group.getValue();
    if (StringUtils.isNotBlank(searchType)) {
      if (textValueField != null) {
        String strSearch = textValueField.getValue();
        if (StringUtils.isNotBlank(strSearch)) {
          if (searchType.equals("Campaign Name")) {
            searchCriteria.setCampaignName(new StringSearchField(SearchField.AND, strSearch));
          }
        }
      }
    }
    notifySearchHandler(searchCriteria);
  }