Can call an applet method directly in javascript?

I want to call an applet method directly in javascript
as the following format:
function test()
ret_val = document.myapplet.mymethod();
myapplet is the applet name,mymethod is a
public method in applet and it returns a string
result,can that works?
//thx

Hi , i know that that is possible, i dont have the example right here just wait until tomorrow at the morning and i sent it to you , please send me a email to remaind me the code
[email protected]

Similar Messages

  • Call to Applet Method from JavaScript Failed.

    I Am calling a method from a javascript function from within a web page.
    The page is loaded into a frame. The parent window of the frame has stored a reference to the applet which defines the methods. Note I am treating the reterence to the applet as a global variable. So that I can reference it methods as I navigate from one page to another.
    I have JavaScript objects defined, and I am passing them as parameters to the applet's methods. In java, the JavaScript objects are refererenced as JSObject. When I call a java method passing a JavaScript
    Object I get the following exception. Note Iam using j2sdk1.4.2_01 on a Windows 2000 Professional System. This problem start occurring after the recent Microsoft Worm/Virus a fix was loaded on my system which resulted in the following bug. Could someone please help me.
    java.lang.NullPointerException
         at sun.plugin.javascript.ocx.JSObject.setIExplorerAppletContext(Unknown Source)
         at sun.plugin.com.DispatchImpl.convertParams(Unknown Source)
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$2.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
    java.lang.Exception: java.lang.NullPointerException
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$2.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)

    A little code snippet would help. I use JSObjects from Java 1.4 no problem and do have all the latest updates. I also have JavaScript calling Java code as well - also with no problem.

  • How to get the applet method value in javascript variable

    Hi,
    I have an applet which reading the text file content, text file has valued either ON or OFF
    import java.applet.*;
    import java.io.*;
    public class A extends Applet
    public String line="";
    public void init( )
    String strPath ="D:/WAS_Status.txt";
    try
                             BufferedReader objReader = new BufferedReader(new FileReader(strPath));
                             line = objReader.readLine();
    }catch( IOException e)
    e.printStackTrace();
                        System.out.println("val :"+line);
              public boolean returnFileValue()
                   if("ON".equals(line))
                        return true;
                   else
                        return false;
    In html file :
    <HTML>
    <HEAD>
    <SCRIPT language="JavaScript">
    var line='';
    function loadAppContent()
         line=document.TestApplet.returnFileValue();
         alert("val : "+line);
    </SCRIPT>
    </HEAD>
    <BODY onload="loadAppContent()">
    <APPLET CODE="A.class" NAME="TestApplet" >
    </APPLET >
    </BODY>
    </HTML>
    I am calling the applet method. But I am not able to get value either as true or false.
    line=document.TestApplet.returnFileValue();
    Getting error as object doesnt support this property.
    I tried, line=document.TestApplet.line;
    Gets val as undefined.
    The line variable of Applet will return either ON or OFF value.
    Pls suggest where it has gone wrong or is there any other way?

    Yes it is a reserved word to warn that this applet , lets say send messages to the HTML page that call it.
    You will find the instruction how to do that at sun site.
    Yes you have to implement an interface inside the applet (code)
    and send a message to HTML with the name and parameters of
    the Javascript you want to call!
    But for all this to work you have to put in your project two new classes.
    And after that call some methods that does the job you want.
    Look for Java to JavaScript Comunication to get what you want!.
    check this per exemple!
    http://java.sun.com/products/plugin/1.2/docs/jsobject.html
    See You ( Ate mais )

  • Calling a abap method in a javascript

    Hi all,
    I've been browsing a bit through this forum, but there has no answer been completely covering my problem...
    I would like to call an abap method in the javascript in order to check some values...
    This is what I have done:
    <script language="JavaScript" defer="defer">
        function do_checks(htmlbevent)
            try
                  var doubles = "<%= controller->check_doubles( )%>";
                  if(doubles == true){
                      var Check = confirm("Test??");
                      if(Check == false){
                        htmlbevent.cancelSubmit = true;
            catch(e)
      </script>
    The method has the following code:
    mehod check_doubles. " returning parameter = rv_double of type flag
      rv_double = abap_true.
    endmethod.
    the button is defined like this...
    <htmlb:button
                              id      = "Save"
                              onClick = "save"
                              onClientClick = "do_checks(htmlbevent);"
                              text    = "<%= otr(crm_ic_appl/Save) %>"
                              />
    The funny thing is, that the controller->check_doubles( ). is already processed at load of the page (although there is no on_load used somewhere...
    If I leave out the " if(doubles == true){ } ", the javascript reacts as foreseen..., but when I keep the " if(doubles == true){ } ", the javascript doesn't go through the method anymore...
    Can anybody help me out here???
    Thanks!!
    Micha

    Hi,
    You can call them FM inside the javascript something like below...
    <script language="JavaScript">
    function yourFM()
    <%
       DATA: guid TYPE GUID_32.
       CALL FUNCTION 'GUID_CREATE' IMPORTING ev_guid_32 = guid.
    %>
    </script>
    <b>To call the class & method:</b>
    <script language="JavaScript">
        function yourFM()
          <% CLASS cl_bsp_login_application DEFINITION LOAD. %>
          var EXIT_URL  = "<%= CL_BSP_LOGIN_APPLICATION=>GET_SESSIONEXIT_URL( page = page ) %>";
      </script>
    But i am not clear what do you want to achieve. I didnt understand what you are trying to do with you code. Could you give more detail?
    <i>* Reward each useful answer</i>
    Raja T
    Message was edited by:
            Raja Thangamani

  • How can I call a servlet method from a javascript function

    I want to call l a servlet method from a javascript function.
    Does any one have an example of code.
    Thinks in advance

    Actually, as long as the servlet returns valid javascript, you can indeed "call it" from the client. It will initiate a request and return the result to the browser.
    This example uses Perl, but it could be easily modified to go to a servlet instead.
    Note that it is only supported in DOM browsers (IE6+/NN6+/etc)
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
    <head>
    <title> Test server-side JS </title>
    </head>
    <body>
    <script type="text/javascript">
    function checkIt(variable, value)
    var newScript = "cgi-bin/validateJS.cgi?"+variable+"="+value;
    var body = document.getElementsByTagName('body').item(0)
    var scriptTag = document.getElementById('loadScript');
    if(scriptTag) body.removeChild(scriptTag);
    script = document.createElement('script');
    script.src = newScript;
         script.type = 'text/javascript';
         script.id = 'loadScript';
         body.appendChild(script)
    </script>
    <p>Test.</p>
    <form id="f1" action="">
    <input type="text" name="t1" id="t1" onChange="checkIt(this.name, this.value)">
    </body>
    </html>
    validateJS.cgi
    #!/opt/x11r6/bin/perl
    use CGI qw(:all);
    my @valArray = split(/=/,$ENV{QUERY_STRING});
    print "Content-type: text/javascript\n\n";
    # myPass is the password
    $myPass = "foobar";
    if ("$valArray[1]" eq "$myPass")
    print "alert(\"Success!!\")";
    else
    print "alert(\"Failure!!\")";

  • Can we call a BO method directly

    Hi all,
    Can we call a BO method  explicitly in a program .
    e.g. can i  call the method approve of the  FORMABSENC BO.
    Regards,
    Sateesh.

    Of course you can. You just need to include the macros include so you can create objects and call the methods. If you are not familiar with the different macros, just browse through <CNTN01> to find what you need. There is documentation in the code.
    You will probably need at least the following four macros
    SWC_CREATE_OBJECT to create an object from its type and key.
    SWC_SET_ELEMENT one or more times to fill the container with appropriate parameters.
    SWC_CALL_METHOD to call the method.
    SWC_GET_ELEMENT one or more times to retrieve returned parameters.
    Note that SWC_SET_ELEMENT does not work for table parametes, use SWC_SET_TABLE instead.

  • How to call a bean method through a javascript function

    I dont discover any problems calling the bean method in this maner:
    <%= helpdesk.data() %>
    But, when I use a Button Onclick= to call the script function and which then is going call my bean method
    an error on the page is reported!
    I have include som code which gives you the idea of what Iam searching for. And is it possible to call
    the bean method without doing from a new jsp page?
    If you have any suggestions to why it doesnt work, please let me know.
    I use Apache Tomcat 4.0
    Best regards Micah.
    <jsp:useBean id='helpdesk' scope='application'
    class='helpdesk.testdb'/>
    <html>
    <head>
    <script language="javascript">
    function broadcast()
    helpdesk.data();
    </script>
    </head>
    <body>
    <input type="button" value="Broadcast" onclick= broadcast()>
    </body>
    </html>

    It's actually quite simple:
    Beans run server-side
    Javascript runs client-side
    So you will never be able to run server-side-code thru the client...

  • Tomcat calling weblogic applet

    Does anyone know how to get by this exception. java.security.AccessControlException:
    access denied (java.net.SocketPermission ) I'm running a web app that calls
    an applet sitting on weblogic 6.1. Whenever I try to call it, it gives me the
    socketPermission error. What do I have to do to get by this?
    Thanks

    I have managed to do this, but perhaps the way I have done it is a bit long-winded and there may be an easier (better) way. Also, note that this method is for applets on the same web site only.
    The answer lies in Javascript, where a Javascript method can call an Applet method. Therefore, if one applet can communicate with the web-page via Javascript, then any other applets on that page can communicate with any other applets there.
    This is an example piece of Javascript code to show u what I mean:
    function callAppletMethod()
       var str = window.parent.VerifyApp.check();
    etc...
    }Here, the variable 'str' gains the value returned by the method 'check()' in the applet called VerifyApp.
    There is other ways to communicate between applets and Javascript, but I think they are for Netscape Navigator browsers only.
    Anyway, hope that helps.

  • Javascript to Java (Applet) method call fails in JRE1.4.1 & NN4.79

    Win2k, Netscape 4.79, JRE 1.4.1. I'm trying to call an applet method from Javascript from the page which contains the applet. 'm using MAYSCRIPT tag. I'm getting the error "myApplet doesn'nt have any properties". (myApplet is the name of the applet). When I use the default JRE which is supported by NN4.79(Symantic JRE 1.1.5) it works well. Does JRE1.4.1 plugin doesn't support Javascript to Java calls? OR I'm doing something wrong.
    Deepak

    I'm seeing the same issue. This is supposed to work. I converted the <APPLET> tags in the HTML to use <OBJECT> and <EMBED> tags using Sun's converter (see http://java.sun.com/j2se/1.4/docs/guide/plugin/developer_guide/using_tags.html). I try to reference the applet (using the document.embeds[0] object instead of the document.applets[0] object) and it seems the applet has not been loaded. I can't reference any of the methods in the applet. It appears the applet has not loaded. I do not see any evidence of the applet's init() method being called.
    Have you had any luck getting this to work?

  • How to call a bean method through javascript?

    Hi,
    i want to call a bean method using the javascript.
    thansk in advance.

    hi
    i want to call a backing bean method thought javscript on the button click.
    i am inplementing addition of textbox at runtime.i wrote method and i am calling that on the button click.but the textbox is not created.
    the code is bleow
    public String doAction() {
         tryStuff1();
    return "samplejsf";
    public void tryStuff1()
    System.out.println("Enter the trystuff method");
         FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot uIViewRoot = facesContext.getViewRoot();
    Application application = facesContext.getApplication();
    UIComponent formComp=uIViewRoot.findComponent("subbody:form1");
    HtmlPanelGrid grid= new HtmlPanelGrid();
    grid.setId("panelgrid2");
    grid.setColumns(2);
    grid.setBorder(2);
    //UIComponent panelGridComp=formComp.findComponent("subbody:panelgrid1");
    //UIComponent panelGroupComp=panelGridComp.findComponent("panelgroup2");
         HtmlOutputText output = new HtmlOutputText();
    output.setValue("dynamic jsf text2");
    System.out.println("hello output text2");
    output.setRendered(true);
    grid.getChildren().add(output);
    HtmlInputText input = new HtmlInputText();
    input.setSize(40);
    input.setValueBinding("value", (ValueBinding) application.createValueBinding("#{sample.text2}"));
    input.setRendered(true);
    grid.getChildren().add(input);
    System.out.println("hello output text1");
    grid.setRendered(true);
    formComp.getChildren().add(grid);
    System.out.println("hello output text3:");
    formComp.getRendersChildren();
    formComp.setRendered(true);
    public boolean getRendersChildren() {
         return true;
    jsp code is
    <h:form id="form1">
    <h:panelGrid columns="2" binding="#{sample.formElements}">
    </h:panelGrid>
    <h:panelGrid id="panelgrid1" columns="1">
    <h:panelGroup id="panelgroup1">
    <h:outputText value="hardcoded jsf text1"/>
    <h:inputText value="#{sample.text1}"/>
    </h:panelGroup>
    </h:panelGrid>
    <h:commandButton id="add" action="#{sample.doAction}" value="add" type="SUBMIT"/>
    </h:form>
    when i click on the button its going into the method and diaplying s.o.p but the text box is not updated to the page.
    why is it so.
    i thought there may be a problem in calling the method directly thru button. i want to try thru javascript calling the bean method.
    why is the page not updated.
    can u help me out
    thanks in advance
    sree

  • Problem calling applet method using IE

    I've searched through the forum and can't seem to find anything that can help me fix this. I'm trying to call an applet's method using Javascript. This is working fine under Netscape, but not IE. Everything I've read seems to indicate that I'm doing this right, but I'm getting "Object doesn't support this property or method" when I try to call the applet method from IE.
    In this example method, I'm trying to call the applet's countChars method, which should return the length of the string you pass into it. Works under Netscape 6.2, but not IE 6.0
    Here's my applet code:
    import java.lang.String;
    public class test extends java.applet.Applet {
    public static int countChars(String s) {
    return s.length();
    And my HTML
    <HTML>
    <HEAD>
    <script language="Javascript">
    function refreshApplet()
    /*     i = document.forms.myForm.TestApplet.countChars();
         document.forms.myForm.output.value=i; */
         document.forms.myForm.output.value=document.applets["TestApplet"].countChars(document.forms.myForm.input.value);
    </script>
    </HEAD>
    <BODY>
    <APPLET CODE = "test.class" WIDTH = 400 HEIGHT = 400 ALIGN = middle NAME = "TestApplet" scriptable="true">
    </APPLET>
    <br>
    <form name="myForm">
    <input type="text" name="input">
    <input type="button" value="click me" onClick="refreshApplet();">
    <hr>
    <input type="text" name="output">
    </form>
    </BODY>
    </HTML>
    Thanks in advance!
    Craig Drabik
    Sr. Programmer/Analyst
    University at Buffalo

    I have very similar problem, my applet works OK using Netscape (6.2 and 7.0), but with IE 6.0 It only works with windows XP;
    The reported error is "Object doesn't support this property or method"
    Can someone please help me to solve this problem.
    Cheers
    Horus
    This is my code:
    - I call the applet using javaScript and input the method setData with two strings.
    function graphic()
         var dataZenith;
         var dataManual;
         initVariables();
         dataZenith = graphicZENith(); //Call other Javascript functions
         dataManual = graphicManual(); //Call other Javascript functions
         document.AppletOne.setData(dataZenith,dataManual);
    I run the applet with this HTML code:
    <applet NAME="AppletOne" code="Appl.class" width="450" height="450"
    MAYSCRIPT></applet>
    //Applet code/////////////
    import java.awt.*;
    import java.awt.geom.*;
    import java.applet.*;
    import java.util.*;
    public class Appl extends Applet {
         private int [] myArray1 = new int [156];     
         private int [] myArray2 = new int [156];
         private boolean flag = false;
         // maxDataYAxesNumber es usado para dividir el eje de las Y
    public void init()
              setFont(new Font("SansSerif", Font.BOLD, 12));
              setBackground (Color.white);
              setSize(getSize());     
    // Get data and put in an array
    public void setData(String data1, String data2)
              final String DELIMITER = ",";
              final StringTokenizer theTokens1 =
                   new StringTokenizer(data1, DELIMITER);     
              final StringTokenizer theTokens2 =
                   new StringTokenizer(data2, DELIMITER);
              try
                        String dataX = data1;
                        for (int i = 0; i < 156; i++)
                        myArray1[i] = Integer.parseInt(theTokens1.nextToken().trim());
                        myArray2[i] = Integer.parseInt(theTokens2.nextToken().trim());
              catch (NumberFormatException e) {};
              flag = true; //I get the data OK
              repaint();
    public void paint (Graphics g){
    Graphics2D g2d = (Graphics2D)g;
    setData(data1, data2) ;
    if (flag == true)
                   //Call other functions to process the graphic
    else g2d.drawString(" Sorry I can get Data", 100,80);          

  • Call abap method in a javaScript Function

    Hi all,
    I want call a abap method via a javaScript function in a view of a bsp application.
    Does someone know how it works?
    regards Alex

    Hi,
    You can either change the location of the page to a target URL usinng "document.location.href = 'targeturl'. So targeturl is the fully qualified url necessary to call the method.
    Or you can take a look at XMLHttpRequest object (http://www.w3.org/TR/XMLHttpRequest/) which can create requests to a given URL. You can parse and use the data returned by the target url.
    Hope it helps,
    Regards.
    Ozcan.

  • Why javascript is not able to call signed appet method ?

    I am trying to call signed applet method from JavaScript. The html page run but when try to call applet method by clicking the button it's not performing the required action. I am really stacked there. It's also don't give any error, please anybody could give me few suggestion that why is it so. It will be great help for me.
    Thanking you

    Please put a System.out.println("Here I am") right at the begining of your java method that is supposed to be called from javascript.
    Redo your scenario and post here the contents of the Java console.

  • Can i call signed applet from jsf page in sun studio creator

    Hello javites,
    I want to know whether i can call signed applet from jsf page in sun studio creator. If possible, how do i go about it.
    Thanks.

    This tutorial may help:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/applet.html?feed=DSC

  • Problem accessing applet methods since 1.4.2_06

    Hello,
    I'm working with ie 6.0
    I'm accessing applet methods from javascript
    My applets were working fine until I installed the JRE 1.4.2_06 (I tested them with JRE 1.4.2_05 and it worked)
    Now, when I call an applet method from javascript, I have a javascript exception, as if the applet is not loaded, but I think it is : I can see it in the traces in the java console !
    I didn't modify the code, just the JRE.
    It doesn't work with jre 1.5 too
    Here a simple sample code that doesn't work with JRE 1.4.2_06 :
    APPLET :
    import java.applet.Applet;
    public class Test extends Applet
         public void test() {
              System.err.println("test");
    HTML :
    <html>
    <body>
    <script language="JavaScript">
         function myTest() {
              document.myform.test.test();
    </script>
    <form name="myform">
    <OBJECT NAME="test" WIDTH=500 HEIGHT=120 CLASSID="CLSID:8AD9C840-044E-11d1-B3E9-00805F499D93">
    <PARAM NAME="code" value="Test.class">
    <PARAM NAME="scripting" value="true">
    </OBJECT>
         <input type="button" value="test !!" onclick="myTest()">
    </form>
    </body>
    </html>
    If you have any suggestion ...
    Thanks

    It should work, what if you try the following:
    html file:
    <html>
    <body>
    <script language="JavaScript">
    function myTest() {
    try{
         document.myform.test.test();
    }catch(e){
         alert(e.description);
    function myTest1() {
    try{
         document.getElementById("test").test();
    }catch(e){
         alert(e.description);
    </script>
    <form name="myform">
    <OBJECT NAME="test" id="test" WIDTH=500 HEIGHT=120 CLASSID="CLSID:8AD9C840-044E-11d1-B3E9-00805F499D93">
    <PARAM NAME="code" value="Test.class">
    <PARAM NAME="scripting" value="true">
    </OBJECT>
    <input type="button" value="test !!" onclick="myTest()"><br>
    <input type="button" value="test with getelementbyID!!" onclick="myTest1()"><br>
    </form>
    </body>
    </html>
    applet:
    import java.applet.Applet;
    public class Test extends Applet{
    public void test() {
         System.err.println("test");
    public void init(){
         System.out.println("this is init");
    When you open the page it should say "this is init" in the java console
    if the test button doesn't work try the getElementById way.

Maybe you are looking for

  • Erro na J1BNFE (nota fiscal de entrada - categoria F1)

    Bom dia, Estou com um erro no monitor de nf-e, para uma nota de entrada - categoria F1: Os erros são: Erro de validação: Campo 44-Place Access Key: V11 (Campo ID) Erro de validação: Campo 44-Place Access Key: V06 (Campo ID) Erro de validação: Campo 4

  • Publishing to MobileMe

    There are two different instructions: on iWeb on publishing it instructs you to go to www.[membername].com/site name; on iWeb Help instructions it instructs you to go to http://web.me.com/membername/SiteName. Niether retrieves the site, why? I just p

  • TB Average and Dynamic Time series

    Hi, In our outline, we have Time dimension tagged ad Dynamic Time series. There few measures which have member formula attached, they are dynamic calc, two pass. Among these measures which are tagged as TB average and skip missing, we get zero for QT

  • FlashPaper2 WinXP BugFix

    WOW! How could Macromedia release FlashPaper with such a critical bug? This was so frustrating especially since there is no troubleshooting section for Flashpaper (online or in offline Help files) and because I just bought this NEW/IMPROVED software.

  • [HELP ]unexpected low memory usage

    Hi all, Could someone help me out with unexpected low memory usage I am facing when I start the DB instance. I am running Oracle 8.1.7.3.2 on Windows 2000 Adv Srv with 2GB of RAM and 3GB of swap area. I only have 1 instance with memory related init p