This is an old revision of the document!
Table of Contents
Edit Person's Details Sample
This sample presents simple form which shows details of selected person. Choose any person from suggest box. Edited data in any field will be saved in the database - no save button is needed.
Live example
UML Model
Business Logic Code
None.
GUI Code
package rs.sol.sampleapps; import rs.sol.soloist.helpers.init.DefaultContextInit; import rs.sol.soloist.helpers.init.Initializer; 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.GUILabelComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent; import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding; import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUICollectionInput; import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIElementComponent; import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUISlotEditorKind; import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUISuggestWidget; import rs.sol.soloist.server.guiconfiguration.nonvisualcompoments.GUIFindAllInstancesSAPComponent; import rs.sol.soloist.server.server.SoloistServiceServlet; public enum EditPersonDetails implements Initializer { INSTANCE; @Override public void init() throws InitializerFailedException { GUIApplicationComponent page = new GUIApplicationComponent(); page.name.set(Text.fromString("EditPersonDetails")); SoloistServiceServlet.registerApplication(page); page.context.set(DefaultContextInit.getRoot()); GUIPanelComponent root = GUIPanelComponent.createFlow(page); GUILabelComponent title = GUILabelComponent.create(root, "Edit Person Details"); title.styleName.set(Text.fromString("titleStyle")); GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root); topPanel.styleName.set(Text.fromString("topPanel")); GUIPanelComponent table = GUIPanelComponent.createTable(topPanel); int row = 0; GUILabelComponent.create(table, "Choose person:", row, 0); GUIFindAllInstancesSAPComponent allPersons = GUIFindAllInstancesSAPComponent.create(root, Person.FQ_TYPE_NAME); // this component fetches all persons, it is invisible component but still, it has to have a parent GUIElementComponent suggestBox = GUIElementComponent.createInput(table, new GUISuggestWidget(), new GUICollectionInput(), row++, 1); GUIComponentBinding.create(allPersons.value, GUICollectionInput.get(suggestBox).collection); 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 GUILabelComponent.create(table, "Gender: ", row, 0); GUIElementComponent genderEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.gender, row++, 1); GUILabelComponent.create(table, "Age: ", row, 0); GUIElementComponent ageEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.age, row++, 1); GUILabelComponent.create(table, "Date of birth: ", row, 0); GUIElementComponent dateOfBirthEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.dateOfBirth, row++, 1); GUILabelComponent.create(table, "Height [m]: ", row, 0); GUIElementComponent heightEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.height, row++, 1); GUILabelComponent.create(table, "Is married: ", row, 0); GUIElementComponent isMarriedEditor = GUIElementComponent.createSlotEditor(table, Person.PROPERTIES.isMarried, row++, 1); GUIComponentBinding.create(suggestBox.value, GUISlotEditorKind.get(nameEditor).element); GUIComponentBinding.create(suggestBox.value, GUISlotEditorKind.get(genderEditor).element); GUIComponentBinding.create(suggestBox.value, GUISlotEditorKind.get(ageEditor).element); GUIComponentBinding.create(suggestBox.value, GUISlotEditorKind.get(dateOfBirthEditor).element); GUIComponentBinding.create(suggestBox.value, GUISlotEditorKind.get(heightEditor).element); GUIComponentBinding.create(suggestBox.value, GUISlotEditorKind.get(isMarriedEditor).element); } }