Edit Object Details

Edit Object Details is a SOLoist sample application that is a simple form for editing details (slots) of a selected object. It relies on the Element Component as shown in 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

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.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.GUIEdit;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIInput;
import rs.sol.soloist.server.guiconfiguration.layout.TableLayoutData;
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.setName("EditPersonDetails"); 
		SoloistServiceServlet.registerApplication(page);
		page.setContext(DefaultContextInit.getRoot());
 
		GUIPanelComponent root = GUIPanelComponent.createFlow(page);
 
		GUILabelComponent title = GUILabelComponent.create(root, "Edit Person Details");
		title.setStyle("titleStyle");
 
		GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root);
		topPanel.setStyle("topPanel");
 
		GUIPanelComponent table = GUIPanelComponent.createTable(topPanel);
 
		int row = 0;
		GUILabelComponent.create(table, "Choose person:", row, 0);
 
		GUIFindAllInstancesSAPComponent allPersons = GUIFindAllInstancesSAPComponent.create(root, Person.CLASSIFIER);
		// This component fetches all persons; it is an invisible component but still, it has to have a parent
		GUIInput suggestBox = GUIInput.createSuggest(table, TableLayoutData.create(row++, 1));
		GUIComponentBinding.create(allPersons.opValue(), suggestBox.ipCollection());
 
		GUILabelComponent.create(table, "Name: ", row, 0);
		// 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);
		GUIEdit genderEditor = GUIEdit.createField(table, Person.PROPERTIES.gender, TableLayoutData.create(row++, 1));
 
		GUILabelComponent.create(table, "Age: ", row, 0);
		GUIEdit ageEditor = GUIEdit.createField(table, Person.PROPERTIES.age, TableLayoutData.create(row++, 1));
 
		GUILabelComponent.create(table, "Date of birth: ", row, 0);
		GUIEdit dateOfBirthEditor = GUIEdit.createField(table, Person.PROPERTIES.dateOfBirth, TableLayoutData.create(row++, 1));
 
		GUILabelComponent.create(table, "Height [m]: ", row, 0);
		GUIEdit heightEditor = GUIEdit.createField(table, Person.PROPERTIES.height, TableLayoutData.create(row++, 1));
 
		GUILabelComponent.create(table, "Is married: ", row, 0);
		GUIEdit isMarriedEditor = GUIEdit.createField(table, Person.PROPERTIES.isMarried, TableLayoutData.create(row++, 1));
 
		GUIComponentBinding.create(suggestBox.opValue(), nameEditor.ipElement());
		GUIComponentBinding.create(suggestBox.opValue(), genderEditor.ipElement());
		GUIComponentBinding.create(suggestBox.opValue(), ageEditor.ipElement());
		GUIComponentBinding.create(suggestBox.opValue(), dateOfBirthEditor.ipElement());
		GUIComponentBinding.create(suggestBox.opValue(), heightEditor.ipElement());
		GUIComponentBinding.create(suggestBox.opValue(), isMarriedEditor.ipElement());
	}
}
Print/export