@Override
  public void init() {

    // the grid should not try to load before a query is made
    setAutoLoad(false);
    init(
        PartyLookupConfiguration.URL_SEARCH_SUPPLIERS,
        "/purchasing/control/viewSupplier?partyId={0}",
        UtilUi.MSG.supplierId(),
        new String[] {PartyLookupConfiguration.INOUT_GROUP_NAME, UtilUi.MSG.supplierName()});
  }
示例#2
0
  /**
   * Default constructor.
   *
   * @param resultsListView the instance of the results list view to use
   */
  public SearchForm(SearchResultsListView resultsListView) {
    super();
    setBorder(false);
    setHideLabels(true);

    // using an inner panel to customize the layout
    Panel innerPanel = new Panel();
    innerPanel.setBorder(false);
    innerPanel.setLayout(new HorizontalLayout(5));

    searchInput = new TextField();
    searchInput.setName(SearchLookupConfiguration.IN_QUERY);
    searchInput.setWidth(200); // width of search input box
    setFieldListeners(searchInput);
    innerPanel.add(searchInput);

    Button submitButton = makeStandardSubmitButton(UtilUi.MSG.search());
    innerPanel.add(submitButton);

    add(innerPanel);

    win = new Window(UtilUi.MSG.searchResults());
    win.setModal(false);
    win.setResizable(true);
    win.setMinHeight(RESULT_HEIGHT);
    win.setLayout(new FitLayout());
    win.setCloseAction(Window.HIDE);

    results = resultsListView;
    results.setFrame(false);
    results.setAutoHeight(false);
    results.setCollapsible(false);
    results.setHeader(false);
    results.setBorder(false);
    results.setWidth(RESULT_WIDTH);
    win.add(results);
  }
 /** {@inheritDoc} */
 public void search(String query) {
   setFilter(UtilLookup.PARAM_SUGGEST_QUERY, query);
   applyFilters();
   getView().setEmptyText(UtilUi.MSG.searchNoResults(query));
 }
 /** Default constructor. */
 public SupplierSearchListView() {
   super();
   setTitle(UtilUi.MSG.supplierList());
   init();
 }
  /** {@inheritDoc} */
  @Override
  public void init() {

    String entityViewUrl = "/crmsfa/control/viewAccount?partyId={0}";
    StringFieldDef idDefinition = new StringFieldDef(PartyLookupConfiguration.INOUT_PARTY_ID);

    makeLinkColumn(UtilUi.MSG.crmContactId(), idDefinition, entityViewUrl, true);
    makeLinkColumn(
        UtilUi.MSG.crmAccountName(),
        idDefinition,
        new StringFieldDef(PartyLookupConfiguration.INOUT_FRIENDLY_PARTY_NAME),
        entityViewUrl,
        true);
    makeColumn(UtilUi.MSG.partyCity(), new StringFieldDef(PartyLookupConfiguration.INOUT_CITY));
    makeColumn(
        UtilUi.MSG.crmPrimaryEmail(), new StringFieldDef(PartyLookupConfiguration.INOUT_EMAIL));
    makeColumn(
        UtilUi.MSG.crmPrimaryPhone(),
        new StringFieldDef(PartyLookupConfiguration.INOUT_FORMATED_PHONE_NUMBER));
    makeColumn(
        UtilUi.MSG.partyToName(), new StringFieldDef(PartyLookupConfiguration.INOUT_TO_NAME));
    makeColumn(
        UtilUi.MSG.partyAttentionName(),
        new StringFieldDef(PartyLookupConfiguration.INOUT_ATTENTION_NAME));
    makeColumn(
        UtilUi.MSG.partyAddressLine1(), new StringFieldDef(PartyLookupConfiguration.INOUT_ADDRESS));
    makeColumn(
        UtilUi.MSG.partyAddressLine2(), new StringFieldDef(PartyLookupConfiguration.OUT_ADDRESS_2));
    makeColumn(UtilUi.MSG.partyState(), new StringFieldDef(PartyLookupConfiguration.INOUT_STATE));
    makeColumn(
        UtilUi.MSG.partyCountry(), new StringFieldDef(PartyLookupConfiguration.INOUT_COUNTRY));
    makeColumn(
        UtilUi.MSG.partyPostalCode(),
        new StringFieldDef(PartyLookupConfiguration.INOUT_POSTAL_CODE));
    makeColumn(
        UtilUi.MSG.crmPostalCodeExt(),
        new StringFieldDef(PartyLookupConfiguration.OUT_POSTAL_CODE_EXT));

    // add last column if logged in user has required permission
    deleteColumnIndex = getCurrentColumnIndex();
    if (hasAccountsRemoveAbility()) {
      ColumnConfig config =
          makeColumn(
              "",
              new Renderer() {
                public String render(
                    Object value,
                    CellMetadata cellMetadata,
                    Record record,
                    int rowIndex,
                    int colNum,
                    Store store) {
                  return Format.format(
                      "<img width=\"15\" height=\"15\" class=\"checkbox\" src=\"{0}\"/>",
                      UtilUi.ICON_DELETE);
                }
              });
      config.setWidth(26);
      config.setResizable(false);
      config.setFixed(true);
      config.setSortable(false);

      addGridCellListener(
          new GridCellListenerAdapter() {
            private final String actionUrl = "/crmsfa/control/removeContactFromAccountAJX";

            /** {@inheritDoc} */
            @Override
            public void onCellClick(GridPanel grid, int rowIndex, int colindex, EventObject e) {
              if (colindex == AccountsSublistView.this.deleteColumnIndex) {
                String accountPartyId = getStore().getRecordAt(rowIndex).getAsString("partyId");
                RequestBuilder request = new RequestBuilder(RequestBuilder.POST, actionUrl);
                request.setHeader("Content-type", "application/x-www-form-urlencoded");
                request.setRequestData(
                    Format.format(
                        "partyId={0}&contactPartyId={0}&accountPartyId={1}",
                        AccountsSublistView.this.contactPartyId, accountPartyId));
                request.setCallback(
                    new RequestCallback() {
                      public void onError(Request request, Throwable exception) {
                        // display error message
                        markGridNotBusy();
                        UtilUi.errorMessage(exception.toString());
                      }

                      public void onResponseReceived(Request request, Response response) {
                        // if it is a correct response, reload the grid
                        markGridNotBusy();
                        UtilUi.logInfo(
                            "onResponseReceived, response = " + response,
                            MODULE,
                            "ContactListView.init()");
                        if (!ServiceErrorReader.showErrorMessageIfAny(response, actionUrl)) {
                          getStore().reload();
                          loadFirstPage();
                        }
                      }
                    });

                try {
                  markGridBusy();
                  UtilUi.logInfo("posting batch", MODULE, "ContactListView.init()");
                  request.send();
                } catch (RequestException re) {
                  // display error message
                  UtilUi.errorMessage(e.toString(), MODULE, "ContactListView.init()");
                }
              }
            }
          });
    }

    configure(
        PartyLookupConfiguration.URL_FIND_ACCOUNTS,
        PartyLookupConfiguration.INOUT_PARTY_ID,
        SortDir.ASC);

    // by default, hide non essential columns
    setColumnHidden(PartyLookupConfiguration.INOUT_PARTY_ID, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_STATE, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_COUNTRY, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_TO_NAME, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_ATTENTION_NAME, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_ADDRESS, true);
    setColumnHidden(PartyLookupConfiguration.OUT_ADDRESS_2, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_POSTAL_CODE, true);
    setColumnHidden(PartyLookupConfiguration.OUT_POSTAL_CODE_EXT, true);
  }