creapage.net

HOWTO - Sashipa development

 How to create an applet.

You already have a Sashipa application. You wish to transform it to an applet.

NB: the Java plugin (in the Sun JRE - free of cost) is required on each PC that will execute your applet.

An applet has restricted rights to access network and devices. The only allowed communications are HTTP access to the server from it has been loaded.

So an applet can't:

The first step is also to make a servlet architecture (that enables multi-users management) or a database access with a PHP.

When using a database access through a PHP, be carefull ! You must have an empty server.logStorage element. Add to this, the element configFileStorage can not be used. Because an applet can't access to local file systems.

When your client-servlet-database architecture or your client-php-database architecture is ready, just set to 'applet' the type attribute of a guiInstance element in you Sashipa code:

  <guiInstance name='guiDemoContact_en' type='applet'>

Rebuild, then your applet is created !

Now you have to make an html page, that contains your applet. The <applet> markup isn't sufficient. Specifical browser markup must be used for calling Java plugin.

Here is the HTML code that I use for the demonstration applet on the Web site:

  <SCRIPT LANGUAGE="JavaScript">
  <!--
      var _info = navigator.userAgent; var _ns = false;
      var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0
                && _info.indexOf("Windows 3.1") < 0);
  //-->
  </SCRIPT>
  <COMMENT>
    <SCRIPT LANGUAGE="JavaScript1.1">
    <!--
      var _ns = (navigator.appName.indexOf("Netscape") >= 0
                && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0
                && java.lang.System.getProperty("os.version").indexOf("3.5") < 0)
                || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0)));
    //-->
    </SCRIPT>
  </COMMENT>
  <SCRIPT LANGUAGE="JavaScript">
  <!--
      if (_ie == true)
        document.writeln(
          '<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"' +
          ' archive="YourNameBinUnit.jar"  WIDTH = "580" HEIGHT = "400">' +
          '<NOEMBED><XMP>'
          );
      else if (_ns == true)
        document.writeln(
          '<EMBED type="application/x-java-applet;version=1.4"' +
          ' archive="YourNameBinUnit.jar"' +
          ' java_CODE = "YourNameBinUnit.class" CODE = "YourNameBinUnit.class"' +
          ' WIDTH = "580" HEIGHT = "400">' +
          '<NOEMBED><XMP>'
          );
  //-->
  </SCRIPT>
  <APPLET CODE = "YourNameBinUnit.class" WIDTH="580" HEIGHT="400" ></XMP>
  <PARAM NAME="CODE" VALUE="YourNameBinUnit.class">
  <PARAM NAME="archive" VALUE="YourNameBinUnit.jar">
  <PARAM NAME="type" VALUE="Xapplication/x-java-applet;version=1.4">
  </APPLET></NOEMBED></EMBED></OBJECT>

You just have to replace 'YourNameBinUnit' by the resource name specified in the guiLoaderBinaryUnit.binaryUnitResourceName element in your Sashipa code. The value for this element is used for creating a name to '.jar' file and a name for '.class' file. Note that in the case of '.class' file, the first letter is switched to upper case. Define the applet size.

Put the jar file in the same directory than the html file.

... and let's go ! :o)

NB: when you are loading the applet, even from your local PC, you have to use a url with the network name (or the ip address) of your host. Do not use localhost, otherwise you should have a security access error.

© Copyright 2003 Sashipa-Melba Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License as much as this note clearly appears.