For calling Applet from OAF, first we need java class file which invokes Applet. If the java file is single, does not depend on any other class files, then add this java file in MyProjects folder and compile from Jdeveloper. call Method of class file, which invokes applet from OAF controller.
If java file depends on other class files, then add jar file which contains all the required java files to Library in jdeveloper.
Adding Jar file to Library in Jdeveloper:
-----------------------------------------------
Right click on ProjectName--> Project properties--> Click on Add Jar/Directory -->select the Jar file --> click on OK
Import jar file in the controller using import statement.
If we want to pass the output of applet to another control file , then its better to call applet from JSP page and invoke this jsp from OAF. JSP supports both client and server applications.
Steps To Call Applets from OAF Page:
---------------------------------------------
1. Call Jsp Page from OAF page which invokes Applets by using setForwardURL Method.
pageContext.setForwardURL("/OA_HTML/SupplierSign.jsp",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
hm, //HashMap
true, // Retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_YES, // Show breadcrumbs
OAWebBeanConstants.IGNORE_MESSAGES);
Pass required parameters using HashMap.
2. Create Jsp page under 'web Content' in Jdeveloper Project.
Right Click on Web Content --> New-->webTier -->Jsp -->select Jsp from Items window and click on Ok.
A wizard will be opened . Click on Next , Give File Name ,Directory should be OA_HTML.
Click on Next -->select error page option as 'Do not use an error page to handle uncaught exceptions in this file' -->Click on Next -->Next-->Next-->Finish
3.Click on Source tab below the jsp page.
4. For Invoking Applets we should migrate required Jar and JS files to /OA_HTML path in the server.
5. Find below code in Jsp to invoke Appltes and send Output of the Applet to Another Page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<head>
<script src="/OA_HTML/JAVA_SCRIPT_FILE" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
var a;
var b;
var UserName;
/* Submit Function definition which calls on body load */
function Submit()
{
/* Fetch values */
UserName = document.getElementById("userNameParam").value;
/* If userName is not null then */
if(UserName != '')
{
a= document.websignerapplet; //Create an object for websignerapplet class
websignerapplet.open(XMLData , "Login" , "sign","attached", "emasSubmit()", "emasCancel()"); // Call open method in websignerapplet class
}
/* If UserName is null then */
else
{
alert('Please enter username to Sign'); //give an alert
return false;
}
}
/* If User clicks on Sign then call emasSubmit function */
function emasSubmit()
{
var loginForm = document.frmsubmitDSC; //Create an object for Form
var returnVal = JAVA_CLASS.METHOD(); //Call getGeneratedSignature method to get SIgnData
/* Assign values to Form Variable */
loginForm.signeddata.value = returnVal ;
loginForm.username.value=UserName;
loginForm.submit(); //Submit Login FOrm
}
/* If User Clicks on Cancel */
function emasCancel()
{
alert('emas cancelled'); //Give an alert
}
</script>
</head>
<body onLoad="Submit()"> <%-- Call Submit function on body load --%>
<%-- Fetch Values --%>
<input type="hidden" id="userNameParam" value="<%=request.getParameter("Username")%>"/>
<div id="javaRequiredDiv"></div>
<script type="text/javascript">
var contextPath = "/OA_HTML/JAR_FILE"; //Get Jar file
if( deployJava.versionCheck("1.6+")==false ) {
var java_message = 'Websigner requires JRE1.5 or higher. Please download it from <a href="http://10.80.100.146:8088/websigner4.0/jre6u21.exe">Click here</a> to download jre. <br>Once Installation is done. Close the browser and relogin.';
if (document.all) {
javaRequiredDiv.innerHTML=java_message;
} else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("javaRequiredDiv");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragment(java_message);
while (el.hasChildNodes()) {
el.removeChild(el.lastChild);
}
el.appendChild(htmlFrag);
}
} else {
var attributes = {
code :'emas.WebsignerApplet.class',
archive : contextPath,
width :1,
height :1,
name : 'websignerapplet'
};
var parameters = {
MAYSCRIPT : 'true',
scriptable : 'true',
enableExpiryCheck : 'true',
regexFilterIssuerName : '',
enableEncipherCheck : 'ALL',
certificateClass : '0'
};
var version = '1.5';
deployJava.runApplet(attributes, parameters, version);
}
</script>
<% try {%>
<!-- <TR>
<TD class="content"><a href="#" onclick="Submit()">Enroll With Digital Signature Certificate</a> </TD> #VA1
</TR> -->
<div class="box">
<FORM name="frmsubmitDSC" action="/OA_HTML/EmpAuthSubmit4.jsp" method="POST"> <%-- Redirect to EmpAuthSubmit4.jsp which invokes webservices to Authenticate Employee --%>
<div>
<%-- Pass variables to EmpAuthSubmit4.jsp --%>
<input type="hidden" value="" name="signeddata">
<input type="hidden" value="" name="AuctionHeaderId">
<input type="hidden" value="" name="userId">
<input type="hidden" value="" name="username">
<input type="hidden" value="" name="DBUser">
<input type="hidden" value="" name="DBPwd">
<input type="hidden" value="" name="Host">
<input type="hidden" value="" name="port">
<input type="hidden" value="" name="Sid">
</div>
</FORM>
</div>
<% }
catch ( Throwable e)
{
out.println("Runtime error in JSP");
}
%>
</body>
</html>