® IBM Software Group © 2006 IBM Corporation EGL Programming – Data Parts and Assignment Statements – 4 – Arrays These slides walk you through the terms.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

® IBM Software Group © 2006 IBM Corporation JSF dataTables – Basic Properties and Development Techniques Part I – of a 3-part section on the use of the.
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
Chapter 10.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 14 – Student Grades Application: Introducing.
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
® IBM Software Group © 2006 IBM Corporation Additional AJAX Examples and Workshops This learning module provides additional AJAX use cases and examples.
Chapter 8. 2 Objectives You should be able to describe: One-Dimensional Arrays Array Initialization Arrays as Arguments Two-Dimensional Arrays Common.
1 Arrays  Arrays are objects that help us organize large amounts of information  Chapter 8 focuses on: array declaration and use passing arrays and array.
Aalborg Media Lab 28-Jun-15 Software Design Lecture 8 “Arrays”
C++ for Engineers and Scientists Third Edition
® IBM Software Group © 2006 IBM Corporation EGL / SOA – Creating and Consuming EGL Web Services This Learning Module shows how to utilize the RBD tooling.
® IBM Software Group © 2006 IBM Corporation JSF dataTables – Advanced use of Properties and Development Techniques Part III – of a 3-part section on the.
® IBM Software Group © 2006 IBM Corporation The Eclipse Data Perspective and Database Explorer This section describes how to use the Eclipse Data Perspective,
® IBM Software Group © 2006 IBM Corporation JSF Menu Component How to create and use JSF Menu components to add custom static and programmatic (dynamic)
® IBM Software Group © 2006 IBM Corporation EGL/Web Project QuickStart – 3 of 4 – Creating the U.I. Layer These slides walk you through the process of.
® IBM Software Group © 2006 IBM Corporation How to read/write XML using EGL This Learning Module shows how to utilize an EGL Library to read/write an XML.
® IBM Software Group © 2006 IBM Corporation JSF Tab Controls This Learning Module shows how to develop server-side EGL applications with dynamic content.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
11 Chapter 8 ARRAYS Continued. 22 MULTI-DIMENSIONAL ARRAYS A one-dimensional array is useful for storing/processing a list of values. For example: –The.
® IBM Software Group © 2006 IBM Corporation Display contents of a Data Table in Excel right from the browser – No POI needed This section describes how.
® IBM Software Group © 2006 IBM Corporation Creating JSF/EGL Template Pages This section describes how to create.JTPL (Java Template Pages) using the Page.
® IBM Software Group © 2006 IBM Corporation JavaScript – and EGL and.JSP Pages This learning module describes the use of JavaScript in your EGL and.JSP.
Chapter 4 Handling User Input PHP Programming with MySQL 2nd Edition
Chapter 5 Java Script And Forms JavaScript, Third Edition.
® IBM Software Group © 2006 IBM Corporation JSF Tree Control This Learning Module describes the use of the JSF Tree Control – for hierarchical organization.
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
Microsoft Visual Basic 2005 CHAPTER 5 Mobile Applications Using Decision Structures.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 11 - JavaScript: Arrays Outline 11.1 Introduction 11.2 Arrays 11.3 Declaring and Allocating Arrays.
Creating a Web Site to Gather Data and Conduct Research.
 2006 Pearson Education, Inc. All rights reserved Arrays.
