【问题标题】:Scout SmartField suggestions from Hibernate从 Hibernate 侦察 SmartField 建议
【发布时间】:2014-08-14 04:58:45
【问题描述】:
我在 Scout 工作,需要 SmartField。为此,我需要设置查找建议。
我看到了创建 Lookup Call 的示例,然后在 Lookup Service getConfiguredSqlSelect 中实现
但我使用 Hibernate 来处理类,所以我的问题是如何将智能字段与 Hibernate 对象填充服务连接起来?
【问题讨论】:
标签:
sql
hibernate
service
drilldown
eclipse-scout
【解决方案1】:
根据 [1] 创建一个新的查找调用,不同之处如下:
- 不要选择 AbstractSqlLookupService 作为查找服务超类型,而是 AbstractLookupService
- 在关联的查找服务中,您现在需要实现 getDataByAll、getDataByKey 和 getDataByText
说明以下sn-p应该有帮助:
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