Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Smart field with master
Smart field with master [message #893713] Thu, 05 July 2012 10:47 Go to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 330
Registered: August 2011
Senior Member
I have two smart fields. On the second field i did set the first one as a master. So in the GUI this looks good. But I cannot find out how to make the rest work. The second field never gives me any results any more. I guess I have to change the lookup call but cannot figure out how.
Re: Smart field with master [message #893731 is a reply to message #893713] Thu, 05 July 2012 11:42 Go to previous messageGo to next message
Eclipse UserFriend
The following pseudocode block shows the two most common variants.

MasterField:

SlaveField:
  getConfiguredMasterField(){
    return MasterField.class;
  }
  
  // variant 1 change the whole lookup call
  execChangedMasterValue(Object newValue){
    if(newValue.equals(value1)){
      setLookupCall(new LookupCall1());
    }else{
      setLookupCall(new LookupCall2());
    }
  }

  // variant 1 handle the variants in lookup calls.
  execChangedMasterValue(Object newValue){
    getLookupCall().setVariant(newValue);
  }



Let me know your success;)

-andreas
Re: Smart field with master [message #893741 is a reply to message #893713] Thu, 05 July 2012 12:39 Go to previous messageGo to next message
Bruno Koeferli is currently offline Bruno KoeferliFriend
Messages: 11
Registered: January 2012
Junior Member
A - in my opinion - better way is to use the master property on LookupCall, which contains the value of the configured master field.

The following pseudoSQL block shows you a possible usage of this master property:
select value from slave_values where master_value = :master


See here for using LookupCall properties in SQL lookup service.
Re: Smart field with master [message #893752 is a reply to message #893741] Thu, 05 July 2012 13:03 Go to previous messageGo to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 330
Registered: August 2011
Senior Member
No succes yet:

Do I have to make any changes at the back-end. Until now I only have a getConfiguredSqlSelect in the LookupService

@Override
protected String getConfiguredSqlSelect() {
return "SELECT id, version " +
"FROM component_version " +
"<key> where id = :key</key> " +
"<text> where UPPER(name) LIKE CONCAT(UPPER(:text), '%')</text>";
}

I wonder how the master value gets in there?

In the shared section I have in my LookupCall

@Override
protected boolean getConfiguredMasterRequired() {
return true;
}

In the Client I do not have

execChangedMasterValue(Object newValue){
getLookupCall().setVariant(newValue);
}

because I cannot find this. I do have on the slave field:

protected void execChangedMasterValue(Object newMasterValue) throws ProcessingException {
getLookupCall().setMaster(newMasterValue);
}

And for the rest I have set the configured values masterRequired and MasterField on the slave field.


Re: Smart field with master [message #893817 is a reply to message #893713] Thu, 05 July 2012 14:48 Go to previous messageGo to next message
Bruno Koeferli is currently offline Bruno KoeferliFriend
Messages: 11
Registered: January 2012
Junior Member
The SQL in your lookup service - I assume that it will be used by the configured LookupCall of your slave field - looks ok. (Here you can refer to your master value by using the binding ":master".)

getConfiguredMasterRequired() on LookupCall is not needed or should be better defined on the slave SmartField - I cannot tell you why this property exists on FormFields and on LookupCalls.

Additionally the execChangedMasterValue() on your slave field can be removed, because the master value will be set to LookupCall by Scout (see AbstractSmartField.prepareBrowseLookup(), prepareKeyLookup(), ...).

If your slave field still stays empty, you can set some breakpoints. F.e. on

  • ... AbstractSmartField.prepareBrowseLookup() to check the master value on the LookupCall
  • ... <your lookup service>.getConfiguredSqlSelect() to check if your SQL is being executed
Re: Smart field with master [message #893829 is a reply to message #893817] Thu, 05 July 2012 15:29 Go to previous message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 330
Registered: August 2011
Senior Member
Thanks, got it working

so in the end, I just had to set the master required and master field on the slave field and change my query in getConfiguredSqlSelect() in the LookupService where the important part is that I can use the :master as the bind value like

" where foreing_key_to_master_table = :master"


Previous Topic:File download from server
Next Topic:Correct way to create hotkeys
Goto Forum:
  


Current Time: Thu Mar 28 12:26:04 GMT 2024

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

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

Back to the top