Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Multi Column SmartField
Multi Column SmartField [message #1553263] Thu, 08 January 2015 15:55 Go to next message
Peter Pfeifer is currently offline Peter PfeiferFriend
Messages: 213
Registered: November 2014
Senior Member

Hello there

according to this blog entry and this wiki entry it's possible to provide a multi column smart field.

Now I was thinking of updating other form fields after a value from the smart field was selected.

Lets assume that the smart field has the following columns:
ID|Firstname|Lastname|Street|ZipCode|City

After selecting an entry I'd like to update the corresponding fields on the form. Namely the Firstname|Lastname|Street|ZipCode|City fields.

Is this possible?

Thanks

Peter
Re: Multi Column SmartField [message #1553625 is a reply to message #1553263] Thu, 08 January 2015 20:33 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I love the questions on the forum where I learn something new about Scout. Wink

My instinct was telling me: NO, not possible. I was thinking that this is a limitation of the SmartField because you can only access the key of the LookupRow that is set as Value in the SmartField when the proposal Form is closed.

BUT I looked into the code and I discovered the getCurrentLookupRow() method. You can use it to access the LookupRow (and access the additionalRowData you are interested in):
@Override
protected void execChangedValue() throws ProcessingException {
  ILookupRow<Long> lookupRow = getCurrentLookupRow();
  PersonTableRowData additionalTableRowData = (PersonTableRowData) lookupRow.getAdditionalTableRowData();
  System.err.println(lookupRow.getText());
  System.err.println(lookupRow.getTooltipText());
  System.err.println(additionalTableRowData.getCity());
  System.err.println(additionalTableRowData.getBirthdate());
}


Please do not hesitate to share your findings about this method. I hope it works as I have told you.

.
Re: Multi Column SmartField [message #1554450 is a reply to message #1553625] Fri, 09 January 2015 07:44 Go to previous messageGo to next message
Peter Pfeifer is currently offline Peter PfeiferFriend
Messages: 213
Registered: November 2014
Senior Member

Hello Jeremie,

thanks for the hint. I'll have a look at it. But first I have to setup a multi column SQLLookup Service properly... somehow Smile

I''ll keep you posted

Peter
Re: Multi Column SmartField [message #1554593 is a reply to message #1554450] Fri, 09 January 2015 09:32 Go to previous message
Peter Pfeifer is currently offline Peter PfeiferFriend
Messages: 213
Registered: November 2014
Senior Member

Ok. It seems to work.

execChangeValue does the trick for retrieving the selected values.

In order to fill the multi column smart field with an SQLLookupService I overwrote the method in order to be able to access the other columsn fromt the SQL statement:
/* (non-Javadoc)
   * @see org.eclipse.scout.rt.server.services.lookup.AbstractSqlLookupService#execLoadLookupRows(java.lang.String, java.lang.String, org.eclipse.scout.rt.shared.services.lookup.ILookupCall)
   */
  @Override
  protected List<ILookupRow<Long>> execLoadLookupRows(String originalSql, String preprocessedSql, ILookupCall<Long> call) throws ProcessingException {
    Object[][] data = SQL.selectLimited(preprocessedSql, 1000, call);
    if (getConfiguredSortColumn() >= 0) {
      sortData(data, getConfiguredSortColumn());
    }
    try {
      Class<?> genericsParameterClass = Object.class;
      try {
        genericsParameterClass = TypeCastUtility.getGenericsParameterClass(getClass(), ILookupService.class);
      }
      catch (IllegalArgumentException e) {
        System.err.println("Unable to calculate type parameters for lookup service '" + getClass().getName() + "'. No key type validation will be performed.");
      }
      List<ILookupRow<Long>> rows = createLookupRowArray(data, call, genericsParameterClass);
      int i = 0;
      for (ILookupRow<Long> row : rows) {
        CustomerCompleteTableRowData bean = new CustomerCompleteTableRowData();
        bean.setFirstname((String) data[i][1]);
        bean.setLastname((String) data[i][2]);
        bean.setCity((String) data[i][5]);
        bean.setStreet((String) data[i][3]);
        bean.setZip((String) data[i][4]);
        row.setAdditionalTableRowData(bean);
        i++;
      }
      return rows;
    }
    catch (IllegalArgumentException e) {
      throw new ProcessingException("Unable to load lookup rows for lookup service '" + getClass().getName() + "'.", e);
    }
  }


I don't know if this is the most appropriate way to achieve a multi column smart field with DB backend or not. If not, please let me know. I'm eager to learn Smile

Peter
Previous Topic:How to update a tree in a tree field?
Next Topic:execAboutToShow()
Goto Forum:
  


Current Time: Wed Sep 25 23:31:04 GMT 2024

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

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

Back to the top