Search code examples
sqlhibernateservicedrilldowneclipse-scout

Scout SmartField suggestions from Hibernate


I am working in Scout and need SmartField. For this I need to set up lookup for suggestions.

I see the example with creating Lookup Call and than implement in Lookup Service getConfiguredSqlSelect

but I use Hibernate to work with classes, so my question is how to connect Smart field with Hibernate object filled service?


Solution

  • create a new lookup call according to [1] with the following differences:

    1. don't select AbstractSqlLookupService as a lookup servic super type, but AbstractLookupService
    2. in the associated lookup service you now need to implement getDataByAll, getDataByKey, and getDataByText

    to illustrate the following snippet should help:

    public class TeamLookupService extends AbstractLookupService<String> implements ITeamLookupService {
    
      private List<ILookupRow<String>> m_values = new ArrayList<>();
    
      public TeamLookupService() {
        m_values.add(new LookupRow<String>("CRC", "Costa Rica"));
        m_values.add(new LookupRow<String>("HON", "Honduras"));
        m_values.add(new LookupRow<String>("MEX", "Mexico"));
        m_values.add(new LookupRow<String>("USA", "USA"));
      }
    
      @Override
      public List<? extends ILookupRow<String>> getDataByAll(ILookupCall<String> call) throws ProcessingException {
        return m_values;
      }
    
      @Override
      public List<? extends ILookupRow<String>> getDataByKey(ILookupCall<String> call) throws ProcessingException {
        List<ILookupRow<String>> result = new ArrayList<>();
    
        for (ILookupRow<String> row : m_values) {
          if (row.getKey().equals(call.getKey())) {
            result.add(row);
          }
        }
    
        return result;
      }
      ...
    

    [1] https://wiki.eclipse.org/Scout/Tutorial/4.0/Minicrm/Lookup_Calls_and_Lookup_Services#Create_Company_Lookup_Call