Programmable Host On-Demand Reference

Programmable Host On-Demand

Display session sample applet

                                         
   import com.ibm.eNetwork.HOD.common.Environment;  // Get the Environment class
   import com.ibm.eNetwork.HOD.customizable.*;      // Access to the API classes 
   import java.applet.*;                            // Get the Applet class 
   import java.awt.*;                               // Get the AWT classes

   public class TermTest extends Applet { 
    CustomDesktop desktop;

      
      public void init() {
         super.init();                       // Call init on the super class 
         setLayout(new BorderLayout()); 
         
         Environment env = new Environment(this);
           
           try { 
                HODSessionManager sm = new HODSessionManager();
                desktop = sm.createCustomDesktop(env, "TermTest");
                HODDisplaySession session = desktop.startDisplaySession("3270 Display");
                add(BorderLayout.NORTH, session.getToolbar());
                add(BorderLayout.CENTER, (Component)session.getTerminal());
                validate();
           } catch (Exception e) { 
                e.printStackTrace();
           } 
        
        
      } // end init method 
      
   } // end TermTest class 

Sample applet explanation

The following explains each statement or group of statements used in the sample program:

  1. Import the necessary packages as follows:
       import com.ibm.eNetwork.HOD.common.Environment;  // Get the Environment class
       import com.ibm.eNetwork.HOD.customizable.*;       // Access to the API classes 
       import java.applet.*;                            // Get the Applet class 
       import java.awt.*;                               // Get AWT classes 
       
  2. Create a simple Java class called TermTest. Extend the Applet class, which gives you an applet that you can run in a browser:
       public class TermTest extends Applet { 
  3. Because you are extending the Applet class, you need to implement an init() method that is called when an instance of TermTest is created. The setLayout statement sets your applet's layout style:
       public void init() { 
          super.init();  
          
          setLayout(new BorderLayout()); 
  4. Create an instance of the Host On-Demand Environment object, passing the applet instance. The Host On-Demand Environment class needs the applet instance when the Programmable Host On-Demand runs as an applet:
          Environment env = new Environment(this);
  5. Create the HODSessionManager and the CustomDesktop objects:
               try { 
               
                    /*
                     * The name of the HTML file generated by the Deployment
                     * wizard is TermTest. HODData/TermTest exists on the Web server 
                     * and contains the session definition files.
                     */
                    HODSessionManager sm = new HODSessionManager();
                    CustomDesktop desktop = sm.createCustomDesktop(env, "TermTest");
                    HODDisplaySession session = desktop.startDisplaySession("3270 Display");
                    add(BorderLayout.NORTH, session.getToolbar());
                    add(BorderLayout.CENTER, (Component)session.getTerminal());
                    validate();
               } catch (Exception e) { 
                    e.printStackTrace();
               } 
      

Run the sample applet

Use the following simple HTML file to run the applet you created. The applet parameter ParameterFile must be present to use the API:

  <HTML>
  <HEAD>
  <TITLE>First Programmable Host On-Demand Applet</TITLE>
  </HEAD>
  <BODY>
  <APPLET archive="habasen.jar,hodbasen.jar,hodapin.jar,ha3270n.jar,hodimg.jar,hacp.jar,ha_en.jar,customer.jar" CODE="TermTest.class" WIDTH=600 HEIGHT=700>
  <PARAM NAME="Cabinets" VALUE="habasen.cab,hodbasen.cab,hodapin.cab,ha3270n.cab,hodimg.cab,hacp.cab,ha_en.cab,customer.cab">
  <PARAM NAME="ParameterFile" VALUE="HODData\\TermTest\\params.txt">
  </APPLET>
  </BODY>
  </HTML>

To run TermTest, complete the following steps:

  1. Save the sample program as TermTest.java.
  2. Compile TermTest.java.
  3. Point a Web browser to TermTest.html on your Web server.

[ Top of Page | Previous Page | Next Page | Table of Contents ]