Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367850 - XML I/O on IForm does not work for IFormFields with non-unique class name
Summary: XML I/O on IForm does not work for IFormFields with non-unique class name
Status: CLOSED DUPLICATE of bug 377781
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Scout (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-04 09:24 EST by Bruno Koeferli CLA
Modified: 2021-08-19 11:25 EDT (History)
2 users (show)

See Also:
judith.gull: juno+


Attachments
Patch implementing the PROPOSED SOLUTION (6.79 KB, patch)
2012-01-04 09:24 EST, Bruno Koeferli CLA
no flags Details | Diff
Patch set form on listbox and treebox fields (2.39 KB, application/octet-stream)
2012-03-28 09:40 EDT, Judith Gull CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Koeferli CLA 2012-01-04 09:24:10 EST
Created attachment 209010 [details]
Patch implementing the PROPOSED SOLUTION

Build Identifier: 3.7.0.2011-Jun 2011

PROBLEM DESCRIPTION:
XML I/O on IForm (IForm.storeXML and IForm.loadXML) does not work properly for IFormFields with a non-unique class name. F.e. if a SearchForm with two tabs which both contains a TextField with the same class name.

EVALUATION:
The problem is located in IFormField.storeXML and IForm.storeXML where the field ID is always treated as "getClass().getSimpleName()". This leads to the known problem with same-named fields in different parent classes (f.e. tabs).

PROPOSED SOLUTION:
The IFromField provide a method getXMLFieldId which will be used for XML I/O. This method will return the fields simple class name by default and can be overridden if a special handling (f.e. same-named fields in different parent classes) is needed.
The attached patch adds this method and makes use of it in IFormField.storeXML and IForm.storeXML.

Reproducible: Always
Comment 1 Judith Gull CLA 2012-03-27 12:22:25 EDT
With the proposed solution the method getXMLFieldId() has to be overwritten for all ambiguous fields, which is very unpractical. Problems caused by ambiguous fields will only be detected on runtime.

A hierarchical structure would solve the ambiguity problem, but would make the loading less lenient. In the current implementation it is possible to move a field to another group box or to rename a group box without migrating the xml file. This would not be possible when using the complete hierarchical structure.

I changed the proposed solution such that a field is identified by its simple name and as many parent names as necessary to make it unique. This should work for most cases by default and allow a lot of refactoring without migration.

It is still possible to set a custom XMLFieldId by overriding org.eclipse.scout.rt.client.ui.form.fields.AbstractFormField.getXMLFieldId(), if needed.

Loading older XML files with ambiguous fields is still possible: Data is imported to the first field found (as before).

Migration:None
Comment 2 Judith Gull CLA 2012-03-27 13:08:53 EDT
Please review & test. Is this ticket needed for a branch?
Comment 3 Judith Gull CLA 2012-03-28 09:40:44 EDT
Created attachment 213292 [details]
Patch set form on listbox and treebox fields
Comment 4 Judith Gull CLA 2012-03-28 09:47:06 EDT
Fixed bug reported by Claudio Guglielmo. Exception in BookmarkUtility, if form is not set on a field. In this case a fallback to the simple name is used.

Listboxes and treeboxes contain fields that are visited without a form. The form should probably be set there as well. See attached patch.

      at org.eclipse.scout.rt.client.ui.form.AbstractForm.getXML(AbstractForm.java:1786)
      at org.eclipse.scout.rt.client.services.common.bookmark.internal.BookmarkUtility.bmStoreTablePage(BookmarkUtility.java:603)
      at org.eclipse.scout.rt.client.services.common.bookmark.internal.BookmarkUtility.createBookmark(BookmarkUtility.java:400)
      at org.eclipse.scout.rt.client.services.common.bookmark.internal.BookmarkUtility.createBookmark(BookmarkUtility.java:307)
      at org.eclipse.scout.rt.client.ui.desktop.AbstractDesktop.createBookmark(AbstractDesktop.java:1399)
      at org.eclipse.scout.rt.client.ui.basic.table.OrganizeColumnsForm$ModifyHandler.execLoad(OrganizeColumnsForm.java:1159)
      at org.eclipse.scout.rt.client.ui.form.AbstractFormHandler.onLoad(AbstractFormHandler.java:181)
      at org.eclipse.scout.rt.client.ui.form.AbstractForm.loadStateInternal(AbstractForm.java:1136)
      at org.eclipse.scout.rt.client.ui.form.AbstractForm.startInternal(AbstractForm.java:664)
      at org.eclipse.scout.rt.client.ui.basic.table.OrganizeColumnsForm.startModify(OrganizeColumnsForm.java:96)
      at org.eclipse.scout.rt.client.ui.basic.table.menus.OrganizeColumnsMenu.execAction(OrganizeColumnsMenu.java:37)
      at org.eclipse.scout.rt.client.ui.action.AbstractAction.doAction(AbstractAction.java:297)
      at org.eclipse.scout.rt.client.ui.action.AbstractAction$P_UIFacade.fireActionFromUI(AbstractAction.java:598)
      at org.eclipse.scout.rt.ui.rap.action.AbstractRwtMenuAction$1.run(AbstractRwtMenuAction.java:180)
      at org.eclipse.scout.rt.ui.rap.core.concurrency.RwtScoutSynchronizer$1.runVoid(RwtScoutSynchronizer.java:61)
      at org.eclipse.scout.rt.client.ClientJob.runStatus(ClientJob.java:177)
      at org.eclipse.scout.rt.client.ClientJob.runTransactionWrapper(ClientJob.java:161)
      at org.eclipse.scout.rt.client.ClientJob.run(ClientJob.java:149)
      at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
      at org.eclipse.scout.rt.client.ui.form.fields.AbstractFormField.getXMLFieldId(AbstractFormField.java:822)
      at org.eclipse.scout.rt.client.ui.form.fields.AbstractFormField.storeXML(AbstractFormField.java:828)
      at org.eclipse.scout.rt.client.ui.form.AbstractForm$13.visitField(AbstractForm.java:1841)
      at org.eclipse.scout.rt.client.ui.form.fields.AbstractCompositeField.visitFields(AbstractCompositeField.java:184)
      at org.eclipse.scout.rt.client.ui.form.fields.listbox.AbstractListBox.visitFields(AbstractListBox.java:886)
      at org.eclipse.scout.rt.client.ui.form.fields.AbstractCompositeField.visitFields(AbstractCompositeField.java:192)
      at org.eclipse.scout.rt.client.ui.form.fields.AbstractCompositeField.visitFields(AbstractCompositeField.java:192)
      at org.eclipse.scout.rt.client.ui.form.fields.AbstractCompositeField.visitFields(AbstractCompositeField.java:192)
      at org.eclipse.scout.rt.client.ui.form.AbstractForm.visitFields(AbstractForm.java:962)
      at org.eclipse.scout.rt.client.ui.form.AbstractForm.storeXML(AbstractForm.java:1851)
      at org.eclipse.scout.rt.client.ui.form.AbstractForm.storeXML(AbstractForm.java:1794)
      at org.eclipse.scout.rt.client.ui.form.AbstractForm.getXML(AbstractForm.java:1776)
Comment 5 Andi Bur CLA 2012-04-26 12:10:43 EDT
Additional requirements came up. The actual issues reported in this bug are now tracked in bug #377781. Marking this ticket as duplicate.

*** This bug has been marked as a duplicate of bug 377781 ***
Comment 6 Matthias Zimmermann CLA 2012-07-09 06:45:58 EDT
bug closed