Table of Contents
Grids
Grids is a SOLoist sample application that demonstrates various tabular views of object details.
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.nonvisualcompoments.GUIFindAllInstancesSAPComponent; import rs.sol.soloist.server.guiconfiguration.style.GUIContext; import rs.sol.soloist.server.guiconfiguration.style.GUIObjectSetting; import rs.sol.soloist.server.guiconfiguration.style.GUIPictureFeature; import rs.sol.soloist.server.guiconfiguration.style.GUITextFeature; import rs.sol.soloist.server.server.SoloistServiceServlet; public enum PersonsTable implements Initializer{ INSTANCE; @Override public void init() throws InitializerFailedException { GUIApplicationComponent page = new GUIApplicationComponent(); page.setName("PersonsTable"); SoloistServiceServlet.registerApplication(page); GUIContext context = createContextAndStyles(); page.setContext(context); GUIPanelComponent root = GUIPanelComponent.createVertical(page); GUILabelComponent title = GUILabelComponent.create(root, "Persons Table"); title.setStyle("titleStyle"); GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root); topPanel.setStyle("topPanel"); // This component fetches all persons GUIFindAllInstancesSAPComponent allPersons = GUIFindAllInstancesSAPComponent.create(root, Person.CLASSIFIER); GUILabelComponent.create(topPanel, "Editable fields").setStyle("subtitle"); createPersonsTable(topPanel, allPersons, false, false); GUILabelComponent.create(topPanel, "Readonly fields").setStyle("subtitle"); createPersonsTable(topPanel, allPersons, true, false); GUILabelComponent.create(topPanel, "Readonly fields as labels").setStyle("subtitle"); createPersonsTable(topPanel, allPersons, true, true); } private void createPersonsTable(GUIPanelComponent root, GUIFindAllInstancesSAPComponent allPersons, boolean readonly, boolean displayAsLabel) { // column components GUIEdit nameEditor = GUIEdit.createField(null, Person.PROPERTIES.name); nameEditor.setReadOnly(readonly); nameEditor.setDisplayAsLabel(displayAsLabel); GUIEdit genderEditor = GUIEdit.createField(null, Person.PROPERTIES.gender); genderEditor.setReadOnly(readonly); genderEditor.setDisplayAsLabel(displayAsLabel); GUIEdit ageEditor = GUIEdit.createField(null, Person.PROPERTIES.age); ageEditor.setReadOnly(readonly); ageEditor.setDisplayAsLabel(displayAsLabel); GUIEdit dateOfBirthEditor = GUIEdit.createField(null, Person.PROPERTIES.dateOfBirth); dateOfBirthEditor.setReadOnly(readonly); dateOfBirthEditor.setDisplayAsLabel(displayAsLabel); GUIEdit heightEditor = GUIEdit.createField(null, Person.PROPERTIES.height); heightEditor.setReadOnly(readonly); heightEditor.setDisplayAsLabel(displayAsLabel); GUIEdit isMarriedEditor = GUIEdit.createField(null, Person.PROPERTIES.isMarried); isMarriedEditor.setReadOnly(readonly); isMarriedEditor.setDisplayAsLabel(displayAsLabel); GUIInput editableTable = GUIInput.createTable(root, "Person", "Name", "Gender", "Age", "Date of Birth", "Height", "Is Married"); editableTable.setColumnComponents(nameEditor, genderEditor, ageEditor, dateOfBirthEditor, heightEditor, isMarriedEditor); editableTable.setMinRows(3); // min rows to show if there is no data in the table GUIComponentBinding.create(allPersons.opValue(), editableTable.ipCollection()); } private GUIContext createContextAndStyles() { GUIContext context = new GUIContext(); DefaultContextInit.getRoot().addContext(context); GUIObjectSetting person = GUIObjectSetting.create(context, Person.CLASSIFIER); GUITextFeature.createName(person, Person.PROPERTIES.name); GUIPictureFeature.createSmallIcon(person, "images/icons/person.png"); return context; } }