Differences

This shows you the differences between two versions of the page.

Link to this comparison view

edit_person_s_details [2012/03/30 16:54]
srdjan.lukovic
edit_person_s_details [2012/07/09 10:48] (current)
srdjan.lukovic [GUI Code]
Line 1: Line 1:
-====== Edit Person's Details Sample ====== +====== Edit Object Details ====== 
-This sample presents simple form which shows details of selected personChoose any person from suggest box. Edited data in any field will be saved in the database - no save button is needed.+ 
 +**Edit Object Details** is a [[SOLoist Sample Applications|SOLoist sample application]] that is a simple form for editing details (slots) of selected objectIt relies on the //Element Component// as shown in [[Element Component|Data Input, View, and Edit Controls]]. 
 + 
 +The object to edit is selected in a text box with suggestion at the top. This text box is an input element component. It provides the selected object on its output pin that is wired to the input pin of the other editor element components.
  
 ==== Live example ==== ==== Live example ====
Line 6: Line 9:
 [[http://soloistdemo.org/SampleApplications/editpersondetails.html]]\\ [[http://soloistdemo.org/SampleApplications/editpersondetails.html]]\\
 [[http://soloistdemo.org/SampleApplications/oql?q=SELECT+p%2C+p.name%2C+p.gender%2C+p.age%2C+p.dateOfBirth%2C+p.height%2C+p.isMarried%2C+p.photo%2C+p.rootFolder%0D%0AFROM+Person+p&f=html | OQL Query: Persons]] [[http://soloistdemo.org/SampleApplications/oql?q=SELECT+p%2C+p.name%2C+p.gender%2C+p.age%2C+p.dateOfBirth%2C+p.height%2C+p.isMarried%2C+p.photo%2C+p.rootFolder%0D%0AFROM+Person+p&f=html | OQL Query: Persons]]
 +|{{screen:editpersondetails.png?250}}|
  
 ===== UML Model ===== ===== UML Model =====
Line 20: Line 24:
 import rs.sol.soloist.helpers.init.Initializer; import rs.sol.soloist.helpers.init.Initializer;
 import rs.sol.soloist.helpers.init.InitializerFailedException; import rs.sol.soloist.helpers.init.InitializerFailedException;
-import rs.sol.soloist.server.builtindomains.builtindatatypes.Text; 
 import rs.sol.soloist.server.guiconfiguration.components.GUIApplicationComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIApplicationComponent;
 import rs.sol.soloist.server.guiconfiguration.components.GUILabelComponent; import rs.sol.soloist.server.guiconfiguration.components.GUILabelComponent;
 import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent;
 import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding; import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding;
-import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUICollectionInput+import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIEdit
-import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIElementComponent+import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIInput
-import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUISlotEditorKind; +import rs.sol.soloist.server.guiconfiguration.layout.TableLayoutData;
-import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUISuggestWidget;+
 import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIFindAllInstancesSAPComponent; import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIFindAllInstancesSAPComponent;
 import rs.sol.soloist.server.server.SoloistServiceServlet; import rs.sol.soloist.server.server.SoloistServiceServlet;
Line 37: Line 39:
  
  @Override  @Override
- public void init() throws InitializerFailedException {+ public void init() throws InitializerFailedException 
 + {
  GUIApplicationComponent page = new GUIApplicationComponent();  GUIApplicationComponent page = new GUIApplicationComponent();
- page.name.set(Text.fromString("EditPersonDetails"));+ page.setName("EditPersonDetails"); 
  SoloistServiceServlet.registerApplication(page);  SoloistServiceServlet.registerApplication(page);
- page.context.set(DefaultContextInit.getRoot());+ page.setContext(DefaultContextInit.getRoot());
  
  GUIPanelComponent root = GUIPanelComponent.createFlow(page);  GUIPanelComponent root = GUIPanelComponent.createFlow(page);
  
  GUILabelComponent title = GUILabelComponent.create(root, "Edit Person Details");  GUILabelComponent title = GUILabelComponent.create(root, "Edit Person Details");
- title.styleName.set(Text.fromString("titleStyle"));+ title.setStyle("titleStyle");
  
  GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root);  GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root);
- topPanel.styleName.set(Text.fromString("topPanel"));+ topPanel.setStyle("topPanel");
  
  GUIPanelComponent table = GUIPanelComponent.createTable(topPanel);  GUIPanelComponent table = GUIPanelComponent.createTable(topPanel);
Line 56: Line 59:
  GUILabelComponent.create(table, "Choose person:", row, 0);  GUILabelComponent.create(table, "Choose person:", row, 0);
  
- GUIFindAllInstancesSAPComponent allPersons = GUIFindAllInstancesSAPComponent.create(root, Person.FQ_TYPE_NAME); + GUIFindAllInstancesSAPComponent allPersons = GUIFindAllInstancesSAPComponent.create(root, Person.CLASSIFIER); 
- // this component fetches all personsit is invisible component but still, it has to have a parent + // This component fetches all personsit is an invisible component but still, it has to have a parent 
- GUIElementComponent suggestBox = GUIElementComponent.createInput(table, new GUISuggestWidget(), new GUICollectionInput(), row++, 1); + GUIInput suggestBox = GUIInput.createSuggest(table, TableLayoutData.create(row++, 1)); 
- GUIComponentBinding.create(allPersons.valueGUICollectionInput.get(suggestBox).collection);+ GUIComponentBinding.create(allPersons.opValue()suggestBox.ipCollection());
  
  GUILabelComponent.create(table, "Name: ", row, 0);  GUILabelComponent.create(table, "Name: ", row, 0);
- GUIElementComponent nameEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.name, row++, 1); + // Slot editor component: it submits the value into the database on focus lost or on enter pressed 
- // slot editor component: it submits the value into the database on focus lost or on enter pressed + GUIEdit nameEditor = GUIEdit.createField(table, Person.PROPERTIES.name, TableLayoutData.create(row++, 1));  
 +
  GUILabelComponent.create(table, "Gender: ", row, 0);  GUILabelComponent.create(table, "Gender: ", row, 0);
- GUIElementComponent genderEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.gender, row++, 1);+ GUIEdit genderEditor = GUIEdit.createField(table, Person.PROPERTIES.gender, TableLayoutData.create(row++, 1));
  
  GUILabelComponent.create(table, "Age: ", row, 0);  GUILabelComponent.create(table, "Age: ", row, 0);
- GUIElementComponent ageEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.age, row++, 1);+ GUIEdit ageEditor = GUIEdit.createField(table, Person.PROPERTIES.age, TableLayoutData.create(row++, 1));
  
  GUILabelComponent.create(table, "Date of birth: ", row, 0);  GUILabelComponent.create(table, "Date of birth: ", row, 0);
- GUIElementComponent dateOfBirthEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.dateOfBirth, row++, 1);+ GUIEdit dateOfBirthEditor = GUIEdit.createField(table, Person.PROPERTIES.dateOfBirth, TableLayoutData.create(row++, 1));
  
  GUILabelComponent.create(table, "Height [m]: ", row, 0);  GUILabelComponent.create(table, "Height [m]: ", row, 0);