® IBM Software Group © 2006 IBM Corporation Programmatically Rendering and Hiding JSF Controls This section describes how to hide and show JSF controls.
A First Book of ANSI C Fourth Edition
® IBM Software Group © 2006 IBM Corporation JSF/EGL Component Properties Deep Dive This section walks you through the options and settings for JSF Component.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
® IBM Software Group © 2006 IBM Corporation “Essential” HTML Tags and Page Development Techniques This Learning Module describes the standard HTML tags.
® IBM Software Group © 2006 IBM Corporation.JSP Page Flow – and Managing State in your Web Application This learning module covers the salient features.
® IBM Software Group © 2006 IBM Corporation EGL/Web Project QuickStart – 2 of 4 – Creating the Business Logic Layer These slides walk you through the process.
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
® IBM Software Group © 2006 IBM Corporation Individual Cell Coloring – in a JSF dataTable Control You may need to programmatically (using EGL) change the.
® IBM Software Group © 2006 IBM Corporation Using JSF Mini-Calendar Controls This section describes how to use a JSF Mini-Calendar Control with EGL It.
® IBM Software Group © 2006 IBM Corporation JSF File Upload Control This Learning Module describes the use of the JSF File Upload component – for allowing.
® IBM Software Group © 2006 IBM Corporation Web JSF Overview – RBD Tooling – for Web Development This unit introduces you to the aspects of the RBD tooling.
® IBM Software Group © 2006 IBM Corporation “Essential” JSF Components and EGL Bindings This Learning Module describes the foundation terms and concepts.
CSCI 6962: Server-side Design and Programming JSF DataTables and Shopping Carts.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: One-Dimensional Arrays Array Initialization Arrays.
® IBM Software Group © 2006 IBM Corporation Finding Out Which Submit Button Was Clicked – and Other JSF Command Button Techniques This section describes.
® IBM Software Group © 2006 IBM Corporation EGL/Web Project QuickStart – 1 of 4 – Creating the Data Access Layer These slides walk you through the process.
® IBM Software Group © 2006 IBM Corporation JSF Panel – Section Controls This Learning Module shows how to develop server-side EGL applications with dynamic.
® IBM Software Group © 2006 IBM Corporation JSF Rich Text Area Component This Learning Module describes the use of the JSF Rich Text Area component – for.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
® IBM Software Group © 2006 IBM Corporation Dependent Combo-Box U.I. Development This Learning Module walks you through the options and development techniques.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
1 Section 10 - Embedded SQL u Many computer languages allow you to embed SQL statements within the code (e.g. COBOL, PowerBuilder, C++, PL/SQL, etc.) u.
® IBM Software Group © 2006 IBM Corporation EGL.CSV (Excel) File Reading and Writing This section describes how to access.CSV (Excel Spreadsheet) files.
LESSON 8: INTRODUCTION TO ARRAYS. Lesson 8: Introduction To Arrays Objectives: Write programs that handle collections of similar items. Declare array.
A FIRST BOOK OF C++ CHAPTER 7 ARRAYS. OBJECTIVES In this chapter, you will learn about: One-Dimensional Arrays Array Initialization Arrays as Arguments.
® IBM Software Group © 2006 IBM Corporation Create EGL/JSF HelloWorld Pages This learning module walks you through the process of creating two simple “hello.
Creating Oracle Business Intelligence Interactive Dashboards
System I (AS400) Login You will need to develop Login procedures for your web applications. This short section describes how to do this for System I.
Arrays, For loop While loop Do while loop
System I (AS400) Login You will need to develop Login procedures for your web applications. This short section describes how to do this for System I.
Arrays.
Presentation transcript:

® IBM Software Group © 2006 IBM Corporation EGL Programming – Data Parts and Assignment Statements – 4 – Arrays These slides walk you through the terms and concepts around declaring EGL Arrays to organize repeating records and primitives. It also covers the EGL built-in Array handling functions and manipulating array information.

2 EGL Arrays  Like many other programming languages, EGL can group variables of the same type into arrays. EGL supports the following kinds of arrays: 1.Array Literals – fixed in size 2.Dynamic arrays 3.Structure field arrays – aka “record arrays”  General info on arrays:  Are one(1)-based in subscripts  Are one(1)-based in subscripts - (like COBOL and RPG) - not zero-based > 0 and 0 and < the current array limit  Can have multiple dimensions – up to seven levels  Size is initialized with an integer value within brackets next to its type Products productRec[6]; //A dynamic array – with six records initialized  Note that you can only refer to an array element that has been initialized  Products[0].Name = “Smith”  run-time error. Products[7].name = “Smith”  run-time error.  Can be of any Primitive Data type or a defined Record type Customers Customer[0];//A dynamic array with no records smallStrArray string[4]; //an array of 4 strings orderArrayOrders[8]; //An array of 8 order records

