To define the client UI, add a visual part to MyDatabaseTCPIPApp and name it, for example, MyClientView.In a Composition Editor open on MyClientView, do the following:
1. Change the Window part's title to Database-TCP/IP client.
3. Change the settings for the left-most column. Specify ID for attributeName and heading, and String for converter. For the next column, specify NAME for attributeName and heading, and String for converter. For the next three columns, specify DEPT, JOB, then YEARS for the attributeName and heading properties of the respective parts. Finally, for the right-most column, specify SALARY for attributeName and heading, and Decimal for converter.
4. Add five Label parts and five Text parts to the window. Change the labels to Staff ID#, Logon ID, Host ID, Port, and Password.Situate a Text part beside each label. Open the settings for the Staff ID# Text part and set notifyChangeOnEachKeystroke to false, and set partName to id. For the Logon ID Text part, set partName to logonId. For the Host ID Text part, set converter to String and partName to hostIdField. For the Port Text part, set converter to Integer, notifyChangeOnEachKeystroke to false, and partName to portField. For the Password Text part, set partName to password.For the object properties of the Text parts, you might specify default values so users do not need to type them in later.
5. Go to the Script Editor for MyClientView and add two instance methods:
2.
3. Connect the hostId attribute of the TCP/IP Connection Specification to the object attribute of the Host ID text field.
4. Connect the port attribute of the TCP/IP Connection Specification to the object attribute of the Port text field.
5.
6. Connect the spec parameter of the clicked-connect connection to the self attribute of the TCP/IP Connection Specification.
7.
8. Connect the normalResult parameter of the sent-receiveWithLengthInData connection to the initializeWith action of the Buffer.
9. Connect the connected event of the TCP Socket to the sendIncorporatingLength: action of the TCP Socket.
10. Connect the sendDataObject parameter of the connected-sendIncorporatingLength: connection to the data script.
11.
12. Connect parameter1 of the changed-formatData: connection to the contentsAsString attribute of the Buffer.
![]() |