Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Accessing the SearchForm from a TablePage
Accessing the SearchForm from a TablePage [message #1780396] Mon, 22 January 2018 07:47 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
We are using extensions to AbstractPageWithTable in which we use getConfiguredSearchForm() to define the search form. We then implement the execLoadData() method, which is called when the search button is pressed. It takes a SearchFilter parameter from which we can get the pre-filled SearchFormData object containing our search criteria. This object is then passed to our OutlineService implementation which uses it to retrieve the required data from our backend. As we keep our backend scout-free, we are moving the contents of the SearchFormData class into another DTO which we then pass from the OutlineService into our backend layer. We have succesfully been using this approach for a few years.

So far, so good.

However, as we are migrating from Eclipse to IntelliJ as IDE we no longer have the possiblity to auto-generate the SearchFormData from the SearchForm (this is done by the Eclipse Scout Plugin). Our idea is to do without the SearchFormData and instead already populate our own DTO in the client instead of the server. The idea is to do this in the AbstractPageWithTable.execLoadData() method of our table page, we would like to get access to the search form, so we could retrieve the field contents and write those into our DTO, we would then call the OutlineService with this DTO instead of the SearchFormData.

The problem is, that I don't currently see how we can access the SearchForm from our TablePage. The SearchFilter bean does not seem to contain a reference to the SearchForm. Is there any way to get a reference to the SearchForm instance? We do know its class (thanks to getConfiguredSearchForm), is there a way to ask Scout for the instance of that class? Can we just use BEANS.get(MySearchForm.class)?
Re: Accessing the SearchForm from a TablePage [message #1780409 is a reply to message #1780396] Mon, 22 January 2018 08:55 Go to previous messageGo to next message
Stephan Merkli is currently offline Stephan MerkliFriend
Messages: 40
Registered: April 2012
Member
Hi Urs

You can call getSearchFormInternal() in execLoadData in order to access the search form. Usually you create an own typed getter in your table page:
  
public IMySearchForm getSearchForm() {
  return (IMySearchForm) getSearchFormInternal();
}


Kind regards
Stephan
Re: Accessing the SearchForm from a TablePage [message #1780416 is a reply to message #1780396] Mon, 22 January 2018 10:05 Go to previous messageGo to next message
Eclipse UserFriend
In addition to Stephan Merklis replay some code examples.

TablePage
@ClassId("42f088a6-d93a-41cc-b6fd-2fc780494fd0")
public class PersonTablePage extends AbstractPersonTablePage<Table> {
  ...

  @Override
  protected void execPopulateTable() {
    getTable().replaceRows(BEANS.get(IPersonService.class)
        .findPersons(new PersonSearchQuery().withFirstName(getSearchFormInternal().getFirstNameField().getValue()))
        .stream().map(person -> {
          ITableRow row = getTable().createRow();
          row.getCellForUpdate(getTable().getIdColumn()).setValue(person.getId());
          row.getCellForUpdate(getTable().getFirstNameColumn()).setValue(person.getFirstName());
          row.getCellForUpdate(getTable().getLastNameColumn()).setValue(person.getLastName());
          return row;
        }).collect(Collectors.toList()));
  }

  @Override
  protected Class<? extends ISearchForm> getConfiguredSearchForm() {
    return PersonSearchForm.class;
  }

  @Override
  public PersonSearchForm getSearchFormInternal() {
    return (PersonSearchForm) super.getSearchFormInternal();
  }
  ...
}


Person and PersonQuery are simple POJOs.
findPersons on the PersonService returns a List<Person>.

/andreas
Re: Accessing the SearchForm from a TablePage [message #1780427 is a reply to message #1780416] Mon, 22 January 2018 10:58 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thank you both for your feedback!
Previous Topic:[6.1.0.M5] Missing RunContext when calling Service from CredentialVerifier
Next Topic:[NEON] Using Wizards (org.eclipse.scout.rt.client.ui.wizard)
Goto Forum:
  


Current Time: Fri Apr 19 23:32:36 GMT 2024

Powered by FUDForum. Page generated in 0.03101 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top