How to call a static method from an event handler

Hi,
   I'm trying to call a static method of class I designed.  But I don't know how to do it.  This method will be called from an event handler of a web dynpro for Abap application.
Can somebody help me?
Thx in advance.
Hamza.

To clearly specify the problem.
I have a big part code that I use many times in my applications. So I decided to put it in a static method to reuse the code.  but my method calls functions module of HR module.  but just after the declaration ( at the first line of the call function) it thows an exception.  So I can't call my method.

Similar Messages

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • How to call jpf controller method from javascript

    Can any one help me how to call pageflow controller method from JavaScript.\
    Thanks.

    Accessing a particular pageflow method from Javascript is directly not possible unless we do some real funky coding in specifying document.myForm.action = xyz...Heres what I tried and it did not work as expected: I found another workaround that I will share with you.
    1. In my jsp file when I click a button a call a JavaScript that calls the method that I want in pageflow like this: My method got invoked BUT when that method forwards the jsp, it lost the portal context. I saw my returned jsp only on the browser instead of seeing it inside the portlet on the page of a portal. I just see contents of jsp on full browser screen. I checked the url. This does make the sense. I do not see the url where I will have like test1.portal?_pageLabe=xxx&portlet details etc etc. So this bottom approach will notwork.
    document.getElementById("batchForm").action = "/portlets/com/hid/iod/Batches/holdBatch"; // here if you give like test1.portal/pagelable value like complete url...it may work...but not suggested/recommended....
    document.getElementById("batchForm").submit;
    2. I achieved my requirement using a hidden variable inside my netui:form tag in the jsp. Say for example, I have 3 buttons and all of them should call their own action methods like create, update, delete on pageflow side. But I want these to be called through javascript say for example to do some validation. (I have diff usecase though). So I created a hidden field like ACTION_NAME. I have 3 javascript functions create(), update() etc. These javascripts are called onclick() for these buttons. In thse functions first I set unique value to this hiddent field appropriately. Then submit the form. Note that all 3 buttons now go to same common action in the JPF. The code is like this.
    document.getElementById("ACTION_NAME").value = "UPDATE";
    document.getElementById("batchForm").submit.
    Inside the pageflow common method, I retriev this hidden field value and based on its value, I call one of the above 3 methods in pageflow. This works for me. There may be better solution.
    3. Another usecase that I want to share and may be help others also. Most of the time very common usecase is, when we select a item in a drop bos or netui:select, we want to invoke the pageflow action. Say we have 2 dropdown boxes with States and Cities. Anytime States select box is changed, it should go back to server and get new list of Cities for that state. (We can get both states and cities and do all string tokenizer on jsp itself. But inreality as per business needs, we do have to go to server to get dynamic values. Here is the code snippet that I use and it works for all my select boxes onChange event.
    This entire lines of code should do what we want.
    <netui:anchor action="selectArticleChanged" formSubmit="true" tagId="selectPropertyAction"/>                    
    <netui:select onChange="document.getElementById(lookupIdByTagId('selectPropertyAction',this )).onclick();" dataSource="pageFlow.selectedArticleId" >
    <c:forEach items="${requestScope.ALL_ARTICLE}" var="eachArticle">
    <%-- workshop:varType="com.hid.iod.forms.IoDProfileArticleRelForm" --%>
    <netui:selectOption value="${eachArticle.articleIdAsString}">${eachArticle.articleItemName}</netui:selectOption>
    </c:forEach>               
    </netui:select>
    See if you can build along those above lines of code. Any other simpler approches are highly welcome.
    Thanks
    Ravi Jegga

  • How to call backing bean method from java script

    Hi,
    I would like to know how to call backing bean method from java script.
    I am aware of serverListener and [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    but i am running in to some issues with [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    regarding which i asked for help in other thread with subject ....Question on AjaxAutoSuggest article (Ajax Transactions Using ADF and J...)
    The reason why i posted is ( though i realise both are duplicates) .. that threads looks as a specific question to that article hence i would like to ask the quantified problem is asked in this thread.
    So could any please letme know how to call backing bean method from java script
    Thanks
    Murali
    Edited by: mchepuri on Oct 24, 2009 6:17 PM
    Edited by: mchepuri on Oct 24, 2009 6:20 PM

    Hello,
    May know how to submit a button autoamtically on onload of page with clicking a welcome alert box. the submit button has managed button too to show a message on console using SOP.
    the problem is.
    1. before loading the page a javascript comes on which i clicked ok
    2. the page gets loaded and the button is there which gets automatically clicked and the managed bean associated with prints a message on console using SOP.
    I m trying to do this through server listener and click listener. the code is(adf jspx page)
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_check4.d1}">
    <af:form id="f1" binding="#{backingBeanScope.backing_check4.f1}">
    <af:commandButton text="commandButton 1"
    binding="#{backingBeanScope.backing_check4.cb1}"
    id="cb1" action="#{beanCheck4.submit1}"/>
    <af:clientListener type="click" method="delRow"/>
    <af:serverListener type= "jsServerListener"
    method="#{backingBeanScope.backing_check4.submit1}"/>
    <f:facet name="metaContainer">
    <af:resource type ="javascript">
    x=confirm("hi");
    // if(x){
    delRow = function(event){
    AdfCustomEvent.queue(event.getSource(), "jsServerListener", {}, false);
    return true;
    </af:resource>
    </f:facet>
    </af:form>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_check4-->
    </jsp:root>
    the backing bean code is -----
    public class classCheck4 {
    public classCheck4() {
    public String submit1() {
    System.out.println("hello");
    return null;
    }

  • How to call a static method in a class if I have just the object?

    Hello. I have an abstract class A where I have a static method blah(). I have 2 classes that extend class A called B and C. In both classes I override method blah(). I have an array with objects of type B and C.
    For every instance object of the array, I'm trying to call the static method in the corresponding class. For objects of type B I want to call blah() method in B class and for objects of type C I want to call blah() method in C class. I know it's possible to call a static method with the name of the object, too, but for some reason (?) it calls blah() method in class A if I try this.
    So my question is: how do I code this? I guess I need to cast to the class name and then call the method with the class name, but I couldn't do it. I tried to use getClass() method to get the class name and it works, but I didn't know what to do from here...
    So any help would be appreciated. Thank you.

    As somebody already said, to get the behavior you
    want, make the methods non-static.You all asked me why I need that method to be
    static... I'm not surprised to hear this question
    because I asked all my friends before posting here,
    and all of them asked me this... It's because some
    complicated reasons, I doubt it.
    the application I'm writing is
    quite big...Irrelevant.
    Umm... So what you're saying is there is no way to do
    this with that method being static? The behavior you describe cannot be obtained with only static methods in Java. You'd have to explicitly determine the class and then explicitly call the correct class' method.

  • Calling a static method from another class

    public class Command
        public static void sortCommands(String command, String order, List object)
             if(command.equalsIgnoreCase("merge") && order == "a")
                  object.setAscending(true);
                  Mergesort.mergesort(object.list);                  // line 85
    }and
    public class Mergesort
         public static void mergesort (int[] a)
              mergesort(a, 0, a.length-1);
         private static void mergesort (int[] a, int l, int r)
         private static void merge (int[] a, int l, int m, int r)
    }Error:
    Command.java:85: cannot find symbol
    symbol : variable Mergesort
    location: class Command
    Mergesort.mergesort(object.list)
    What am I doing wrong here? Within the Command class I am calling mergesort(), a static method, from a static method. I use the dot operator + object so that the compiler would recognize the 'list' array. I tried using the
    Mergesort.mergesort(object.list);notation in hopes that it would work like this:
    Class.staticMethod(parameters);but either I am mistaken, misunderstood the documentation or both. Mergesort is not a variable. Any help would be appreciated, I have been hitting a brick wall for hours with Java documentation. Thanks all.

    [Javapedia: Classpath|http://wiki.java.net/bin/view/Javapedia/ClassPath]
    [How Classes are Found|http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html]
    [Setting the class path (Windows)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html]
    [Setting the class path (Solaris/Linux)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html]
    [Understanding the Java ClassLoader|http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html]
    java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
    javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

  • How to call a set method from within a constructor

    Hello,
    I want to be able to call a set method from within a Scanner, to be used as the argument to pass to the Scanner (from a source file). Here's what i tried:
    private void openFiles()
            input = new Scanner( setSource );              
        and here is the set method:
    public String setSource( String in )
            source = in;
            return source;
        }obviously there will be more code in this method but i'm trying to tackle one problem at a time. Thanks in advance..

    The "String in" declaration says: "Nobody may ever invoke setSource() without specifying a certain String. The content of the String is known at run-time only."
    In no place in your code you say the compiler: "I want the 'in' variable (actually, parameter) of method setSource() to contain the first arg which is passed to the application".
    This is exactly the same mechanism allowing you to write "new Scanner" with something inside the two parentheses.

  • How to call an ejb method from jsp?

    Hi, everyone!
    Inside my JSP, I4m using scripts in order to show and receive information, that is, a form.But I don4t Know if I can use the same variables from the script in order to call the 'set' methods from my EJB.
    Could anyone show me an example?
    Thanks in advance,
    Silvia

    InitialContext ctx = new InitialContext();
         GeneralEditor editor = (GeneralEditor) ctx
                        .lookup("GeneralEditorBean/remote");
              GeneralService service = (GeneralService) ctx
                        .lookup("GeneralServiceBean/remote");
              LanMu lm = new LanMu();
              lm.setName("shdfkhsad");
              editor.add(lm);

  • How to call a EJB method from Session bean method

    Hi all,
    I'm new to J2EE programming. I have a simple doubt .
    I have already created a lookup method for EJB bean in Session bean .
    My question is how to call a method of an ENTITY bean (say insertRow) from SESSION bean method(Say invoke_insertRow) .
    Please provide me an example code .
    Thanks in advance.

    InitialContext ctx = new InitialContext();
         GeneralEditor editor = (GeneralEditor) ctx
                        .lookup("GeneralEditorBean/remote");
              GeneralService service = (GeneralService) ctx
                        .lookup("GeneralServiceBean/remote");
              LanMu lm = new LanMu();
              lm.setName("shdfkhsad");
              editor.add(lm);

  • How to call Backing Bean method from href tag in JSF. -- URGENT

    Hi guys,
    i am new to JSF. i want one option. how to call a backing bean method from href.
    I searched a lot. i found one component <commandLink>, but i cann't use <commandLink> i have to use only href which is client instructions.
    If anyone knows pls help me. Its Urgent. If u can, give me the code also.
    Suggestions will be appreciated.
    Thanks
    Rajesh

    You can make use of the constructor of the backing bean or the @PostConstruct annotation if you want to use managed properties.
    You may get some ideas out of this: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html].

  • Call to pl/sql from java event-handler

    How can I call pl/sql procedure or function from java-script event handler
    Thanks,
    Anna

    Anna,
    You cannot call any arbitrary PLSQL code from the forms, only "standard"/custom event handlers can be called through do_event Javascript fuction, syntax :
    do_event(this.form,this.name,1,'ON_CLICK,'');
    where:
    1 - button intstance, if you have more than one instance of the same button on the screen this should be 2,3,4.....
    'ON_CLICK' - is the predefined event type
    '' - the last argument is any user defined string which will passed down to the PLSQL event handler.
    Thanks,
    Dmitry
    null

  • How to call a static method of a class from another class?

    Hello,
    I have two classes in a package. The first one
    package my package;
    public class class1
    protected static ImageIcon createIcon(String path)
    The second one
    package my package;
    public class class2
    private ImageIcon image1;
    image1 = class1.createIcon("/mypath");
    This does not work since class2 cannot load the appropriate image. Where do I have to define the ImageIcon variables in class one or two and do they have to be static variables?
    Thanks in advance
    Christos

    If the two classes are in the same package, that will work, in fact. A trivial example:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    // Note: Member of the same package
    package foo;
    public class Foo2 {
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }However, if they are in different packages that won't work - the protected keyword guarantees that only classes derived from the class with the protected method can access it: Therefore this will not work:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    package foo.bar;
    public class Foo2{
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }But this will:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    package foo.bar;
    public class Foo2 extends foo.Foo1 {
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }I think you should read up a bit more about packages and inheritance, because you're going to have a lot of trouble without a good understanding of both. Try simple examples first, like the above, and if you hit problems try to produce a simple test case to help you understand the problem rather than trying to debug your whole application.
    Dave.

  • How to call a bean method from html component in jsf

    hi all
    i need a solution for this problem of mine.. actually em working on a jsf application with contains a jsf-jsp having a span containg html button inside my javascript. i want to call a method on click of this button and fetch some data which i have already populated in my bean.how do i do this??? i hv attached a piece of code of d same...
    <script language="JavaScript" type="text/javascript">
    function test(form){
    var Title="DEBIT, gift, Request, TICK";
    var Span=document.createElement("Span");
    Span.style.position="absolute";
    Span.style.left=(parseInt(110)-5)+"px";
    Span.style.top=(+parseInt(274)-5)+"px";
    Span.style.backgroundColor='Red';
    var next=document.getElementById("forImage");
    next.innerHTML="<img src='http://127.0.0.1:9000/action=clusterserve2dmap&sourcejobname=myjob_clusters' />";
    Span.innerHTML="<[input type='button' >";
    document.getElementById("forImage").appendChild(Span);
    any help is highly appreciated

    Hi,
    this gonna be a hack, but here's how it could work
    - you create a Servlet that accesses the FacesContext to obtain a managed bean
    - you issue a XmlHttpRequest from the button to your servlet to obtain the payload
    - show the retrieved values in your HTML
    see http://www.thoughtsabout.net/blog/archives/000033.html for the middle part
    Frank

  • HOW TO CALL A JSP METHOD FROM ANOTHER JSP

    Hi all, I have to JSP1 and JSP2 and i would like to call a method of JS1 from JSP2. Is that possible ??
    Example:
    JSP2 Code
    somewhere in the code ...
    String s = JSP1.getName();
    out.println("EL NOMBRE ES " +s );
    thanks in advance for your help

    No, it is not possible. Infact you cannot write your own methods in JSP. What ever you write in a jsp page is part of _jspService() method. Secondly how can you instantiate another class(generated by JSP), until or unless you know the name of the class that resulted from your JSP. Your JSP page is first converted into .java file which is stored in some package e.g.
    pagecompile.jsp._yourJSPfile.
    I couldnot understand why you need to invoke a method of another JSP in your JSP.
    Hope this helps

  • How to call a static method of a class (continued)

    In reference to the above topic posted one week ago I give you the relative code. The problem is resolved and it was the following one (amazing for me since I looked for any possible error in the code like the one posted in my article but I could never imagine this trivial thing.........):
    the package name which is the directory with the appropriate class files should not extend the lenght of 8 characters!!! Initially I had a package named Applications (too long for DOS...) and when I renamed it to Test everything worked. Any suggestion on how to overcome this DOS filesystem problem?
    Christos
    Here is my simplified code
         package test;
         import java.io.*;
         import java.net.URL;
         import javax.swing.*;
         import java.beans.*;
         import java.awt.*;
         import java.awt.event.*;
         public class myapplet extends JApplet
         private MyClass myframe;
         private JDesktopPane desktop;
         private Dimension d;
    public void init() {
    myframe= new MyClass();
    desktop = new JDesktopPane();
    d=desktop.getSize();
    try {
    javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
    public void run() {
    createGUI();
    } catch (Exception e) {
    System.err.println("createGUI didn't successfully complete");
         private void createGUI() {
         myframe.pack();
         myframe.setBounds(0,0,d.width,d.height);
         desktop.add(myframe);
         this.getContentPane().add(desktop);
         try {
         myframe.setMaximum(true);
         } catch (PropertyVetoException e) {
         e.printStackTrace();
         myframe.setVisible(true);
    protected static ImageIcon createAppletImageIcon(String path,
    String description)
    int MAX_IMAGE_SIZE = 75000; //Change this to the size of
    //your biggest image, in bytes.
    int count = 0;
    BufferedInputStream imgStream = new BufferedInputStream(
    myapplet.class.getResourceAsStream(path));
    if (imgStream != null)
    byte buf[] = new byte[MAX_IMAGE_SIZE];
    try {
    count = imgStream.read(buf);
    } catch (IOException ieo) {
    System.err.println("Couldn't read stream from file: " + path);
    try {
    imgStream.close();
    } catch (IOException ieo) {
    System.err.println("Can't close file " + path);
    if (count <= 0) {
    System.err.println("Empty file: " + path);
    return null;
    return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buf),
    description);
    } else {
    System.err.println("Couldn't find file: " + path);
    return null;
    followed by the class MyClass
    package test;
         import javax.swing.*;
         import java.awt.*;
         import java.awt.event.*;
         public class MyClass extends JInternalFrame
         private JLabel jl;
         private String myicon1="images/myimage.gif";
         private ImageIcon image1;
         public MyClass()
         super ( "This is my application",false,true,true,false);
         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    image1= myapplet.createAppletImageIcon(myicon1,"");
    jl = new JLabel("This is my image",
              image1,JLabel.CENTER);
    jl.setFont (new Font("Times-Roman",Font.BOLD, 17));
    getContentPane().add(jl);
    and finally the html file with the applet tag:
    <APPLET CODE = "test.myapplet" width=760 height=380>
    </APPLET>

    I have to say that everything works fine even with
    long package names besides the loading of the image in
    MyClass (in fact you see the JInternalFrame with the
    JLabel without icon!). Since I never saw an error in
    the Sun Java Console or the DOS window I tried this
    last solution, i.e. to shorten the package name. Only
    then the icon appears in the label......strange thingsThere shouldn't be a problem with long package (and hence long directory) names.
    private String myicon1="images/myimage.gif"; // which becomes the 'path' variable below
    BufferedInputStream imgStream = new BufferedInputStream(
    myapplet.class.getResourceAsStream(path));So are you sure you are always putting this images subdirectory underneath where your myapplet class lives? If myapplet.class lives in /foo/bar/mypackage, belongs to the 'mypackage' package, and your classpath includes /foo/bar, then your gif file better be at /foo/bar/mypackage/images/myimage.gif (or actually at mypackage/images/myimage.gif from any classpath root)

Maybe you are looking for

  • Chat room test

    Last weekend I finally got my camera to be recognized by iChat. During the weekend I tried to set up my girlfriend and brother with an account and make a connection. Me--iChat and iSight with AIM, they, PCs with digicams with USB set to pc camera. It

  • Lines in pdf format

    Hi I have a report and in the template i have made only top lines of the frames visible for group breaks . This is working fine in the reports where each group is being seperated by a line( top edge of the frame) However when i convert this into pdf

  • Can't see files in folders

    I have one user who cannot see any files in folders on Sharepoint. She can see the folders themselves, and any file not in a folder, but gets a 'page cannot be displayed' when she clicks on any folder. We have granted her full access but still the pr

  • Returned Checks

    Hello friends, How will the following configuration be done related to returned checks. WHere will the returned checks be posted in SAP. Which transaction will be used to post them. A listing of customer checks dishonored by the customers bank and re

  • Update BBP_PDBEI BE_DOC_TYPR

    Hi all, Any ideas how i can update the field BP_DOC_TYPE, due to an error in PPOMA_BBP we have a "ec" instead of "EC" therefore all the carts failed to go over to ECC. Any help on this would be greatful. Regards Steve