Thursday, June 17, 2010

Using Applet in OAF

I have came across the use of applet within OAF page for a requirement where I had to use Java APIs provided by an activeX control loaded on client machine. Since OAF code runs on server side and not on client machine, using the applet was the only option to use.

The steps for using the applet are

  • Suppose XXApplet.class is the class file of your applet. First step is to package the applet into a jar file and sign the jar file. A page allow only singed applets to run, hence signing the applet is required.
  • To convert an applet class to a jar, command is

jar cvf uXXApplet.jar XXApplet.class

  • To sign the above jar file, follow below two links in chronological order by logging into unix server

http://java.sun.com/docs/books/tutorial/security/toolfilex/step2.html

http://java.sun.com/docs/books/tutorial/security/toolfilex/step3.html

  • On your OAF page, create OARawTextBean item. Lets assume its ID is xxApplet.
  • Extend the controller of the page. In your process request, you can attach the html text to the above Raw Text Bean as below. The example also shows passing the parameters to applet as "DocumentName" and "DocumentId".

String appletCode = "{applet code='XXApplet.class' ARCHIVE='XXApplet.jar' width=550 height=75}" + "{PARAM NAME='DocumentName' VALUE='XXXXXXX'}" + "{PARAM NAME='DocumentId' VALUE='A5577'}" +"This browser does not support Applets.{/applet}"; // replace } with > and { with <

OARawTextBean appletBean = (OARawTextBean)webBean.findChildRecursive("xxApplet"); !

appletBean.setText(appletCode);

  • Put the signed Applet jar file at $OA_HTML.