Skip to main content



      Home
Home » Eclipse Projects » Eclipse Scout » getAdditionalRowData returns null
getAdditionalRowData returns null [message #1834699] Mon, 16 November 2020 07:16 Go to next message
Eclipse UserFriend
Hello,

So I build an Custom table smart field according to the github example. This works perfect, so i got 2 columns in the smartfield.

LookupCall looks like this:
  @Override
  protected List<? extends ILookupRow<Long>> execCreateLookupRows() {
    IProjectService service = BEANS.get(IProjectService.class);
    List<LookupRow<Long>> rows = new ArrayList<>();
    for (List<Object> projectData : service.getHierarchicalProjectLookupData()) {
      Long projectId = (Long) projectData.get(0);
      String projectName = (String) projectData.get(1);
      String projectNumber = (String) projectData.get(2);
      
      LookupRow<Long> row = new LookupRow<Long>(projectId, projectName);
      HierarchicalProjectRowData bean = new HierarchicalProjectRowData();
      bean.setProjectNumber(projectNumber);
      row.withAdditionalTableRowData(bean);
      rows.add(row);
    }
    return rows;
  }
  
  public class HierarchicalProjectRowData extends AbstractTableRowData {

    private static final long serialVersionUID = -7729290938303347521L;
    public static final String projectNumber = "projectNumber";
    
    private String m_projectNumber;
    
    public String getProjectNumber() {
      return m_projectNumber;
    }
    
    public void setProjectNumber(String m_projectNumber) {
      this.m_projectNumber = m_projectNumber;
    }
  }

Now what i want is to get the additionalTableRowData.
So in the Smartfield under execValueChanged i call getLookupRow and on that I call getAdditionalTableRowData but this returns null. I dug into it a bit and saw that it builds an LookupRow from a JsonObject and in there the information is still there. But now I dont know how to proceed.

How would I get the additionalTableRowData of that LookupRow?

Scout V10 (classic)

Thank you all in advance,
Luis
Re: getAdditionalRowData returns null [message #1834713 is a reply to message #1834699] Mon, 16 November 2020 12:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi Luis

You need to implement getConfiguredColumnDescriptors() in your SmartField. See this example in the Widgets application:
https://scout.bsi-software.com/widgets/?dl=widget-smartfield (Custom table field)

Source code is here:
https://github.com/BSI-Business-Systems-Integration-AG/org.eclipse.scout.docs/blob/5d4fcadbb90d3b9c1667e507d63b497e8c52936e/code/widgets/org.eclipse.scout.widgets.client/src/main/java/org/eclipse/scout/widgets/client/ui/forms/SmartFieldForm.java#L452

Cheers,
André




Re: getAdditionalRowData returns null [message #1834714 is a reply to message #1834713] Mon, 16 November 2020 12:46 Go to previous messageGo to next message
Eclipse UserFriend
Hi Andre,

Yes I already have that. Maybe i wasnt clear. The Smartfield works fine. It shows both columns with values in it.

The only problem I have is accessing the additionTableRowData from the LookupRow.

Regards,
Luis
Re: getAdditionalRowData returns null [message #1834747 is a reply to message #1834714] Tue, 17 November 2020 05:20 Go to previous messageGo to next message
Eclipse UserFriend
Hi Luis

Long time ago I've made this comment here in JsonSmartField.java:
    // Info: cannot de-serialize 'additionalTableRowData' because it uses generic
    // JSON serialization. See JsonLookupRow#tableRowDataToJson - this shouldn't
    // be a problem because that data is only used in the proposal chooser


So there seems to be a good reason, why the additional data is not applied when the lookup row is selected in the UI.

I'd suggest to use the LookupCall again in execValueChanged and call getByKey() using the value as key. Then read the additional table data from the lookup row returned by the LookupCall.

André
Re: getAdditionalRowData returns null [message #1835267 is a reply to message #1834747] Sat, 28 November 2020 16:19 Go to previous message
Eclipse UserFriend
I had the same problem and solved it. Try something like this:
                              public HierarchicalProjectRowData getAdditionalTableRowData() {
					if(getLookupRow() == null) {
						return null;
					} else {
						HierarchicalProjectRowData rowData = (HierarchicalProjectRowData)getLookupRow().getAdditionalTableRowData();
						
						if(rowData == null) {
							Iterator<ILookupRow<Long>> resultLookupRows = getResult().getLookupRows().iterator();
							
							while(resultLookupRows.hasNext()) {
								ILookupRow<Long> lookupRow = resultLookupRows.next();
								
								if(lookupRow.getKey().equals(getValue())) {
									rowData = (HierarchicalProjectRowData)lookupRow.getAdditionalTableRowData();
									break;
								}
							}
						}
						
						return rowData;
					}
				}

				@Override
				protected void execChangedValue() {
					HierarchicalProjectRowData rowData = getAdditionalTableRowData();

					//TODO: your logic 
				}
Previous Topic:SQL vs. bean data column in table
Next Topic:Rich content in desktop notifications
Goto Forum:
  


Current Time: Tue Jul 08 22:11:45 EDT 2025

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

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

Back to the top