getDataByText() for SmartFields with CodeTypes [message #1440399] |
Wed, 08 October 2014 06:07  |
Eclipse User |
|
|
|
We are using a number of LookupServices for DB based data. In all of those, we have implemented the getDataByText() methods in a way that match the typed search text using contains() instead of startsWith(). This is what our users wanted and are used to.
However, we also have a number of Smartfields that use CodeTypes. On those, the search only considers text that matches the start of the code type's text. Our users would like to have the same behaviour as with our LookupService based smartfields.
I have looked at the implementation for Smartfields that use code types instead of LookupServices. As far as I can see AbstractSmartField.setCodeTypeClass() uses CodeLookupCall.newInstanceByService() which in turn uses DefaultCodeLookupCallFactoryService.newInstance() to create a new lookup call based on CodeLookupCall. The "only match the start of the string" behaviour seems to come from which CodeLookupCall.getSearchPattern().
Am I right in assuming that the way to change this behaviour I could extend CodeLookupCall to MyCodeLookupCall which overwrites getSearchPattern and then I would need to register my own MyCodeLookupCallFactoryService with a higher priority than DefaultCodeLookupCallFactoryService in order for this to work?
Or is there an easier way?
|
|
|
|
|
Re: getDataByText() for SmartFields with CodeTypes [message #1440489 is a reply to message #1440423] |
Wed, 08 October 2014 08:37   |
Eclipse User |
|
|
|
Hi Urs,
Judith Gull wrote on Wed, 08 October 2014 12:47You can also set IDesktop.setAutoPrefixWildcardForTextSearch(boolean), if this behaviour is for all searches.
As Judith said, if for all your lookupcall, you want to match the entered text like a "contains" operation, and not a "start with" you can just add this line at the beginning of Desktop#execOpened():
@Override
protected void execOpened() throws ProcessingException {
setAutoPrefixWildcardForTextSearch(true);
//... rest of the method
If you debug, you will see that the client adds 2 wildcard char "*" before and after the String entered by the user. This will be true for all the SmartFields in your application (SmartFields working with CodeTypes or with LookupCalls).
Urs Beeli wrote on Wed, 08 October 2014 13:32There is one stumbling block: getSearchPattern() is static, so it can't be overwritten in a derived class. Is there a reason for it being static?
In my opinion, no reason at all. You can open a bug to fix this.
The fix is trivial:
- Mark "public static Pattern getSearchPattern(String s)" as deprecated [will be removed with N-Release].
- Create a replacement method "protected Pattern createSearchPattern(String s)" as replacement (copy paste from the old one with another signature).
- Change the code to use your new method.
This is a small but useful step into making scout better. We need those small contributions in order to improve our code base.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.26682 seconds