Menu

Info on applet

Help
2011-10-12
2013-03-18
  • nenad cikic

    nenad cikic - 2011-10-12

    I have installed clarion2java, java jdk postgre,maven and i have tried to port the cookbook example to clarion6 (which is what i use at the moment). All is working perfectly!
    Now i am trying to specify my project in details with the customer. The project i have is relatively simple. I think that there are not more than 10 browses/forms/reports. I have seen that you may also generate applets. Is there some example for this? Is it possible to print to local printers from applets (i suppose it is possible)?

    thanks
    Nenad

     
  • Andrew Barnham

    Andrew Barnham - 2011-10-14

    Hi.  I have created a system which allows you to run the bulk of the clarion/java application remotely, but the client is a thin frontend that is applet based.  The applet, when compacted and obfuscated is about 400k.  To make the entire project a applet it can be done with a few lines of java, the resulting .jar files would be about 3 or 4 MB although.

    Yes, the applet is able to access local printers etc; but in most web browsers it will complain about security and ask user to confirm.  To work around this you need to get the applet digitally signed.

    In addition to local printers, my thin client also emulates local INI file like settings, access local file system, etc.  Essentially the application feels like it is running locally, although only the GUI layer is and the main business logic resides elsewhere.

    The system, like most of clarion2java is not very polished although.  Some expertise in network programming and java programming in general will be necessary.

    To enable server mode. In your clarion app, after the 'CODE' statement add the following:
       @java-code 'org.jclarion.clarion.swing.gui.StartServer.start();'

    This will enable server mode, the application when run will wait for a client to connect.

    To run the client (on same machine) do following:

    java -jar org.jclarion.clarion.swing.gui.StartClient localhost 5000

    localhost is name of host server is running on.  5000 is TCP/IP port number.  If you run across networks, make sure firewalls in between allow traffic on port 5000.

    To build as an applet you need to wrap in some code like this (not tested)
    public class MainApplet extends Applet
    {
            private static final long serialVersionUID = 7318609913869099963L;

            @Override
            public void init() {
                    Thread t = new Thread() {
                            @SuppressWarnings({ "unchecked", "rawtypes" })
                            public void run() {
                                    AccessController.doPrivileged(new PrivilegedAction() {
                                            @Override
                                            public Object run() {
                                                    AccessController.checkPermission(new AllPermission());
                                                    StartClient.main(new String { "name of webserver","5000" } );
                                                    return null;
                                            }

                                    });
                            }
                    };
                    t.start();
            }
    }

     

Log in to post a comment.

Auth0 Logo