Presentation is loading. Please wait.

Presentation is loading. Please wait.

® IBM Software Group © 2006 IBM Corporation EGL Programming - Data Parts and Assignment Statements - 2 - DataItems These slides walk you through the terms.

Similar presentations


Presentation on theme: "® IBM Software Group © 2006 IBM Corporation EGL Programming - Data Parts and Assignment Statements - 2 - DataItems These slides walk you through the terms."— Presentation transcript:

1 ® IBM Software Group © 2006 IBM Corporation EGL Programming - Data Parts and Assignment Statements DataItems These slides walk you through the terms and concepts around declaring EGL variables using DataItem definitions. This learning module also covers EGL data properties in-depth.

2 2 2. DataItems – Defining Custom Types or “Domain Definitions”  EGL supports the creation of new types for your application domains, that consist of extended semantic definitions for common application development requirements through a language abstraction known as DataItems.  A DataItem is a single element definition that associates a primitive data type with extended properties. Using DataItems you can create an operational “data dictionary” for your application with business rules entered into a central repository (a file of DataItems), coded and tested once and reused throughout.  Examples: dataitem Password String { DisplayUse=Secret, DisplayName = "Enter Password", InputRequired = yes } end  Defines a Password type as a string, that:  Displays asterisks when bound to a JSF control  The default label it creates is “Enter Password:”  The user must enter a value, or the EGL generated code – will return an error message dataitem OrderAmount Money(9, 2) { NumericSeparator = yes, ValidValues = [1.00, ] } end dataitem StateAbbrev String { ValidValues = ["AK","AL","CT","DE","NC","TX","NJ"] } end  Can you figure out what semantic validations the OrderAmount and StateAbbrev DataItems provide?

3 3 Declaring an EGL DataItem – Syntax Format Prototype: DataItem { EGL Properties } end Example: DataItem Last_Name_Inp string { displayUse = input, displayName = “Enter Last Name”, inputRequired = yes, validatorFunction = lnameValFunc } end 1.Dragging a variable of this type onto a web page will create an input control 2.The label of this control will be: “Enter Last Name:” 3.This is not an optional entry field for users 4.A function in the JSFHandler named: lnameValFunc will be invoked automatically, to ensure that the data entered conforms to more complex business rules

4 4 I’ve Already Used DataItems + F3 (Open on Selection)  Yes! When you imported the tables with the Data Access Application wizard, that process created a DataDefinitions.egl file – with default DataItems that were referenced in the fields of the records used in allcustomers2, updatecustomer2, allorders, etc. F3 (Best Practice)  F3 (Best Practice) Edit allcustomers2. egl. Highlight the Customer record definition and press F3 (this will open the record definition in the Content Area). You can then highlight a DataItem (type) in the record, and press F3 to see the original DataItem definition. F3  F3

5 5 DataItems – Best Practices – 1 of 2 – Generic/Specific Domains  DataItem Best Practices fall into two basic categories: 1.Individual/specific field domain definition 2.Generic domain definition Specific (individual field) DataItem Definitions: - You can define an individual DataItem (or most of the DataItems) for individual fields in Records and variables throughout your application***Notes - Typically, you would embed as many domain-specific customized properties as you can, when taking this approach dataItem Password String {DisplayUse=Secret,DisplayName="Enter Password", InputRequired=yes} end dataItem OrderAmount Money(8,2) {NumericSeparator=yes, ValidValues=[1.00, ]} end dataitem OrderDetails String {DisplayName="Order Details"} end dataitem CurrentStates String {ValidValues = ["AK","AL","CT","DE","NC","TX","NJ"]} end dataitem CustID int {DisplayUse=outPut,DisplayName="Customer ID",ValidValues=[1,999999]} end Generic (reusable/domain) DataItem Definitions - You can define “global” DataItem types for domains you use repeatedly throughout your application. Ex. MoneyType (9,2), DateType (dateFormat, etc.) - You would probably declare a minimal number of generic/common properties for such definitions, and then add to/over-ride when you declare variables of these types (see next slide) dataitem NameType String { upperCase = yes } end dataitem IDType int { DisplayUse=outPut, DisplayName="ID" } end dataitem MoneyType Money(8, 2) { NumericSeparator = yes, sign=leading } end dataitem DateType Date {dateFormat=eurDateFormat} end dataitem StateType char(2) {ValidValues = ["AK","AL", "AS", "AR", "AZ", "CA", "CO", "CT"…]}

6 6 DataItems – Best Practices – 2 of 2 – Over-riding Properties  For any use (reference to) a DataItem type, in one of your logic parts, you may: 1.Insert new properties – which are added to the property list defined in the DataItem 2.Over-ride properties – which forces the EGL tooling to substitute your new property, for a defined property of the same type in the Domain DefinitionExample: 1. Initial DataItem definition: 2. Variable of type: Password – over-riding DisplayName and DisplayUse, adding UpperCase= field3 3. Drag field3 (with over-ridden properties) on a web page. Note design and run-time results:  UpperCase=yes  Over-Ridden DisplayUse Over-Ridden DisplayName 