3 Array Literals  An array literal consists of a pair of brackets that contains a comma separated list of literals (including other array literals) or expressions (including array variables).  Each array literal has a type, and can be used anywhere an array of the given type is allowed—for instance, as an initializer for an array variable. Here are some examples: myInts int[5] = [1,2,3,4,5]; //initialize when you declare! validStates char(2)[6] = ["NY","NJ","NC","DE","MD","WA"]; premiumMax decimal(9,2)[4] = [ , , , ];  Refer to an array element using an integer value or integer variable subscript between square brackets Result int = myInts[3] + myInts[4]; i int = 3; Result int = myInts[i] + myInts[i+1]; tempMax int = premiumMax[i];

4 Dynamic Arrays  The syntax for declaring a dynamic array is shown in the following examples: // An array of 6 elements or less, with 4 elements initially maxSize=6 myDataItemArray myDataItem[4] { maxSize=6 }; // An array of customer records, with no elements initially – that can hold up to 100 records CustomerArray Customer[0] {maxSize=100}; // An array of customerOrders records – which is a record type containing an embedded array of Orders records custOrdArray CustomerOrders[0]; //No initialized elements record CustomerOrders type basicRecord CustomerId CustomerId; FirstName FirstName; LastName LastName; OrdersOrders[0]; //Array of Orders records as a field in CustomerOrders end

5 Manipulating Dynamic Arrays - EGL Array Functions To add rows to a Dynamic Array use the appendElement() array function arrayVar.appendElement( ); … where the appended data value is a variable of the same type as the array.  Primitive  Record type  So – to explicitly add new rows to a dynamic array: 1.Declare a single instance variable for the array data 2.Declare an array variable (of the data type – that matches the single instance variable) 3.Assign values to the fields in the single instance variable 4.Issue an appendElement(dataOfSameType); statement.

6 Manipulating Dynamic Arrays - Other EGL Array Functions  Size ( )  yields an integer with the number of rows in the array: sz int = size(custArray);  ArrayVariableName. insertElement(, idx);  inserts to specific row location in the array – existing rows bumped up by one custArray.InsertElement(customerRec, 2);  ArrayVariableName. removeAll();  zeros (empties) array of all rows in the array: custArray.removeAll();  ArrayVariableName. removeElement(idx);  removes a specific row from the array: custArray.removeElement(4);  Use Content Assist to code construct your statements 

7 EGL Structure Fields with Arrays – Examples and Declaration – 1 of 2  You can embed an array of fields into a structure Record. Reference the array portion as: recName.groupFieldName[n]. … custRec custRecord; //Variable Declaration – single structure record, of type: custRecord i int; //integer subscript for referencing array element … Function main() i = 3; custRec.CustInfo.Address[i].City = "Nyack"; //Variable.groupVar.arrayVar[idx].field = value … record custRecord type basicRecord 01 CustInfo; 10 name; 20 firstName CHAR(20); 20 midInit CHAR(20); 20 lastName CHAR(20); 10 Address[3];//Embedded array of (3) addresses within CustInfo 20 StreetChar(20); 20 CityChar(20); 20 StateChar(2); 20 ZipChar(5); 10 PhoneChar(14); end ***See slide Notes for additional details

8 … myClassStudentYTD; //Record variable of type Student … Function main() myClass.class.names[3].student = "Smith"; //Assign 3 rd student name: Smith myClass.class.names[3].grades.grade[1] = 95.0; //Assign 1 st test score to Smith … End //end logic-part record StudentYTD type basicRecord 01 class; 10 classtitlechar(20); 10 Instructorchar(20); 10 names[8];//Array of eight students 20 student CHAR(10); 20 grades GradeRec; //Grades – variable of type: GradeRec End //end-record record GradeRec type basicRecord 01 grade Decimal(4,2) [20] ;//20 occurrence array of grades End //end-record  You can also have embedded arrays (see below). For structured arrays the subscript is still at the end. The first value references the outer array, the second value the inner array.  Example: Declare a record for student information. For a class of eight students, maintain an array of 20 grades for each student. EGL Structure Fields with Arrays – Examples and Declaration – 2 of 2 ***See slide Notes for additional details

