Results 1 to 6 of 6
  1. #1
    mitchj is offline Member
    Join Date
    Apr 2012
    Posts
    7
    Rep Power
    0

    Default Java script call to a Java method

    Hi,

    Can I call a Java method from Java script? If so how?

    What I am trying to do is I call a Java method from my xhtml page and that method returns a list. I need to process that list in my xhtml code but I don't know how to. Can anyone help?

    Thanks!

    mitchj

  2. #2
    jlczuk is offline Senior Member
    Join Date
    Apr 2012
    Location
    New York State of Confusion, USA
    Posts
    137
    Blog Entries
    1
    Rep Power
    0

    Default Re: Java script call to a Java method

    You cannot call Java from Javascript to the best of my knowledge. More importantly, where is the data from which this list is to be created? In what form were you expected to received the list from Java (if you could even do that) for your Javascript to process?

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java script call to a Java method

    Where is the 'java method'? Client? Server?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,574
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java script call to a Java method

    Quote Originally Posted by jlczuk View Post
    You cannot call Java from Javascript to the best of my knowledge.
    I googled a bit on this subject and it seems that you can call Java methods from Javascript; if the shebang is running in a browser you can call the methods of an Applet from Javascript and I even read about calling Java on the server side if Javascript happens to run there too. As always, google is our friend.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    mitchj is offline Member
    Join Date
    Apr 2012
    Posts
    7
    Rep Power
    0

    Default Re: Java script call to a Java method

    Quote Originally Posted by jlczuk View Post
    You cannot call Java from Javascript to the best of my knowledge. More importantly, where is the data from which this list is to be created? In what form were you expected to received the list from Java (if you could even do that) for your Javascript to process?
    I'm using JSF for this application.

    The data originates from a database. I have an EJB that makes the call to the database. Then I have a managed bean that has a reference of that EJB injected into it. When the user enters their id on the web page that id is passed to the managed bean (controller) which in turn makes a call to the EJB to read the database. All info from the database is stored in one object then I access that object to get pieces of info as I need to display them on the webpage. Some data is just one thing some is is stored as an arrayList.

    I don't really know if I need java script or not. I'm just trying to figure out how to process the arrayList in my xhtml page.

    I'm kinda new at this Java, JSF, etc stuff!

    Thanks for your help!
    mitchj

  6. #6
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java script call to a Java method

    Your explanation still doesn't make much sense as to what you want javascript to call (see my questions in the post above). If you wish to call the server from the client, then look into using AJAX.

Similar Threads

  1. Call Java Method in MS SQL
    By mexyz in forum New To Java
    Replies: 19
    Last Post: 02-17-2010, 01:38 PM
  2. How to call php script using Java
    By narik in forum New To Java
    Replies: 2
    Last Post: 01-22-2010, 05:08 PM
  3. Call java method from jsp
    By saiphani723 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-25-2009, 11:21 AM
  4. Call java Methods from Python Script
    By hofsoc in forum New To Java
    Replies: 1
    Last Post: 02-18-2009, 04:47 PM
  5. [B] How to call Perl script from Java [/B]
    By JavaEmpires in forum Advanced Java
    Replies: 7
    Last Post: 12-19-2008, 03:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •