Rocket U2 Web Development January 2014 WDE-511-RPN...

37
Rocket U2 Web Development Environment Developing Applications with RedPages.NET Version 5.1.1 January 2014 WDE-511-RPN-DG-01

Transcript of Rocket U2 Web Development January 2014 WDE-511-RPN...

Page 1: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Rocket U2 Web DevelopmentEnvironment

Developing Applications with RedPages.NET

Version 5.1.1

January 2014WDE-511-RPN-DG-01

Page 2: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

2

NoticesEdition

Publication date: January 2014Book number: WDE-511-RPN-DG-01Product version: Version 5.1.1

Copyright© Rocket Software, Inc. or its affiliates 1996-2014. All Rights Reserved.

Trademarks

Rocket is a registered trademark of Rocket Software, Inc. For a list of Rocket registered trademarks goto: www.rocketsoftware.com/about/legal . All other products or services mentioned in this documentmay be covered by the trademarks, service marks, or product names of their respective owners.

Examples

This information might contain examples of data and reports. The examples include the names ofindividuals, companies, brands, and products. All of these names are fictitious and any similarity tothe names and addresses used by an actual business enterprise is entirely coincidental.

License agreement

This software and the associated documentation are proprietary and confidential to Rocket Software,Inc. or its affiliates, are furnished under license, and may be used and copied only in accordance withthe terms of such license.

Note: This product may contain encryption technology. Many countries prohibit or restrict theuse, import, or export of encryption technologies, and current use, import, and export regulationsshould be followed when exporting this product.

Contact information

Website: www.rocketsoftware.com

Rocket Software, Global Headquarters77 4th AvenueWaltham, MA 02451–1468USATel: +1 781 577 4321Fax: +1 617 630 7100

Page 3: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

3

Contacting Global Technical SupportIf you have current support and maintenance agreements with Rocket Software, you can access theRocket Customer Portal and report a problem, download an update, or find answers to in the U2Knowledgebase. The Rocket Customer Portal is the primary method of obtaining support.

To log in to the Rocket Customer Portal or obtain a Rocket Customer Portal account, go towww.rocketsoftware.com/support

Alternatively, you can contact Global Technical Support by email or telephone:

Email: [email protected]:

North America +1 800 729 3553United Kingdom/France +44 (0) 800 773 771 or +44 (0) 20 8867 3691Europe/Africa +44 (0) 20 8867 3692Australia +1 800 707 703 or +61 (0) 29412 5450New Zealand +0800 505 515

Page 4: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

4

Contents

Notices................................................................................................................................................................................... 2

Contacting Global Technical Support................................................................................................................................. 3

Chapter 1: Rocket U2 Web Development Environment overview..................................................................................... 5Introduction...............................................................................................................................................................5

Chapter 2: Using RedPages.NET..........................................................................................................................................6RedPages.NET and RBOs overview......................................................................................................................... 6

RedPages.NET API........................................................................................................................................ 6RedPages.NET data source controls............................................................................................... 6

Chapter 3: RedPages.NET API..............................................................................................................................................8RedObject class.........................................................................................................................................................8RecordSet class.......................................................................................................................................................10RedSet class............................................................................................................................................................ 12RedField class......................................................................................................................................................... 13RbException class................................................................................................................................................... 15

Chapter 4: Using RedPages.NET to access RBOs from C#............................................................................................... 17Creating and using a RedObject............................................................................................................................17Creating and using a RecordSet object................................................................................................................ 18Creating and using a RedSet object......................................................................................................................19Creating and using a RedField object................................................................................................................... 21Error and alert handling.........................................................................................................................................23Example: Session IDs..............................................................................................................................................23Example: RBO handles........................................................................................................................................... 24

Chapter 5: Creating a RedPages.NET application............................................................................................................ 26Opening a new project in Visual Studio................................................................................................................26Setting the page properties................................................................................................................................... 27Building the application.........................................................................................................................................27Linking the controls................................................................................................................................................30Binding multivalued properties to a list type control..........................................................................................31

Appendix A: Configuration files......................................................................................................................................... 33rgw5.ini file..............................................................................................................................................................33

Sections of rgw5.ini file..............................................................................................................................34[LogLevel] section...........................................................................................................................34[Default] section..............................................................................................................................35[accountname] section...................................................................................................................35

Page 5: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

5

Chapter 1: Rocket U2 Web DevelopmentEnvironment overview

Rocket U2 Web Development Environment (Web DE) is an application development toolkit for buildinginteractive client/server applications for deployment on the World Wide Web or on a corporateintranet.

IntroductionThis manual covers accessing RedBack objects (RBOs) from .NET. It describes the core RedPages.NETAPI, and introduces RBO Data Sources for ASP.NET.

The content in this manual provides an overview of RedPages.NET; it does not include installationinformation. For information on how to install RedPages.NET, see Getting Started.

Page 6: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

6

Chapter 2: Using RedPages.NET

RedPages.NET is a collection of .NET classes that are Web DE-aware, and can communicate withRBOs on the RedBack Object Server. This chapter provides examples of how to access RBOs from C#.rgw5.ini file, on page 33 also provides some examples.

This documentation assumes that you know both C# and the .NET Framework.

RedPages.NET and RBOs overviewThe RedPages.NET API is a collection of .NET classes that provide access to the RBOs that reside in aUniData or UniVerse (U2) database. This allows access for easy building of .NET applications againsta U2 database. You can use any .NET authoring tool, such as Microsoft Visual Studio, to design theapplications for your web pages, ASP.NET

Web DE allows you to design your business rules and logic by using RBOs. RBOs are objectrepresentations of U2 data and business logic. For more information about RBOs, see Developing RBOswith U2 Web Designer.

RedPages.NET API

The RedPages.NET API functionality is provided by the RedPages.NET assembly, which provides theclasses required to connect and interact with RBOs on the RedBack Object Server.

In development mode, RedPages.NET should be installed in the same location that your .NETdevelopment environment or editor is installed.

For run time, you must install the RedPagesNET.dll where the required environment can access it.

RedPages.NET data source controls

In addition to the core RedPages.NET API, Web DE also includes a set of .NET data source controls thatallow RBOs to participate in ASP.NET data binding.

The RedPages.NET data source controls are designed to easily bind data to the controls. Developmenttools such as Visual Studio have extensive tooling built around the concept of data binding, and oftenno code is required to link data sources to their corresponding Web controls.

The following data source controls are available:

▪ RBODataSource▪ UQueryDataSource

The RBODataSource control provides single-record semantics for your application, and allows thedata to be viewed one record at a time. This control is useful in situations where only one record perpage needs to be manipulated, such as on an ASP.NET form.

The UQueryDataSource control provides record-set semantics for your application. This control isuseful in situations where sets of records are bound to list-type and table-type controls, such as theASP.NET ListView control.

Drag-and-drop operations and wizards help you bind the data sources to the controls on the page.When you drag a control onto the Visual Studio form, it is bound to the data source and all therequired ASPX code is generated automatically. You can add the RBO connection details by using thewizards that are connected to the controls.

Page 7: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

RedPages.NET data source controls

7

You can also use the wizards to designate the appropriate RBO Create, Read, Update, and Delete(CRUD) operations, instead of having to add these to the code manually. For example, the CRUDoperations for a uObject-based RBO might be WriteData, ReadData, WriteData, and DeleteData,respectively.

If you want to create programs that go beyond the capabilities supplied by the wizards, you canprogram against the events supplied by the ASP.NET infrastructure. This allows you to tie in thevarious phases of data binding, giving you full flexibility within your applications.

For an example of how to bind the data source to the controls, see Creating a RedPages.NETapplication, on page 26.

Page 8: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

8

Chapter 3: RedPages.NET APIThe RedPages.NET API is a library of the object classes, interfaces, and value types contained withinthe RedPages.NET assembly. These are the classes that you can use within the application code toaccess U2 systems from within their .NET application. The classes are driven by a series of methodsthat instruct the application on how to access and manipulate the Web DE data.

The following classes can be used in a RedPages.NET application:

▪ RedObject class, on page 8▪ RecordSet class, on page 10▪ RedSet class, on page 12▪ RedField class, on page 13▪ RbException class, on page 15

RedObject classThe RedObject class represents an RBO class instance on the client. It calls RedBack Object Servermethods on behalf of its client and can store all state for that RBO class instance.

The constructors, methods, and properties of the RedObject class are described in the followingtables.

Table 1: RedObject constructors

Constructor Description

public RedObject() Creates a RedObject instance without referencing a connection oran RBO.Creates a RedObject instance and associates a connection and anRBO with the instance.

publicRedObject(stringRBOAccount, stringRBOClass)

Parameters: RBOAccount is the RBO account to which youwant to connect. RBOClass is the RBO to associate with thisRedObject instance (in the form of “module:RBO” where module isthe module that contains the RBO).

Table 2: RedObject methods

Method Description

Opens an RBO instance.public void open()

RbException: An RbException is thrown if open() cannot takeplace, indicating a connection error, RedPages.NET error, or servererror.Opens an RBO instance.public

RedObject(stringRBOAccount, stringRBOClass)public voidopen(string account)

Parameters: account is the account to which you want toconnect.

RbException: An RbException is thrown if open() cannot takeplace, indicating a connection error, RedPages.NET error, or servererror.

Page 9: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

RedObject class

9

Method Description

Opens an RBO instance.public voidopen(string account) Parameters: account is the account to which you want to

connect.

RbException: An RbException is thrown if open() cannot takeplace, indicating a connection error, RedPages.NET error, or servererror.Sets the current value for a property.public void

setProperty(stringpropertyName, stringvalue)

Parameters: propertyName defines a property in the RBO.value is the current value of the property.

An alternative NLS method that sets the current value for aproperty name.

public voidsetProperty(stringpropertyName,UniDynArray value)

Parameters: propertyName defines a property in the RBO.value is the current value of the property.Gets the current value for a property.public string

getProperty(stringpropertyName)

Parameters: propertyName is the name of the property whosevalue should be returned.

Return value: Returns the current value. Null if property name isnot found.An alternative NLS method that gets the current value for aproperty name. This is the value as set by the last server call,not the value that may be held in a RedBean associated with thespecified propertyName.

public UniDynArraygetPropertyToDynArray(stringpropertyName)

Parameters: propertyName is the name of the property whosevalue should be returned.

Return value: Returns the current value. Null if property name isnot found.Calls the specified method for the RBO. The method call takesplace on the RedBack Object Server.

public RecordSetcallMethod(stringmethodName) Parameters: methodName is the name of the RBO method to

invoke.

Return value: The return value is a RecordSet object if themethod is the Select method or the PageDisp method on a uQuery.Otherwise, the return value is null.Refreshes the RedObject instance with RedBack Object Serverstate for the required session as determined by the handle passed.The session details are passed in to identify the specific session.

If the current session details are the same as the ones passedin, the object returns the current property values. If the sessiondetails are different, a request is made to the RedBack ObjectServer to get the requested information.

public ArrayListrefresh(string handle)

Parameters: handle is the handle obtained by using thegetRBOHandle() method.

Return value: Returns the current property values after refresh.public ArrayListrefresh(UniDynArrayhandle)

An alternative NLS method that refreshes this instance withRedBack Object Server state for the required session asdetermined by the handle passed.

Page 10: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 3: RedPages.NET API

10

Method Description

Parameters: handle is the RBO handle for the RBO instance.

Return value: Returns the current property values after refresh.Sets the RBOHandle on the RedObject. This handle is generatedby the RedBack Object Server and can be used later to refresh aRedObject with data from the RedBack Object Server.

public voidsetRBOHandle(stringRBOHandle)

Parameters: RBOhandle is the current handle, as returned by aprevious call to getRBOHandle().Gets the RBOHandle on the RedObject. This handle is generatedby the RedBack Object Server and can be used later to refresh aRedObject with data from the RedBack Object Server.

public stringgetRBOHandle()

Return value: Returns current RBOHandle details for the currentRBO. This handle is generated by the RedBack Object Serverand can be used later to refresh a RedObject with data from theRedBack Object Server.Gets the SessionId for the current RBO. This session ID isgenerated by the RedBack Object Server and can be used later tocreate other RBOs as part of the same session.

public stringgetSessionId()

Return value: The return value is the session ID for the currentRBO.Sets the SessionId for the current RBO.public void

setSessionId(stringsessionId)

Parameters: sessionId is the current session ID, as returned bya previous call to getSessionId().

public UniDynArraySessionId

An alternative NLS property.

Table 3: RedObject properties

Property Description

Gets the current RBOHandle details for the current RBO. Thishandle is generated by the RedBack Object Server and can be usedlater to refresh a RedObject with data from the RedBack ObjectServer and to also associate other RedObjects with the currentsession.

public UniDynArrayRBOHandle

Parameters: RBOHandle is the current handle, as returned by aprevious call to getRBOHandle().

Return value: Returns current RBOHandle details for the currentRBO. This handle is generated by the RedBack Object Server.

public stringServerAlert

Holds any alert messages from the server. This value is set aftereach callMethod.

RecordSet classThe RecordSet class represents the set of rows returned from a uQuery object. It provides methods toiterate through the rows returned by the uQuery.

The methods and properties of the RecordSet class are described in the following tables.

Page 11: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

RecordSet class

11

Table 4: RecordSet methods

Method Description

Gets the field value for the current row.public stringgetProperty(stringpropertyName)

Parameters: propertyName is the field name to return for thecurrent row.

Return value: Returns the value for the field name for the currentrow.Moves the row number (cursor) to a specified position. If movedpast the last row, it will set EOF to true. If moved before row 1, itwill set BOF to true. If another page is required, it requests thatpage. If the row requested is greater than the amount of rows, thepage number is set to the last page plus one and the row numberis set to the last row plus one.

public void move(intpos)

Parameters: pos is the row number position.public voidmoveFirst()

Moves the current row position to 1.

public voidmovePrevious()

Moves the row number (cursor) back 1. If past the initial row, itsets BOF to true. If another page is required, it requests that pageto return true.

public void moveNext() Moves the row number (cursor) forward 1 position. If it movesbeyond the last position, it will set EOF to true.

public void moveLast() Moves the current row position to the last row.Moves the RecordSet to the previous page.public bool

movePrevPage() Return value: Returns true if successful, or false if already on thefirst page.Moves the RecordSet to the next page.public bool

moveNextPage() Return value: Returns true if successful, or false if already on thelast page and there are no more pages to view.Refreshes the state from RedBack Object Server and sets data topage one. You can then use the move(int pos) method to setthe row number as required.

public voidrefresh(stringobjHandle)

Parameters: objHandle is the handle of the RBO instance fromwhich to refresh values.

Table 5: RecordSet properties

Property Description

public intAbsolutePage

Gets a specific page and also sets row number and relative rownumber.

public intAbsolutePosition

Gets the current row position.

public bool BOF Returns boolean value depending on the beginning of the recordset. Returns true if returned at beginning of record set (before row1); otherwise, it returns false.

public bool EOF Returns a boolean value depending on the end of the record set.Returns true, if at end of record set (after last row); otherwise, thereturn value is false.

public int MaxPages Returns the maximum number of pages for this uQuery.

Page 12: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 3: RedPages.NET API

12

Property Description

public int NumItem Gets the count of number of items selected.public int PageSize Gets the number of items per page.public intRelativePosition

Gets the current row position relative to the current page.

public string Row Gets the data for the selected row.public UniDynArrayRowToDynArray

An alternative NLS property that gets the UniDynArray for theselected row.

RedSet classThe RedSet class is used to create a storage object to save state in the .NET tier. It does notcommunicate to the RedBack Object Server. It is passed an initial list of fields and from then on canadd or set values for these fields

The methods and properties of the RedSet class are described in the following tables.

Table 6: RedSet methods

Method Description

public void addNew() Adds a new row to the RedSet class without setting any values.Positions the row number so that it is ready for setPropertycalls.Adds values passed to corresponding field names. The field namesmust be one of the field names passed in the open method call.

public voidaddNew(string[]fieldList, string[]values)

Parameters: fieldList is the name of the field to update withpassed value. values is the value to update.

public void close() Closes the storage arrays and sets all values to null.public void delete() Deletes the current row.

Returns the current position within the field names array of thespecified field.

public intgetFieldPos(stringfield) Parameters: field is the specified field name.

Returns the value for the field name for the current row.public stringgetProperty(stringfieldName)

Parameters: fieldName is the field name to return for thecurrent row.Moves the row number (cursor) to a specified position. If past thelast row, it sets EOF to true; if before row 1, it sets BOF to true.

public void move(intpos)

Parameters: pos is the row number position.public voidmoveFirst()

Moves the row cursor to the first position in the RedSet.

public void moveLast() Moves the row cursor to the last position in the RedSet.public void moveNext() Moves the row number (cursor) forward 1. If past the last row, it

sets EOF to true.public voidmovePrevious()

Moves the row number (cursor) back 1. If past the initial row, itsets BOF to true. If another page is required, it requests that page.

Page 13: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

RedField class

13

Method Description

Initializes the data stores in RedSet. Allocates a storage array foreach field name passed.

public voidopen(string fieldList)

where Parameters: fieldList is a comma delimited array of fieldnames.Sets the field to the specified value for the current row.public void

setProperty(stringfield, string value)

Parameters: field is the field name to set.

value is the value to set it to.

Table 7: RedSet properties

Property Description

public intAbsolutePosition{ get; }

Returns the current row position.

public bool BOF{ get; }

Returns true if the row cursor is less than one; otherwise, it returnsfalse.

public bool EOF{ get; }

Returns true if the row cursor is at a position after the last row,otherwise false.

public int NumItems{ get; }

Returns the number of items in this RedSet class.

RedField classThe RedField class provides dynamic string handling. The RedField string supports value mark (VM)and subvalue mark (SVM) delimited arrays.

The methods and properties of the RedField class are described in the following tables.

Table 8: RedField methods

Method Description

Returns the number of values separated by a value mark in thisinstance of a RedField object.

public int count()

Return value: Returns an integer that represents how many timevalues separated by a value mark were found.Returns the number of values separated by a subvalue mark at theposition specified.Parameters: vm_c (an integer) is the value mark position forextraction.

public int count(intvm_c)

Return value: Returns an integer that represents how many timevalues separated by a value mark were found.Deletes a dynamic string element in the current RedField string atthe position specified.

public void del(intvm_c)

Parameters: vm_c (an integer) is the value position for deletion.Deletes a dynamic string element in the current RedField string atthe position specified.

public void del(intvm_c, int svm_c)

Parameters: vm_c (an integer) is the value position for deletion.svm_c (an integer) is the subvalue position for deletion.

Page 14: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 3: RedPages.NET API

14

Method Description

Returns the number of characters in this instance of a RedFieldobject.

public int getLength()

Return value: Returns an integer that represents the number ofcharacters.Returns the number of characters at the position specified.Parameters: vm_c (an integer) is the value mark position forextraction.

public intgetLength(int vm_c)

Return value: Returns an integer that represents the number ofcharacters.

public stringgetValue()

Gets the string representation of the RedField.

Extracts a dynamic string element from the current RedField stringat the position specified.

public stringgetValue(int vm_c, intsvm_c) Parameters: vm_c (an integer) is the value position for extraction.

svm_c (an integer) is the subvalue position for extraction.

Return value: Returns a string value.Extracts a dynamic string element from the current RedField stringat the position specified.

public stringgetValue(int vm_c)

Parameters: vm_c (an integer) is the value mark position forextraction.

Return value: Returns VM the character.Inserts a string into the current RedField string at the positionspecified.

public void ins(intvm_c, string pval)

Parameters: vm_c (an integer) is the value position for insertionthat can be set to -1 to indicate ‘insert at end,’ but only if am_c is> 0. pval (a string) is the string value that is to be inserted at thespecified position.Inserts a string into the current RedField string at the positionspecified.

public void ins(intvm_c, int svm_c,string pval) Parameters: vm_c (an integer) is the value position for insertion

that may be set to -1 to indicate ‘insert at end,’ but only if am_c >0. svm_c (an integer) is the subvalue for insertion that can be setto -1 to indicate ‘insert at end,’ but only if am_c and vm_c valuesare > 0. pval (a string) is the string value that is to be inserted atthe specified position.

public RedField() Constructs a new RedField class with no characters.Constructs a new RedField object, setting its initial value to that ofthe passed string.

public RedField(stringsval)

Parameters: sval is a string.Replaces a dynamic string element in the current RedField stringat the position specified.

public voidreplace(int vm_c,string pval) Parameters: vm_c (an integer) is the value position for deletion.

