In this task you will understand the properties of a single field in an objectUI dialog box, in other words, the syntax and the possibilites of the <attribute element. In this example we choose the Edit workstate dialog box in the EdAdmin4 application, defined in the EdAdmin4_Config.xml configuration file. |
You will be able to perform this task only if: •You already opened the edadmin4_config.xml file as explained in TASK: Open for editing one or more files with objectUI elements and ordered the view as explained in TASK: Display an ordered view of objectUI elements. If not so, return to those tasks and perform them first, and then return here. |
1.Within the definition of the objectUI editWorkstate, locate, by pressing the <attribute name="name"> <ui mode="Normal"/> </attribute> As you can clearly see, in this simple variant, the attribute has one property called name with the value "name", and one object element called ui, which in turn has one property called mode with the value "Normal". By default, Visual Studio paints property names in red, values in blue, and object elements in dark red. The above is a rather short definition available. The purpose of the ui object element is to set some standard behaviors. In this example, the value "Normal" simply means the field will be editable, while the value "ReadOnly" will lock it against editing. The part <attribute begins the attribute definition, while the part </attribute> ends it. You must be very careful about syntax. 2.Now, expand and review the second attribute, related to the Color field: <attribute name="color"> <ui mode="Normal"> <template kind="Color" xmlns="http://www.teradp.com/schemas/GN4/1/XmlSchemaExt.xsd"/> </ui> </attribute> This is already more complicated. Its object element <template has the property kind with the value "Color" and the namespace xmlns with the value "http://www.teradp.com/schemas/GN4/1/XmlSchemaExt.xsd". Please notice that all the complexity of the user interface is hidden from the user. Color picker is internally defined, and to get it on screen it is enough to specify the kind="Color". In the further text we will explain which templates are available for which attributes. 3.Let's look at the third attribute, the one of the Description field, whose template has an additional object element, that limits the number of the description rows to 4: <attribute name="description"> <ui mode="Normal"> <template kind="MultiLineString" xmlns="http://www.teradp.com/schemas/GN4/1/XmlSchemaExt.xsd"> <objectUI> <web maxRows="4"/> </objectUI> </template> </ui> </attribute> A note here: you can safely split long lines with many properties into separate lines, just by pressing Enter - no problem will occur because of such editing. In the previous example, we moved the kind and xmlns into own lines for better readability. 4.The Percentage field is pretty similar to the Description field, but it's kind is "SimpleString" (so you cannot go to new line), the spelling of that field is disabled, and the <objectUI> element limits the number of characters in the field to 4 (e.g. 100%, but not 4000%). <attribute name="percentComplete"> <ui mode="Normal" instruction="workstatePercentComplete"> <template kind="SimpleString" useSpellChecker="no" xmlns="http://www.teradp.com/schemas/GN4/1/XmlSchemaExt.xsd"> <objectUI> <web maxCharsPerLine="4"/> </objectUI> </template> </ui> Conclusions: •You learned about the <attribute tag and a little bit about its structure. •You noticed that the complexity of the user interface is hidden from the person who configures it, and the only difficulty is to know the names of the available attributes, element objects and similar - but that's what the reference documentation serves for. •You saw few examples of the <template element object and its properties. Exercises •Modify the value in <web maxRows="4"/> to 2 or to 6 and see how it behaves. Important: remember that you have to save the file and import it in the database as explained in TASK: Save changes and import them in database. Then review the changes in the application, as explained in TASK: Review configuration changes in the application. More reading |