Advanced Programming Tasks > Integrate Web and Host Data |
Using this sample program, you can build a custom application that can perform the following tasks:
In addition, the sample program demonstrates the recommended way to get an Application object and keep it around. It defines the class member variable m_application , assigns an Application instance to it in OnLoad(), and then uses the variable to reference the Application instance.
To build the custom application
This code defines the m_application variable, as follows:
private Attachmate.Reflection.Framework.Application m_application;
This code also provides the easiest and most reliable way to reference a Web element — the ID:
IWebElement searchbox = m_WebDocument.GetElementById("q")
Locate the line that starts |
And do this |
m_terminal= (IIbmTerminal) -or- m_terminal= |
Edit the path to match the location of the session document you saved in step 1. For example, if you created a 5250 session named test.rd5x on Windows 7, edit the path to read as follows: (@"C:\Users\user_name\Documents\Attachmate\Reflection\test.rd5x"); |
m_webControl= (IWebControl) |
Edit the path to match the location of the Web page document you saved in step 1. |
The program starts Reflection 2014 and opens a Windows Form application interface that contains two buttons and three text boxes.
To run the custom application
The host and Web page documents open in Reflection.
The application extracts text from the host session screen and places it in the Search box of the Web page document. Then, it gets the Web element for the Search Web button and clicks the button, which triggers a search and a navigation to the search results page. From the search results page, it locates the Web element for the result text, extracts the number from that text, and places it in a message box.
When you quit the custom application, the m_application instance is garbage collected.