Using a JavaScript function as a listener

Problem with the original Java plug-in system. Most all my customers are forced to use the original Java plug-in (not the Next-Gen). So, I need a solution that works for the original please.
JavaScript:
applet.addActionListener({
    actionPerformed: function(evt) {
        alert("Heard the event!\n" + evt.toString());
Java Applet (snippet):
private JButton pushButton;
public void addActionListener(final JSObject jsl) {
    // Wrap the JSObject in an ActionListener.
    ActionListener l = new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            jsl.call("actionPerformed", new Object[] { evt });
    // Add the JS listener to the button so it gets informed of clicks.
    pushButton.addActionListener(l);
}This works fine if I could use the Next-Gen plug-in, but as I mentioned earlier, I am prohibited from using that.
Oddly enough, this code seems to work in IE, but it fails in Firefox. In Firefox while the JSObject itself is not equal to null, calling "toString()" on it returns "null". Thus, the call to "call(...)" does nothing and the JS function is never called.
In IE, it may be necessary to use a full-fledged class to store the reference to the JSObject. The "final" keyword should preserve it, but sometimes it doesn't.
public class JSActionListener implements ActionListener {
    private final JSObject jsObj;
    public JSActionListener(JSObject jsObj) {
        this.jsObj = jsObj;
    public void actionPerformed(ActionEvent evt) {
        jsObj.call("actionPerformed", new Object[] { evt });
public void addActionListener(final JSObject jsl) {
    // Wrap the JSObject in an ActionListener.
    ActionListener l = new JSActionListener(jsl);
    // Add the JS listener to the button so it gets informed of clicks.
    pushButton.addActionListener(l);
}

I'm such a moron. I never put in a trace command to see if
the last line of my shrink command was getting executed. It turns
out the movie doesn't scale perfectly to 16.5 but instead goes to
16.49etcetc. As a result that last line wasn't being executed. Now
everything works. But I was wondering if you guys could think of a
nice way to compartmentalize all of this code, like maybe store it
all in a variable or something, so I can attach it to several
different movie clips?

Similar Messages

  • How to make use of javascript functionality in WD application?

    hi,
    I want to use some javascript functionality in my web dynpro application.
    This is my requirement:
    I want to design templates for User's ID card.
    For that , I need to use label, image area, headings in that template as drag and drop objects(so that we can move the lable, image fields whereas we want in that template area).
    We have already done this scenario by using javascript.
    How could it be possible in web dynpro?
    Can I use the existing javascript in my WD application?
    Anyone Pls suggest me.
    Thanks.

    hi Abdul,
    in addition you could read documentation on the popupmenu, you can find here:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/de/416d42ab7fd142e10000000a1550b0/frameset.htm
    BTW: This only works for NW2004s (-;
    Kind regards
    Stefanie

  • Captivate_DoExternalInterface - Has anyone used this JavaScript function?

    I noticed in the SCORM_utilities.js file there was a function named:
    function Captivate_DoExternalInterface() {
    Has anyone tried to use this JavaScript function from inside a course, such as to update the value for the current "bookmark" of where the student is in the course?

    Yes, I've seen various posts over the years with folks who use that to make specific LMS calls.
    It can be done...
    Here for example, though a bit old:
    Google Groups
    Search the web for that function and I'm sure you'll find at least a few examples...

  • Hello, My web site is using the javascript function transformDocument but it looks like it doesn't working in version 6

    Hello,
    My we site is using a lot of ajax, and I have a function transformDocument that it doesn't works in version 6.
    Please help!!!

    Thanks a lot!!

  • Using external javascript functions

    So I have a couple of scripts that I use to create a 360 image rotation and an auto rotate on page load that I use before animating them in Edge Animate.  Here's an example of what I mean. the 360 rotation is just cycling through a series of images to create a rotating effect every certain number of pixels the mouse is dragged. To make the autoplay, I use an extended version of jquery-ui to simulate a mouseclick and drag.
    Now this works well without bringing in the html into Edge Animate, but what I want to do is to be able to enable the autoplay after animating an image in Edge. So the call to start the autoplay is this.
    <script>
    $('#product').simulate("drag-n-drop", {dx: 300, interpolation: {stepWidth: 10, stepDelay: 50}});
    </script>
    So with the javascript libraries in referenced in my html already, would I right in saying that all I would have to do is add that script as a trigger on my timeline?

    Load all the script files using the script loading option in Edge Animate
    Than if the are using the right query element ,i think the above code should work

  • Using a javscript function in a jsp embedded in another jsp

    Hi All,
    I have 2 jsp's say, a.jsp and b.jsp. I am using the b.jsp in a.jsp using the
    <jsp:include page="b.jsp" /> in a.jsp
    Now i am having a javascript function test() in a.jsp. Can i use this javascript function in b.jsp also. I just want the output of this function to be used in b.jsp also. So is there a way i can use it or should i write the function again in b.jsp?
    Thanks in advance!!!!!!

    Javascript only intercepts on the generated HTML output at the client side, not on the server side JSP code. If the function is there in the HTML output, you can just use it.

  • JavaScript functions in ADFLib - jdev 11.1.2.3

    Hello:
    I would like to create an ADF Library that has many JavaScript functions and any application that adds this ADF Library to its project should be able to use the javascript functions.
    Or is there a better way to accomplish this?
    I'm following the Enterprise Structure of creating ADFLibs for : Common Code, Common Model, Common UI
    Subsystems then import these ADFLibs
    The Master app, imports the ADFLibs and the Subsystems and uses subsystem taskflows in the Master to complete the application.
    In my case, I would like to execute the same JavaScript in both the Subsystem and the Master. So I think I should put the JavaScript in the Common UI adflibrary or what???
    What is the best way to structure this to be able to reuse the Javascript in multiple apps?
    Is there any articles/samples that you can reference?
    Thanks for the help.

    Thanks...
    I have watched this video. It was very helpful but not seemingly enough for this issue.
    My first try was to put the JavaScript in the CommonUI, but then I could not figure out how to reference it in the adflib as the JavaScript library is relative to the context path. So I still have not figured this out yet.
    Thanks for the help.

  • Calling javascript function with pressing button

    Hello,
    I would like to enable an item on my page wihic is disabled before.
    I should use a javascript function.
    I wrote in the page HTML Header:
    <script language="JavaScript1.1" type="text/javascript">
    function enFormItems(item1){
    enItem = document.getElementById(item1);
    enItem.style.background = 'white';
    enItem.enabled = true;
    </script>
    I would like to call this funtion when i press a button.
    How can i do that? It is possible?
    Thank You

    Zoltan,
    Have the button redirect to a url and enter the following for the url:
    javascript:enFormItems('PXX_ITEM_NAME');Regards,
    Dan
    http://danielmcghan.us/
    http://sourceforge.net/projects/tapigen/

  • Select tag with JavaScript function

    I am using a selectOneMenu tag for navigation. After the selection I use a button to go to the selected page. I would prefer to go to the selected page without using an additional button. I think I have to use a JavaScript function with the attribute "onchange". How does this JavaScript function look like?

    I use something like this, it works fine
    <h:selectOneMenu id="selectedEndorsement" valueChangeListener="#{engageListServiceBean.changeEndorsement}" value="#{engageListServiceBean.selectedEndorsementNum}" onchange="submit()">

  • Browser Javascript call Acrobat Javascript function

    What I want to do is call a function in Acrobat Javascript by clicking a button in my browser.
    So if you click the browser button it executes a javascript function that calls an acrobat javascript function.
    I found this example:
    Browser javascript
    function printDocument() {
         var pdfObject = document.getElementById(\"PDFObj\");
         pdfObject.postMessage([\"alert\", \"Hello from HTML\"]);
    Acrobat javascript
    In the secure folder (C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Javascripts\kassa.js) my folder level script
    so this is executed for each pdf document.
    this.hostContainer.messageHandler =
         onMessage: function(aMessage)
              for(var i = 0; i < aMessage.length; i++)
              console.println("Recvd Msg[ " + i + "]: " + aMessage[i]);
          onError: function(error, aMessage){ },
          onDisclose: HostContainerDisclosurePolicy.SameOriginPolicy
    This should do the job...
    But if i look at the javascript debugger window(acrobat)
    it shows:
    this.hostContainer has no properties
    9:Folder-Level:App:kassa.js
    this.hostContainer has no properties
    9:Folder-Level:App:kassa.js
    Any solution for my problem?

    hi levi,
    Thank u very much for responding,
    to be precise i have to show the user a small window saying that the excel sheet is being prepared and once the sheet is prepared this window has to be closed. So to open and close this child window i need to use the javascript functions.
    currently my jsp looks this way
    <script>
         function open()
         funciton close()
    </script>
    <body>
    <script>
         open();
    </script>
    include x.jsp //sets the content type to excel
    include y.jsp //writes to the excel sheet
    <script>
         close();
    </script>
    <body>
    My x.jsp looks this way
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "filename=" + "abc.xls");
    response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader("Expires",0);
    response.addHeader("Cache-control", "no-store");
    response.addHeader("Cache-control", "max-age=0");
    The issue is the javascripts are not getting called at all. Is there any other way to solve this. Since i am the beginner in this field i dont have much idea about this. A code snippet will be of great help.
    Thanx

  • How to pass value to pop up window using javascript function?

    I am not sure how to do this, I want to open new window from existing form,This is Mod/PLsql for consists some javascript functions also. When I am clicking on new window in form then new form should open with results of value entered,but new window form is opening with main page :( , not able to get text box value from parent form. How to call textbox input value in popup window from parent window using javascript?
    currently I'm using following code:
    HTP.p('<script type="text/javascript">
    function pop_up5()
    var l_url=window.opener.document.getElementById("p_single_store_pc").value;
    window.open(l_url, '''', ''fullscreen=no, scrollbars=1'');
    </script>' );
    Edited by: user11970612 on Jun 14, 2012 5:02 AM

    this is probably due to the Javascript code and not a "real link" to another page... I don't know if the null is due to the Javascript...
    But if you really really want to use javascript instead of a ... you can pass the location of the url with JSP (on your main page) as a parameter to the open window... (...) u can put instead of main.jsp <%= request.getServerName()+request.getRequestURI() %>
    the value <%= ... %> will return something like test.com/html/main.jsp
    Hope this helps.

  • How to use a Session object in a Javascript function

    I have an object that I have set in my session.
    On my jsp I want to pull it out of my session and use it as a parameter for a javascript function. But I am not sure how to do that... the function call is below... I want to assign a value to ifFormat (last variable in function) But I am not sure what to use inside javascript.
    <script type="text/javascript">
         Calendar.setup({inputField:"f_date_dfFirstPmtDate",
                                              button:"f_trigger_dfFirstPmtDate",
                                             singleClick:true,
                                              ifFormat:XXXXX});
    </script>

    Note that javascript runs on the client side, and JSP runs on the server. JSP and the session objects are NOT available to javascript in reaction to the user.
    If this function is called only when the page is first created, not when the user interacts with the page, or if you want that value to be constant with respect to the javascript, then you can do this:
    <%
      String someValue = (String)session.getAttribute("theAttributeName");
    %>
    <script type="text/javascript">
         Calendar.setup({inputField:"f_date_dfFirstPmtDate",
                                              button:"f_trigger_dfFirstPmtDate",
                                             singleClick:true,
                                              ifFormat:<%=someVale%>});
    </script>

  • Using Javascript function to change the value of a request variable

    Have a javascript function that activates onchange within a form variable. Would like the javascript function to change the value of a request variable.
    The javascript function is able to obtain the current value of the request variable ( which is 0 ) however I am unsuccessful in changing the value to 1.
    I have been trying to use the following:
         var vchange = 'request.changes_made = 1 ;' ;
         eval(vchange);
    Any ideas?

    If the user makes a change to the content of the form, and then attempts to leave the form, a javascript alert pops up giving the user the option of cancelling the submit, returning to the form and saving it.
    If there have been no changes, then the user is free to migrate to another page.
    This process is to protect users from losing valuable information but not to annoy them with "R U Sure" messages.
    Knowing the status of the form content is important to the functionality of the application.
    G

  • How to use javascript functions in struts jsp page

    hi
    iam using struts jsp pages. here iam calling one javascript function. but iam not able to access the form in javascript.
    wat i have to give as form name to get the elements of the form.
    please reply me soon
    it is urgent
    vamsi

    your form has no name liek this one:
    <html:form action="/userRegistration.do" >so you cannot access the elements inside your form?
    accessing the elements inside the form will be like this:
    document.forms[0].propertyName.value;

  • Using Javascript Functions with Flash 8

    I wanted to know how to integrate Javascript functions with
    Flash 8 created swf files. I assume this would be done using
    ActionScript, I know some ActionScript but am not as familiar with
    it as to be able to integrate other programming languages with it.
    I'd like to be able to call other programming language functions
    with my swf files.
    The particular case I'm working on now is to be able to open
    Pop-Up windows for display of web items from within links written
    in ActionScript in a swf file. In other words, have the user click
    a link in a Flash movie and open a window using a Javascript
    window.open function that would be called. I would like the window
    to contain more flash movies that contained further links to
    functions. If any one could offer up some advice or point me to a
    few tutorials and how tos on how to get the Flash part of this done
    I'd appreciate it.
    In a broader scope, a seemless workflow linking Flash output
    files to outside scripting and programming functions would be nice
    to know if anyone has links or input on where I can read up on
    this.
    Thanks

    myButton.onRelease = function () {
    getURL("javascript:myFunc('myVars')");
    }

Maybe you are looking for

  • How re-install OS X Lion fresh without disks?

    Something is wrong with programs or something on my Mac and I want to completely wipe the hard drive and start over with a fresh copy of Lion.  I did a Time Machine backup last night and will then just bring over files one at a time from that externa

  • ITunes Syncing Errors under iOS6 on iPhone 4

    when I have my iPhone4 (with iOS6 installed) sync with iTunes for updated apps, I always get errors from iTunes telling me some apps are not synced and they will be a such state that tapping them won't open because they are in updating-mode if you kn

  • Creative MediaSource/Search for Freew

    Didn't see a software section, but figure a lot of us would have this beaut of an app included with their player, and wondered if anyone acually used it. I assume most of you ignored this app as all of its features come stock with a new PC, and you m

  • Streaming a downloaded movie onto Apple TV

    I downloaded a movie from the internet of which the files are in vob format. I can play the movie fine on my iMac through DVD player. How can I stream this this movie to my HDTV through Apple TV using Airplay? Home Sharing is turned for both the iMac

  • Best photo printer under $400?

    I'm looking for a high quality but relatively inexpensive photo printer. I want to display my high school photography students' photos in the main hallway cabinet of our administration building. The printers we have on campus are not up to par, and I