7 7  EGL Properties – Leveraging DataItems  You specify useful business semantics for a DataItem by coding one or more EGL Properties. Properties are powerful ways of expressing business rules for your DataItems. They are coded with the following name/value pair syntax: { =, =, … } { =, =, … } Considerations:  Properties exist for:  Data Parts (we are mostly interested in Data Part properties here)  Logic Parts  UI Parts (Terminal User Interface forms)  DataItems allow you to:  Consolidate like or related properties into a single new, custom “type”  Create unique “one-off” types for fields in your application Let’s have a look at properties within the help system. Master list of all EGL properties  From the Help menu, search on: Master list of all EGL properties

8 8 EGL Properties – Two Categories Formatting and U.I. display  upperCase  upperCase / lowerCase – translates Alphabetic characters to upper case  zeroFormat  zeroFormat – display a zero (yes) or blank (no – default) on pages for values of zero  Sign  Sign – provides a negative indicator character, for numeric values less than zero being displayed  displayName  displayName – allows you to customize the label for the variable, when dragged onto a page  dateFormat – allows you to custom-format a date field’s display  fillCharacter – over-rides the default fill character (blanks) for fields  numericSeparator – adds commas to Money and numeric output fields Validation and Data Entry Validation and Data Entry (input/edit properties)  All of these Properties are used to trigger server-side generated code, that automatically applies business logic rules – consistently, to user data entry values, and automatically returns errors if the data tests false  inputRequired (yes/no) – forces users to enter non-blank data in a field upon input *** Notes  validValues […] – allows you to provide a list of values which user input is tested against*** Notes  validatorTable = DataTablename – Names an EGL DataTable that contains values which the user input must adhere to  validatorFunction = FunctionName – allows you to name a custom JSF Handler function that will be called automatically to test user input against. Use for complex data entry edit requirements  onValueChangeFunction – similar to validatorFunction, except that this function is only invoked if users actually change values on a field in a page

9 9 EGL Properties and Content Assist and Source Assistant too! What if you don’t remember the syntax for a particular EGL Property? Two options: 1. Ctrl+Shift+Z 1. By placing your cursor between the curly braces, and pressing Ctrl+Shift+Z - You invoke Source Assistant – wizard- driven method of selecting properties 2. Ctrl/Spacebar 2. Ctrl/Spacebar - You can let Content Assist bring up a list of all variable properties 

10 10 Declaring EGL Variables That Reference a DataItem Type  After a DataItem has been defined and saved you can refer to it as the “TYPE” of a variable in a Logic Part. And the EGL tooling “copies” all of the extended semantic properties of the DataItem definition to your variable declaration when you generate.  This allows you to declare variables of ; - using Content Assist (in an EGL Logic Part) //VariableName DataItem (new variable type) pWord Password; ordAmt OrderAmount;  Note that the DataItem definition (in the above example, Password and OrderAmount) must be available within the Namespace – meaning you may need an import statement for the folder that contains the EGL source file with the DataItem definitions you wish to use. Ex. import data.*;

11 11  Workshops for DataItem Topic – 1 of 2 Using the RBD tooling and EGL, create the EGL DataItems and their custom properties as shown here. Steps: DataDictionarydataEGLSource 1. Create a new EGL source file named: DataDictionary in the \data\ directory under \EGLSource\ 2. Into this file, Copy and paste the following DataItem definitions (below the package statement) //A DataItem AgeItem smallint {displayName="Enter Age", validValues=[[18,99]], DisplayUse = input} end //D DataItem DateOfBirthItem Date {displayName="Enter Date of Birth", dateFormat=usaDateFormat} end //H Dataitem HeightItem Decimal (3,1) {displayName="Enter Height", value=0.0} end //N DataItem NameItem string {displayName="* Enter Name",inputRequired=yes} end //P DataItem PhoneItem char(12) {displayName="* Enter Phone",inputRequired = yes} end //S DataItem SalaryItem decimal(8,2) {displayName="Enter Salary",currency=yes, validValues=[[ , ]], DisplayUse = Input} end DataItem selItem boolean {value=false, displayname="Generic Boolean"} end DataItem StateItem char(2) {validValues=["CA","CT","NJ","NY","NC"]} end //Z DataItem ZipItem char(5) {displayName="Enter Zip", validValues=[["00001","90210"]]} end 3. Modify the displayName and validValues properties. 4. Change the dateFormat from usaDateFormat to another alternative. Note – use Content Assist to help you discover and code a valid date format syntax)

12 12  Workshops for DataItem Topic – 2 of 2 newaccount 5.Return to your newaccount JSFHandler, and modify the EGL data types, as shown here  …referencing DataItems instead of Primitive types in most cases  Use Content Assist  Use Content Assist to speed your work! Ctrl/S 6.Press Ctrl/S to save

13 13  Now that you have completed this topic, you should be able to:  Define EGL DataItems  Describe several useful properties of DataItems  Use Content Assist and Source Assistant to create DataItem properties  Code variables that reference new DataItem types  Over-ride EGL properties defined in DataItems for variables declarations Topic Summary


Download ppt "® IBM Software Group © 2006 IBM Corporation EGL Programming - Data Parts and Assignment Statements - 2 - DataItems These slides walk you through the terms."

Similar presentations


Ads by Google