pval (a string) is the string value that replaces the string at thespecified position. If the position does not exist in the target string,this string is inserted.

Page 15: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

RbException class

15

Method Description

Replaces a dynamic string element in the current RedField stringat the position specified.

public voidreplace(int vm_c, intsvm_c, string pval) Parameters: vm_c (an integer) is the value position for

replacement. svm_c (an integer) is the subvalue for replacement.pval (a string) is the string value that replaces the string at thespecified position. If the position does not exist in the target string,this string is inserted.Assigns a new value for the attribute mark character.public void setAM(char

AM) Parameters: AM is the character to use a value mark.Assigns a new value for subvalue mark character.public void

setSVM(char SVM) Parameters: SVM is the character to use a value mark.Assigns a new value for value mark character.public void setVM(char

VM) Parameters: VM is the character to use a value mark.

Table 9: RedField properties

Property Description

public string StringValue Sets the RedField value to that of the passedstring.

public static char RM = '\u00FF'; This is a record mark character.public static char AM = '\u00FE'; This is an attribute mark character.public static char VM = '\u00FD'; This is a value mark character.public static char SVM ='\u00FC';

This is a subvalue mark character.

public static char TM = '\u00FB'; This is a text mark character.

RbException classThe RbException class represents the exception generated from RedPages.NET at various classes andmethods.

The properties and constants of the RbException class are described in the following table andsection.

Table 10: RbException properties

Property Description

public string Message The current exception message.The type of exception.public int Type

Return value: This property returns the following exception types:

▪ Connection error = 1;▪ Server error = 2;▪ RedPages.NET error = 3;

public string TypeDesc This method gets the description of the exception type.

Page 16: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 3: RedPages.NET API

16

Property Description

Return value: This property returns the following exception types:

▪ Connection error = 1;▪ Server error = 2;▪ RedPages.NET error = 3;

RbException constants

The RbException class supports the following constants:

▪ public const int CONNECTIONERROR = 1;▪ public const int SERVERERROR = 2;▪ public const int REDPAGESERROR = 3;

Page 17: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

17

Chapter 4: Using RedPages.NET to access RBOsfrom C#

The following sections provide step-by-step examples of how to access RBOs from C#.

Creating and using a RedObjectA .NET application can communicate with an RBO through the U2.WDE.RedPages.RedObject class.The RedObject class provides methods that enable you to set and get values from the properties of itsRBO, and to call RedBack Object Server methods.

The following steps provide an example of how to create and use an instance of RedObject to accessRBOs on the host computer.

1. Create an instance of RedObject, for example,

...using U2.WDE.RedPages;...RedObject currObj = new RedObject();

2. Specify the details of the U2 Web DE-enabled account, for example,currObj.RBOAccount =”accountname”;

where accountname denotes the account name used by Web DE to represent a U2 account thathas been enabled for Web DE. The accountname corresponds to an entry in the rgw5.ini filethat maps the name to an account on the backend, such as rbexamples. For more informationabout the rgw5.ini file, see rgw5.ini file, on page 33.

3. Specify an RBO class for this object. The RedObject needs to know which RBO to access, and youmust specify which module and RBO you will be accessing, for example,currObj.RBOClass(String RBOClass);

where RBOClass denotes an RBO class in the format module:rboclass, for example,

currObj.RBOClass("EXMOD:Employee");

Tip: You can combine the first three steps into one step as follows:RedObject currObj = new RedObject("rbexamples","EXMOD:Employee");

4. If the RBO is stateful, open the RBO.With a stateful RBO, this step is necessary in order to create the RBO instance within the RedBackObject Server. Opening the RBO creates initial state for the RBO, as well as session details (if anew session), for example,

currObj.open();

open() throws RbException if an error occurs in the open. The following will catch theRbException.

try {currObj.open();}catch(RbException rbe) {

Page 18: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 4: Using RedPages.NET to access RBOs from C#

18

...}

5. Get property values of the RBO, for example,String val = currObj.getProperty(String propname)

where propname denotes a property name from the current RBO, for example,

String lastName = currObj.getProperty("LastName");

6. Set property values of the RBO, for example,currObj.setProperty(String propname, String value);

where propname denotes a property name from the current RBO, for example,

currObj.setProperty("EmpId", "1014");

7. Call a method on the RBO, for example,RecordSet rs = currObj.callMethod(String methodName);

If the method is a “Select” against a uQuery object, it returns a RecordSet object. Otherwise, anull object pointer is returned.

try {currObj.callMethod("ReadData");}catch(RbException rbe){...}ortry {RecordSet rs = currObj.callMethod("Select");}catch(RbException rbe) {...}

The callMethod() throws an RbException on error when calling a method.

Creating and using a RecordSet objectIf the RBO is a uQuery or RPC call, Web DE creates a U2.WDE.RedPages.RecordSet object. TheRecordSet is used to return rows of data. A RecordSet allows code to move through the rows of datareturned from the server and get properties for the current row. Users can retrieve pages of dataand scroll through them to display in a report or lookup. For further information about RPCs, seeDeveloping RBOs with U2 Web Designer.

The following steps provide an example of how to create and use an instance of a RecordSet object.

1. Create a RedObject and set the U2 account name and class details.

Note: The account must be a Web DE-enabled UniData or UniVerse account.

For example,

using U2.WDE.RedPages...RecordSet rs = null;RedObject currObj = new RedObject("rbexamples","EmployeeList");

Page 19: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Creating and using a RedSet object

19

2. Open the RBO, for example,

try {currObj.open();}catch(RbException rbe) {...}

3. Call the Select() method on the RBO, creating a RecordSet object, for example,

try {rs = currObj.callMethod("Select");}catch(RbException rbe) {...}

4. Scroll through the RecordSet rows, extracting column data as require, for example,