9  Workshop EGL Arrays and Array Functions – 1 of 4 Using the EGL Editor: newaccount.egl  Edit newaccount.egl  Add  The accounts array variable  An integer variable  The six functions shown here  Note: Use Content Assist to help you create the Array Function statements  Press Ctrl/S and clean up all syntax errors Note that //comments are optional

10  Workshop EGL Arrays and Array Functions – 2 of 4 From Page Designer – Edit newaccount.jsp 1. Select and delete the existing Submit Button 2. From Page Data – select all of the JSF Handler functions. 3. Drag and Drop them onto the page – where they will create seven new submit buttons 4. Again from Page Data – select the selRow – int field, and drag and drop it onto the page, below your new buttons  From Configure Data Controls, specify this field as:  Updating an existing row

11  Workshop EGL Arrays and Array Functions – 3 of 4 From Page Designer:  From Page Data: accounts – accountRec[]  Select accounts – accountRec[]  Drag and Drop it onto the page below SelRow From Configure Data Controls, Create this control for:  Displaying an existing record (read-only)

12  Workshop EGL Arrays and Array Functions – 4 of 4 From Page Designer:  Run the page  Enter valid data, and press addAccount  Create several rows in the array  Utilize the remaining functions to:  Delete a specific row  Insert a new row at a specific location in the array  Select (retrieve) a row from the array into the detail account fields  Update a specific row in the array  Clear the array  Etc.

13  OPTIONAL Workshop EGL DataTypes and Records – 1 of 3 If time permits, create a.JSP page and JSFHandler that use most of the common EGL variable datatypes and records found in business applications (standalone variables, single record, record array). eglDataTypePage.jsp  Start by creating a new web page named: eglDataTypePage.jsp

14  OPTIONAL Workshop EGL DataTypes and Records – 2 of 3 Edit the EGL Code for the page – and add the following: - Do the steps in order - Do the steps in order - Use Content Assist - Use Content Assist 2. Declare variables 3. Code the Function Assignment statements – use mouse-based copy/paste freely 1. Declare a Record Note the different EGL data types 4. Press Ctrl/S *** See slide Notes to get copy/paste code for this OPTIONAL workshop

15  OPTIONAL Workshop EGL DataTypes and Records – 3 of 3 From Page Designer/Page Data 1.Drag intVar onto the page. Create an  Input control 2.Drag the newRecord  function onto the page 3.Drag dtRec onto the page. Create Output controls  4.Drag dtRecArray onto  the page. Create Output controls 5.Run the page on the server – and verify the behavior of the function and the datatypes.

16  OPTIONAL WORKSHOP - Nested Arrays – 1 of 3  As shown in this section, you can embed a dynamic array, as a variable inside of another dynamic array record – down as many levels as seven - for your business logic requirements. This can be very useful, in presenting related/“normalized” table information – as this example shows:  From Project Explorer, create a new Web Page  Right-click over \WebContent\ - select; New > Web Page treePage.jsp  Name the page: treePage.jsp - and select a template.  Change the header text (as shown)   (Right-click, and) Edit the page code   Replace the existing JSFHandler, with Copy/Paste the code from this slide’s Notes   Check out the embedded (nested) Dynamic Arrays …which are defined at the bottom of the code Press Ctrl/S  Press Ctrl/S to save generate

17  OPTIONAL WORKSHOP - Nested Arrays – 2 of 3  From Page Designer – from Page Data, Select myCompany and drag/drop it onto the Content Area. For each embedded array inside the myCompany variable, you will seen a Multi-Column Data ellipsis, allowing you to customize the control type, for each embedded (nested) array to be displayed through this JSF dataTable. not  Note that in this example, we’ve added several columns to categorize the table rows (you did this on allorders2.jsp, remember?) It’s not necessary to do so for this example.

18  OPTIONAL WORKSHOP - Nested Arrays – 3 of 3  Run the page on the Server. Note the embedded (nested array) information, displayed hierarchically in the dataTable  Note again, that we are using alternate row colors, dataTable borders, and row categorization to obtain this functionality and rendering.

19  Now that you have completed this topic, you should be able to:  Define the different types of EGL Arrays  Declare array variables  Assign values to reference-able array elements  Use the Array built-in-functions to:  Add array elements  Delete array elements  Clear an array  Insert an array element at a particular array row Topic Summary