Menu

Executing JavaScript-Function on ButtonClick

NikiG
2007-12-03
2013-04-24
  • NikiG

    NikiG - 2007-12-03

    Hello!

    Is there a way to call a javascript function, which is defined in a file on a button click or with Hyperlink.loadLocation?

    thanks!

     
    • Nobody/Anonymous

      You can call a function with:

      final WebApplication currentWebApp = (WebApplication)Application.current(); 
      //only need to do this once
      currentWebApp.clientSideIncludeFile("myJavascriptFunctions.js");

      Later on to call your functions:
      currentWebApp.clientSideMethodCall(...)
      currentWebApp.clientSideMethodCallWaitForReturn(...);

       
    • NikiG

      NikiG - 2007-12-06

      Thanx, but can you explain how to use it.
      I dont have a form to submit, this is the action i want to execute:
      function throwsapevent() {
        document.[here would be a form].action = "SAPEVENT:CLOSE";
        document.[here would be a form].submit();
      }
      So which Arguments do I have to add to the method clientSideMethodCall?

      Thanks a lot for your help!

       
    • Nobody/Anonymous

      Not an expert on javascript, you may want to search the forums for other answers:
      http://sourceforge.net/forum/message.php?msg_id=4156540

      You could also just display the page you want in a webrowser component.

       
    • Nobody/Anonymous

      After a few hours I found the solution:
      I created a .js file:

      function throwsapevent(id) {
        document.write("<form name=\"sapevent\">");
        document.sapevent.action = "SAPEVENT:CLOSE";
        document.sapevent.submit();   
      }

      Imported the file at the beginnen of the webapp:

      final WebApplication app = (WebApplication)Application.current();
      app.clientSideIncludeFile("close_sapevent.js");

      Calling the Method:
      final WebApplication currentWebApp = (WebApplication)Application.current();               
      currentWebApp.clientSideMethodCall((Integer)null, "throwsapevent", new Object[]{});

      Maybe another one can need it in future...

      Thanx for you help!

       

Log in to post a comment.

MongoDB Logo MongoDB