/*Now that we have the first page (returned by the “Select” call) we can get and set values for that page that tell us how many items were selected and what the page size is (determined by the RBO from the class definition).*/int pageSize = rs.PageSize;string maxRows = currObj.getProperty("MaxRows");int maxPages = rs.MaxPages;/*This section of code will loop through each item on a page, printing the details to the console. The movement through each row is done with rs.MoveNext(). When a page is at the end then rs.EOF() will be set to true.rs.moveFirst(); // set the row cursor at the first rowfor (int z = 1; z <= pageSize; z++){if (rs.EOF)return;String s = "";if (rs.EOF)s = "";else{s = rs.getProperty("EMP.ID") + " " + rs.getProperty("FIRST.NAME") + " " + rs.getProperty("LAST.NAME");// do something with data;Console.Out.WriteLine(s);}rs.moveNext();}

Creating and using a RedSet objectYou can use a RedSet object to store rows of data. For example, you might need to store a shoppingcart. You can use a RedSet to store rows of data within RedPages.NET.

The following steps provide an example of how to create and use an instance of a RedSet object.

1. Create an instance of a RedSet object. This instance creates an empty shell for the new RedSetobject, for example,RedSet redSet = new RedSet();

2. Call the open() method, passing a list of property names.

Page 20: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 4: Using RedPages.NET to access RBOs from C#

20

Before you can do anything with the object, open the object and define the properties that itsupports. In calling the open() method on the RedSet object, pass a list of its properties as aparameter. Opening a RedSet object defines the fields to be supported in its internal arrays, forexample,

redSet.open(fieldlist);

where fieldlist denotes a comma-separated list of names of properties the object supports.3. Add new records to the object.

To save data in the RedSet object, you must first add a new record. You do this by calling theaddNew() method. After calling the addNew() method, the new record becomes the currentrecord, for example,

redSet.addNew();orredSet.addNew(String[] fieldNames, String[] values);

where fieldNames denotes an array of field names; each field name must exist in the initial listpassed in the open() method call. And values denotes an array of corresponding values.

4. Select the current record.This syntax moves to the first, last, next, or previous record in a specified RedSet object, andmakes that record the current record, for example,

RedSet.{MoveFirst() | MoveLast() | MoveNext() | MovePrevious()}

5. Get property values of the RedSet object, for example,variable = redSet.getProperty(String propname);

where propname denotes a field name that must exist in the initial list passed in the open()method call.

6. Set the property values of the RedSet object, for example,redSet.setProperty(String propname, String value);

where propname denotes a field name that must exist in the initial list passed in the open()method call.

7. Optional: Clear the RedSet object, for example,redSet.close();

This closes an open object and any dependent objects, making the RedSet object available forreuse.

The following example shows the RedSet code.

using U2.WDE.RedPages;//1. Create a RedSet object instance that will be used to manipulate our strings.RedSet oRedSet = new RedSet();

//2. Define "field name"oRedSet.open("firstName,lastName,dept");

//3. Assign the rows of data.String[] fields = new String[] { "firstName", "lastName","dept" };String[] values = { "Mike", "Kontorovich", "Eng" };oRedSet.addNew(fields, values);values[0] = "Jurgen";values[1] = "Joarder";values[2] = "Eng";oRedSet.addNew(fields, values);values[0] = "Simon";

Page 21: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Creating and using a RedField object

21

values[1] = "Caddick";values[2] = "Support";oRedSet.addNew(fields, values);values[0] = "Nghia";values[1] = "La";values[2] = "Eng";oRedSet.addNew(fields, values);

//4. Now scroll through the RedSet getting values.oRedSet.moveFirst();while (!oRedSet.EOF){Console.Out.WriteLine(oRedSet.getProperty("firstName"));Console.Out.WriteLine(oRedSet.getProperty("lastName"));Console.Out.WriteLine(oRedSet.getProperty("dept"));oRedSet.moveNext();}

//5. Finished, so can get rid of all data - this leaves the object available for re-useoRedSet.close();

Creating and using a RedField objectA RedField object is a nested data structure that can represent UniData or UniVerse multivalues andmulti-subvalues.

Note: CHAR(253) and CHAR(252) are the default values for a value mark and subvalue mark,respectively. You change these values by using the SetVM() and SetSVM() methods.

Access to multivalues and multi-subvalues uses a syntax similar to that found in the UniVerse BASIC orUniBasic language, using the getValue() method.

The following steps provide an example of how to create and use an instance of a RedField object.

1. Create an instance of a RedField object.The following syntax creates an empty RedField object.

RedField rf = new RedField();

2. Assign the RedField a string value.You can assign the RedField a string value in a variety of ways by using the Ins(), Replace(),and Append() methods, for example,

rf.StringValue = “dynastring”;

3. Add, delete, or replace individual elements in the string value.For example, execute the following to insert an element at Value position 2:

rf.ins(2,stringValue);

Enter the following code to delete SubValue 3 of Value 1:

rf.del(1,3);

Enter the following code to add a new SubValue to the end of Value 2:

rf.ins(2,rf.count(2) +1, “”);

Page 22: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 4: Using RedPages.NET to access RBOs from C#

22

4. After you manipulate the string by using the RedField, you can extract it again as a dynamicstring, for example,rf.getValue();

5. When you finish with any object, close or reset the object to release any resources that it might beconsuming by using the following code:rf = null;

The following example shows the RedField code.

using U2.WDE.RedPages....//1. Create a RedField object instance that will be used to manipulate our string.RedField oFld = new RedField();

//2. Create initial string - a list of names and item counts and convert the":" and "," separators into subvalue and value marks.String myString = "Colin:100,Jurgen:205,Tony:400,Mike:400";myString = RedField.swap(myString, ":", RedField.SVM.ToString());myString = RedField.swap(myString, ",", RedField.VM.ToString());

//3. Assign the string to the RedField.oFld.StringValue = myString;

//4. Display current contents.Console.Out.WriteLine("RedField contains " + oFld.getValue());

//5. Now display each multi value.Console.Out.WriteLine("<br><br>"); for (int mvpos = 1; mvpos <= oFld.count();mvpos++) { Console.Out.WriteLine("value at" + mvpos + " = " + oFld.getValue(mvpos));}

//6. Now display each multi value, subvalue1. Console.Out.WriteLine("<br><br>"); for (int mvpos = 1; mvpos <= oFld.count();mvpos++) { Console.Out.WriteLine("value at" + mvpos + ",1 = " + oFld.getValue(mvpos,1)); }

//7. Now insert Nghia at multivalue position3. oFld.ins(3, "Nghia"); oFld.ins(3, 2, "800");

//8. Now redisplay current values. Console.Out.WriteLine("RedFieldcontains " + oFld.getValue()); for (int mvpos= 1; mvpos <= oFld.count(); mvpos++) {Console.Out.WriteLine("value at " + mvpos+ " = " + oFld.getValue(mvpos)); }

//9.Delete Mike from the list. oFld.del(5); Console.Out.WriteLine("RedFieldcontains " + oFld.getValue()); //10. Nowconvert it back into the original format.myString = RedField.swap(oFld.getValue(),RedField.VM.ToString(), ","); myString = RedField.swap(oFld.getValue(),RedField.SVM.ToString(), ":"); Console.Out.WriteLine("myString= " + myString);

Page 23: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Error and alert handling

23

Error and alert handlingThe RedBack Object Server and RedPages.NET can generate errors. The RedBack Object Server canalso generate alerts.

Errors

Errors are thrown as RbException when RedObject methods open() and callMethod() are called.

try {empObj.open();}catch(RbException rbe) {//deal with error.System.out.printIn(rbe.getType() + rbe.getMessage());return;}

The types of exceptions are:

▪ RbException.CONNECTIONERROR▪ RbException.SERVERERROR▪ RbException.REDPAGESERROR

Alerts

If you want to look for alerts generated by the RedBack Object Server callMethod() method call,use:

getServerAlert();If(this.empObj.getServerAlert().length()>0)System.out.printIn(empObj.getServerAlert());

Example: Session IDsWhen you make an initial request to the RedBack Object Server, Web DE creates a session ID. Youshould pass this session ID with every subsequent request so the RedBack Object Server can associateall stateful RBO instances created for a specific session.

Each RBO created on the RedBack Object Server is given a unique RBO handle. The RedBack ObjectServer uses a unique session ID to identify each request from a client.

The program that makes the request to the RedBack Object Server ensures that the session ID ispassed as required. You can also use the RBO handle to make sure that a current state for an RBO isused rather than a new instance of that RBO.

For example, a program might need to:

1. Create an instance of an Employee RBO as the first request for a user. The RedBack Object Servercreates a session ID and state for the user and also creates state for the Employee RBO. The stateand session ID are returned to the program that made the initial request.

2. The program then makes a request to create an instance of the Department RBO, read thespecific department record for the Employee (as stored in Employee RBO), and then update thedepartment record with details of that Employee.

The session ID passed in step 1 must be associated with the RBO in step 2. Otherwise, Web DE createsa new session ID on the RedBack Object Server, because none was passed with the open() method,and any method called from the Department RBO on the RedBack Object Server will not have accessto state created for the session from the Employee RBO.

Page 24: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 4: Using RedPages.NET to access RBOs from C#

24

Always associate session IDs with all stateful RBOs that a specific user creates.

The following example does not use stateless RBOs. Stateless RBOs do not store state and do not usesession IDs.

using U2.WDE.RedPages;...String accountname = "rbexamples";String sessionID = "";RedObject empObj = new RedObject(accountname, "EXMOD:Employee");try{empObj.open();// Preserve session ID for subsequent RBOs.sessionID = empObj.getSessionId();}catch (RbException RBE){}// Now create another RBO part associate the current session ID.RedObject deptObj = new RedObject(accountname, "EXMOD:Department");deptObj.setSessionId(sessionID);// Now when the RBO is opened, the RedBack object server will// associate it with the current session id.

It is important that your program preserve the current session ID so that it can be used with all statefulRBOs. If the session is no longer available on the RedBack Object Server, for example, if it has expired,an RbException will be thrown on the open() method.

Example: RBO handlesWeb DE assigns a unique handle to each RBO that is created on the RedBack Object Server. Web DEpasses and returns the handle with every request made on that RBO using RedObject.

It is common to create an RBO in one page, or application component, and to enter data in that RBO.You might require that data later in the application processing from another page or applicationcomponent.

If the data is held in the RedObject, you must preserve the RedObject instance somewhere (dependingon your environment) so that you can retrieve it later. If the data is held on the RedBack ObjectServer in state, which it would be if you made a call to any RedBack Object Server method from theRedObject, you can preserve the RBO handle for that RBO, and then refresh its state into any RBO.

For example, you can create an instance of the Employee RBO from an ASP.NET page, set someproperties of that RBO, and then call an Employee method on the RedBack Object Server. Youcan then move to another ASP.NET page that might need to access some of the properties for theEmployee RBO. You can preserve the .NET instance of the RedObject somewhere, or you couldpreserve the RBO handle.

The following example shows how to use an RBO handle.

using U2.WDE.RedPages;...String empHandle = "";RedObject empObj2 = new RedObject(accountname, "EXMOD:Employee");try{empObj.open();empHandle = empObj2.RBOHandle;

Page 25: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Example: RBO handles

25

// Do stuffempObj.callMethod("update"); // server side method}catch (RbException rbe){}// Now before we leave this page/code, make sure empHandle is preserved in a later page/code. Need to get handle of current employee RBORedObject newObj = new RedObject();newObj.RBOAccount = accountname;try{newObj.refresh(empHandle); // where empHandle was preserved// newObj will now contain the state from the RedBack object//server for the Employee RBO.}catch (RbException rbe) { }

There are different ways to store session IDs and RBO handles (both values are strings).

Where you store these values depends on your runtime platform, application architecture, and design.Some of the places you can store them include:

▪ Cookies▪ Hidden fields on page▪ As part of a query string

If you do not store and associate a session ID with RBOs, you create new session state within theRedBack Object Server, preventing you from accessing previous RBO state information.

If you do not need to access previous RBO state, consider using stateless RBOs for at least part ofyour application. They are referenced in the same way by RedPages.NET, but do not require an opencall, and do not have a session ID. You cannot refresh a stateless RBO later because server state is notpreserved. For further information about stateless RBOs, see Developing RBOs with U2 Web Designer.

Page 26: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

26

Chapter 5: Creating a RedPages.NET applicationYou can use any .NET authoring tool to create a web application, but the examples in these sectionsare created using C# in Microsoft Visual Studio 2010.

To create a project in Microsoft Visual Studio, complete the following steps:

1. Opening a new project in Visual Studio, on page 262. Setting the page properties, on page 273. Building the application, on page 274. Linking the controls, on page 30

Opening a new project in Visual StudioUsing Visual Studio, you can open a new project to create a web application.

1. From Visual Studio, select File > New > Web Site.2. From the New Web Site window, select ASP.NET Web Site.

Figure 1: New Web Site window

3. Click Browse, and navigate to the directory where you want your project to reside. Provide anappropriate name for the project, for example, EmployeeList, and then click OK.The new project opens in the Microsoft Visual Studio window.

Page 27: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Setting the page properties

27

Figure 2: New project

Setting the page properties

1. In the Solution Explorer pane, right-click the C:\..\EmployeeList project, and select AddReference.

2. Click the Browse tab, and navigate to the Web DE installation path.3. Select all of the available DLLs, and click OK.4. In the Visual Studio toolbox, right-click an empty section and select Add Tab.5. In the dialog box, name the tab appropriately, for example, WebDE. Click OK.6. Right-click inside the WebDE toolbox tab and select Choose Items.7. In the Choose Toolbox Items window, select Browse, and navigate to the Web DE installation

path, for example, C:\U2\U2WDE511\DataSource.8. Select U2.WDE.WebControls.dll and click Open.9. Click OK to close the Choose Toolbox Items window.10. In the Visual Studio toolbox, right-click an empty section and select Show All to see the added

WebDE section.

Note: At this point, on some versions of Visual Studio, you need to run Build > Build Solutionfrom the menu to make Visual Studio aware of the DLLs. Omitting this step can result in errorsappearing on the design surface when the Data Source controls are dragged to the page.

Building the application

1. Drag a Label onto the form and set the Text Property to Employee List.

Page 28: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 5: Creating a RedPages.NET application

28

2. Drag a UQueryDataSource control onto the form and position it under the Employee List label.You can change the name of the control in the Properties pane. In this example, the default nameof UQueryDataSource1 is accepted.The UQueryDataSource Tasks menu opens. If the tasks menu does not open automatically, clickthe arrow button on the upper right corner of the control.

3. On the Tasks menu, click Set Credentials.4. Enter your user name and password, and click OK.5. Select the following connection details for the control:

▪ Account: rbexamples▪ Module: EXMOD▪ RBO: EmployeeList

Figure 3: Connection details

Click the arrow on the upper right side of the control to minimize the Tasks menu.6. Drag a GridView control onto the form, and position it below the UQueryDataSource control.

The GridView Tasks menu opens.

Figure 4: GridView Tasks

7. On the Tasks menu, click Set Credentials.8. Enter your user name and password, and click OK.9. From the Choose Data Source options, select UQueryDataSource1, and from the GridView Tasks

menu, select the Enable Selection check box.

Page 29: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Building the application

29

10. From the GridView Tasks menu, select Edit Columns and change how the information isdisplayed:

Figure 5: Fields dialog box

a. From the Selected Fields list, select an item.b. In the BoundField properties section, edit the properties as follows:

▪ Set the HeaderText for the EMP.ID field to Employee ID.▪ Set the HeaderText for the FIRST.NAME field to First Name.▪ Set the HeaderText for the LAST.NAME field to Last Name.▪ Set the HeaderText for the DEPT field to Dept.

c. When finished, click OK.11. Drag a Label onto the form, and set the Text Property to Employee Information.12. Drag an RBODataSource control onto the form. Position the control below the Employee

Information label.

The RBODataSource Tasks menu opens. If the tasks menu does not open automatically, click thearrow button on the upper right corner of the control.

Select the following connection details for the control:

▪ Account: rbexamples▪ Module: EXMOD▪ RBO: Employee▪ ReadMethod: ReadData▪ UpdateMethod: WriteData▪ InsertMethod: WriteData▪ DeleteMethod: DeleteData

Page 30: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 5: Creating a RedPages.NET application

30

Figure 6: RBODataSource Tasks menu

Click the arrow on the upper right side of the control to minimize the Tasks menu.13. Drag a Data DetailsView control onto the form, and position it below the RBODataSource

control.14. On the DetailsView Tasks menu, from the Choose Data Source options, select RBODataSource1.15. From the DetailsView Tasks menu, select Edit Columns and change how the information is

displayed:

a. From the Selected Fields list, select an item.b. In the BoundField properties section, edit the properties.c. Delete unnecessary fields by highlighting the item in the Selected Fields list, and then

clicking “X.” The fields used in this example are Select, EmpId, FirstName, LastName,Salary, Dept, and Interests.

d. Change the HeaderText property for the selected fields as follows:

▪ Set the HeaderText for the EMP.ID field to Employee ID.▪ Set the HeaderText for the FIRST.NAME field to First Name.▪ Set the HeaderText for the LAST.NAME field to Last Name.

e. When finished, click OK.

Linking the controls

1. In the GridView properties pane, select DataKeyNames and then click the ellipsis (...) button.2. From the Data Fields Collection Editor dialog box, select EMP.ID from the available data fields list,

and click the rightarrow (>) to move it to the selected data fields list.Visual Studio pulls information from this field when you select an employee name from the list.Click OK.

3. In the RBODataSource control property pane, select Select Parameters from the propertywindow and then click the ellipsis (...) button.

4. From the Parameter Collection Editor window, click Add Parameter. In the text box that appearsin the Parameters section, type EmpId. EmpId is the key field property of the Employee RBO.

5. From the Parameter source menu, select Control.6. From the ControlID, select GridView1. The row selected from the Employee List grid will now

drive the Employee Details control. Click OK.7. Run the application by selecting Debug > Start Without Debugging.

Page 31: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Binding multivalued properties to a list type control

31

An Explorer browser opens. Your application should look similar to the following example:

Figure 7: ASP.NET application example

Binding multivalued properties to a list type controlProperties with multivalues can be bound to list type controls. Multivalued properties can be boundindividually or together with other associated properties. The following steps bind the multivalue-delimited Interests property to a Repeater control.

1. Select the DetailsView control that you added to the form earlier. Click the arrow on the upperright corner of the control to open the DetailsView Task menu, and then select Edit Fields.

2. On the Field dialog box, from the Selected fields section, select Interests. Click Convert this fieldinto a TemplateField, and then click OK.

3. Open the DetailsView Task menu, and select Edit Templates.The DetailsView menu opens in Template Editing Mode, as shown in the following figure.

Figure 8: Template Editing Mode

Page 32: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Chapter 5: Creating a RedPages.NET application

32

4. From the ItemTemplate section, delete [Label1].5. Drag a Repeater control from the Data toolbox tab to the ItemTemplate section.6. Click the arrow to open the Repeater Tasks menu and from the Choose Data Source options,

select RBODataSource1.7. With the Repeater control still selected, go to the Properties window and set the DataMember

field of the Repeater to Interests.

Note: When binding associated multivalued properties, set the DataMember field ofthe data bound control to a comma-separated list of RBO property names (for example,“CardNumber,ExpirationDate,SecurityCode”).

8. The Repeater control requires you to switch to Source View to enter the markup that will berepeated for each row of data. Inside the existing <asp:Repeater> tag, enter <ItemTemplate>.Increase the width of the DetailsView to accommodate the Interests field.

9. Select Debug > Start without Debugging from the Visual Studio menu to run the application.The individual values of the multivalued Interests field are displayed on their own lines, as shownin the following figure:

Figure 9: ASP.NET Application

Page 33: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

33

Appendix A: Configuration filesThe following sections describe the content of the Web DE configuration files.

rgw5.ini fileConfiguration of RedPages.NET connections is controlled through the rgw5.ini file, which isinstalled on Windows by default in the C:\U2\U2WDEnnn directory, where nnn is the versionnumber you installed. This path is set in the environment variable %U2WDE%. On UNIX systems,the rgw5.ini must be manually copied to your desired location, for example, the /etc directory.The $U2WDE environment variable should be created and the value set to point to the path to thergw5.ini file.

Format

The rgw5.ini file format is:

[SectionName]parameter_1=value_xparameter_2=value_y...

Each section contains a set of related parameters. Web DE searches the rgw5.ini file for predefinedand user-defined section names, and updates internal parameters based on the values set in the file.Most of the section names are predefined, so you cannot change them. However, you can define thenames of additional sections.

Example rgw5.ini file

The following example rgw5.ini file contains the default sections and settings that show the type ofdata required for each parameter:

[LogLevel]panic=1err=1inf=0init=1times=1wrn=1trace=1

[Default]perfstats=0

[rbexamples]workdir=C:\U2\U2WDE511\UDserver\rbexamplesMinimumPoolSize=2MaximumPoolSize=2ConnectionString=udcsuserId=cbrownpassword=2spwV0hJequEefsSBqK1KQ==server=localhostlogpath=C:\U2\U2WDE511;SchedulerPort=7070como=1usingssl=1

Page 34: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Appendix A: Configuration files

34

PoolingDebug=1IdleRemoveThreshold=15000IdleRemoveExecInterval=1000OpenSessionTimeout=1000

Sections of rgw5.ini file

The rgw5.ini file contains three default sections:

▪ [LogLevel] section▪ [Default] section▪ [accountname] section

[LogLevel] section

This section of the rgw5.ini file contains parameters for the types of information to write to theclient log files for Web DE-enabled U2 accounts. The log level parameters are global; they apply to allWeb DE-enabled U2 accounts on the RedBack Object Server computer.

The client log files are:

▪ RedBeans_accountname.log▪ RedPages_accountname_processid.log, where processid is the ID of the Windows process

with RedPagesNet.dll loaded.

The following example shows the [LogLevel] section:

[LogLevel]panic=1err=1inf=0init=1times=1wrn=1trace=1

The following table lists the log level parameters. Each parameter specifies whether to write details fora type of information to the client log files.

To log a type of information, set the parameter to 1, for example panic=1. To turn off logging fora type of information, set the parameter to 0, for example panic=0. By default, all parameters areturned off, except panic, err, and init.

Table 11: [LogLevel] section parameters

Parameter Description

panic Specifies whether to log fatal errors.

▪ 0 – Do not log fatal errors.▪ 1 – Log fatal errors. This is the default setting.

err Specifies whether to log details of serious errors.

▪ 0 – Do not log serious errors.▪ 1 – Log serious errors. This is the default setting.

Page 35: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

[Default] section

35

Parameter Description

inf Specifies whether to log informational messages.

▪ 0 – Do not log informational messages. This is the default setting.▪ 1 – Log informational messages.

init Specifies whether initialization/termination messages are to be logged.

▪ 0 – Do not log initialization or termination messages.▪ 1 – Log initialization/termination messages. This is the default setting.

times Specifies whether to log the times (in milliseconds) for executing RBO methodcalls.

▪ 0 – Do not log times of method calls. This is the default setting.▪ 1 – Log times of method calls.

wrn Specifies whether to log warning messages.

▪ 0 – Do not log warning messages. This is the default setting.▪ 1 – Log warning messages.

trace Specifies whether to log program flow tracing messages.

▪ 0 – Do not log program flow tracing messages. This is the default setting.▪ 1 – Log program flow tracing messages, including incoming request names,

request values, property names, and property values from the client. Alsolog outgoing property names and values being returned to the client.

[Default] section

The parameters in this section define Web DE system defaults. They apply to all Web DE-enabled U2accounts within the system. You can override the defaults within each [accountname] section.

The following example shows the [Default] section:

[Default]perfstats=0

The following table lists the default global parameters at the Web DE system level. You can add otherdefault parameters in this section, if applicable.

Table 12: [Default] section parameters

Parameter Description

perfstats Specifies whether to log performance statistics.

▪ 0 – Do not log performance statistics.▪ 1 – Log performance statistics.

The Perfstats.log file includes the same statistics available from theWeb DE performance monitor API, such as wait time and number of requestsprocessed for each account.

The Perfstats.log file is written to the C:\U2\U2WDEnnn directory bydefault, where nnn is the version number you installed.

[accountname] section

The rgw5.ini file contains a section for each account. The name of the section is the connectionname of the account, used as a reference by RedBeans or RedPages.NET.

Page 36: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

Appendix A: Configuration files

36

In each account section, you must define at least the mandatory parameters for the account. You canspecify additional parameters. If you specify a parameter in the [accountname] section that is also inthe [Default] section, the value you set for the account overrides the system default value.

The following example shows the [accountname] section:

[rbexamples]workdir=C:\U2\U2WDE511\UDserver\rbexamplesMinimumPoolSize=2MaximumPoolSize=2ConnectionString=udcsuserId=cbrownpassword=2spwV0hJequEefsSBqK1KQ==server=localhostlogpath=C:\U2\U2WDE511;SchedulerPort=7070como=1usingssl=1PoolingDebug=1IdleRemoveThreshold=15000IdleRemoveExecInterval=1000OpenSessionTimeout=1000

The following table describes the parameters in the [accountname] section:

Table 13: [accountname] section parameters

Parameter Description

workdir The physical path to the U2 account on the computer on which theRedBack Object Server is installed.

MinimumPoolSize The minimum number of connections maintained in the connection pool.

Setting this value and the MaximumPoolSize value to 0 enables thedeveloper mode, which allows you to execute newly compiled codethrough Web DE processes. Instead of using a cached version of the objectcode, the developer mode allows you to pick up the new object code assoon as it is available by causing the associated database processes torestart after each method call. While allowing newly compiled code to bepicked up, this mode carries a performance overhead as the associateddatabase processes terminate and are recreated after each method calland is not recommended for “live” production use for this reason.

The SchedulerPort must also be commented out to bypass theconnection to the Java Scheduler.

MaximumPoolSize The maximum number of connections maintained in the connection pool.

Setting this value and the MinimumPoolSize value to 0 enables thedeveloper mode. See the description in MinimumPoolSize for informationabout the developer mode.

ConnectionString Specifies whether the connection is a UniData (udcs) or UniVerse (uvcs)connection.

userId The operating system-level user ID for the RedBack Object Servercomputer.

Page 37: Rocket U2 Web Development January 2014 WDE-511-RPN …docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/webde/previous... · January 2014 WDE-511-RPN-DG-01. 2 Notices Edition ... Rocket

[accountname] section

37

Parameter Description

password The password associated with the user ID specified in the userIdparameter.

The password is encrypted when you save the JavaScheduler.inifile in Web Designer.

If you edit and save the rgw5.ini file in a text editor, the passwordis saved in plain text. To maintain server security, open and save thergw5.ini file in Web Designer to encrypt the password.

server The name or IP address of the computer on which the RedBack ObjectServer is installed.

logpath The full path of the directory in which to store client logfiles for the account on the client computer. The clientlog files are RedBeans_accountname.log andRedPages_accountname_processid.log, where processid is theID of the Windows process with RedPagesNet.dll loaded.

The directory must already exist; Web DE does not create a new directoryfor you. If the specified logpath directory does not exist, the applicationfails at run time.

SchedulerPort The port number on which the Java Scheduler accepts requests from thisaccount.

If this parameter is commented out, and the MinimumPoolSizeand MaximumPoolSize parameters are set to 0, the Java Schedulerconnection is bypassed.

como Specifies whether to save the server logs to the account _PH_ file inUniData or the &COMO& file in UniVerse.

▪ 0 – Do not save the logs.▪ 1 – Save the logs.

usingssl Specifies whether to use the SSL protocol when connecting to the U2server.

▪ 0 – Do not use SSL.▪ 1 – Use SSL.

PoolingDebug Specifies whether to keep a log of UOJ processes for the account fordebugging purposes.

▪ 0 – Do not keep a log of UOJ processes.▪ 1 – Keep a log of UOJ processes.

encoding Allows support of any session encoding for connections usingRedPages.NET or RedBeans.

IdleRemoveThreshold The number of milliseconds that a connection pool thread can remainidle before it is flagged for removal.

IdleRemoveExecInterval The number of milliseconds of the interval at which UOJ runs anexecutable to remove from a connection pool any threads that haveexceeded the idle threshold.

OpenSessionTimeout The number of milliseconds for which UOJ attempts to acquire a sessionfrom the connection pool before timing out.