- GUIElementComponent heightEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.height, row++, 1);+ GUIEdit heightEditor = GUIEdit.createField(table, Person.PROPERTIES.height, TableLayoutData.create(row++, 1));
  
  GUILabelComponent.create(table, "Is married: ", row, 0);  GUILabelComponent.create(table, "Is married: ", row, 0);
- GUIElementComponent isMarriedEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.isMarried, row++, 1);+ GUIEdit isMarriedEditor = GUIEdit.createField(table, Person.PROPERTIES.isMarried, TableLayoutData.create(row++, 1));
  
- GUIComponentBinding.create(suggestBox.valueGUISlotEditorKind.get(nameEditor).element); + GUIComponentBinding.create(suggestBox.opValue()nameEditor.ipElement()); 
- GUIComponentBinding.create(suggestBox.valueGUISlotEditorKind.get(genderEditor).element); + GUIComponentBinding.create(suggestBox.opValue()genderEditor.ipElement()); 
- GUIComponentBinding.create(suggestBox.valueGUISlotEditorKind.get(ageEditor).element); + GUIComponentBinding.create(suggestBox.opValue()ageEditor.ipElement()); 
- GUIComponentBinding.create(suggestBox.valueGUISlotEditorKind.get(dateOfBirthEditor).element); + GUIComponentBinding.create(suggestBox.opValue()dateOfBirthEditor.ipElement()); 
- GUIComponentBinding.create(suggestBox.valueGUISlotEditorKind.get(heightEditor).element); + GUIComponentBinding.create(suggestBox.opValue()heightEditor.ipElement()); 
- GUIComponentBinding.create(suggestBox.valueGUISlotEditorKind.get(isMarriedEditor).element);+ GUIComponentBinding.create(suggestBox.opValue()isMarriedEditor.ipElement());
  }  }
 } }
 </code> </code>
Print/export