Problem: launch javaBean method in Javascript?

I want to launch a method of javaBean in javascript, but it always occur errors.
the main code is as following:
<jsp:useBean id="getPropertyBean" class="mmes.BeanSetExamProperty" scope="page"/>
<html><head>
<script language="JavaScript" type="text/JavaScript">
function check(){
var kp_name,kp_code;
for(var i=0; i<10; i++){
kp_name = form1.selectedknowledgepoint.options.text;
kp_code = getPropertyBean.getCode(kp_name); //getCode(String name) is a method
// Just here, error occurs.
} //end of check()
</script>
Because kp_name is varible in function check(), So, how can I launch getCode()?

sigh...
JSP runs on the Server.
Javascript runs on the client.
JSP. Server
Javascript. Client
These things are not the same.
They can not communicate with eachother directly.
All of the JSP code runs when the the page is requested. It finishes, and sends the page back to the client.
THEN you can run javascript code at the client end.
The only way you have to invoke java/jsp code again is to send an http request by submitting a form/ clicking a hyperlink.
In short - you can't call Javabeans from javascript.

Similar Messages

  • Problem calling Java method from JavaScript in JSP / ADF

    Hi all,
    In my JavaScript onMouseUp() function, I need to call a method on my Java backing bean. How is this done? Info on the web indicates a static Java method can be called by simply "package.class.staticMethod(...)". but when I put the statement
    "jsf.backing.GlobalRetriever.createBasemap(affectedLayer);"
    I get an error message "jsf is undefined".
    The functionality I'm trying to get is: I have a custom slider control and based on its value, I want to call oracle map viewer specifying a map extent of the (current extent / slider value) to do a zoom in/out. In addition, the slider uses a onMouseMove() function to change the size of the image display so it looks like a dynamic zoom in/out.
    Please assist or let me know if I can provide some additional information. Thanks in advance.
    Jim Greetham

    No. The Java and Javascript in a Faces application are really working in two different universes.
    Java is running on the server. It generates HTML (and sometimes even Javascript) and sends that to the client machine. That's where all your backing beans are.
    Javascript runs directly in the browser. There's no way anything on the server can have access to anything you define in Javascript, unless you explicitly send that information back to the server, either via standard form submission (which only works when someone presses a "Submit" button) or via an Ajax-type call. So otherwise, nothing you define in Javascript will ever be available to a backing bean.

  • How to pass a javascript variable to a javabean method

    Hi
    I need to pass a String from a Javascript argument to a javabean method. localUrl will be instantiated with a string not from any form item(option box, textbox, etc) so cannot use
    String param = request.getParameter("XXX").
    My code below does not work as localUrl is not seen by javaBean and returns a null.
    function ShowWaitDisplay(localUrl)
    var Description = <%=RandomFeeds.getDescription(localUrl)%>;
    //Do something with the string Description
    Thanks
    Andrew

    Since, java bean code will be executed on the server side and java script executes on client side, by the time your javascript variable created, the bean code is already been executed.

  • Accessing a public method from javascript in an applet!!!

    Hi!!
    I'm have an applet (named say applet.class) in an html page that has a public method like this....
    public void doShowFrame()
              Frame frame = new frame();
         frame.setVisible (true);
    What I want to do is to call that method with javascript, I've tried to do it like this...
    function show(){
    applet.doShowFrame();
    But when i press the button that launch the java scipt the browser says
    'applet' is unidentified...
    What's wrong, what can I do??

    http://www.google.com/search?q=applet+javascript+communication&sourceid=opera&num=0&ie=utf-8&oe=utf-8
    how hard was that? seriously.

  • Problem launching Campaign from UI

    Hi All
    We have a problem launching campaign from UI screen,as when we try and launch the campaign from the screen
    following error is coming:
    Cannot display view BSPWD_BASICS/WorkAreaHostViewSet of UI Component CRM_UI_FRAME
    An exception has occurred Exception Class CX_SHM_OUT_OF_MEMORY - Insufficient Shared Objects Memory Available
    Method: CL_SHM_AREA=>_ATTACH_WRITE70
    Source Text Row: 2
    Error occurred during navigation
    An exception has occurred Exception Class CX_BSP_WD_RUNTIME_ERROR -
    Method: CL_BSP_WD_VIEW_CONTROLLER=>BIND_VIEW
    Source Text Row: 165
    Cannot display view BSPWD_BASICS/BreadCrumbView of UI Component CRM_UI_FRAME
    An exception has occurred Exception Class CX_BSP_WD_INV_VA_ASSIGNMENT - Assigned view in view area Root could not be loaded.
    Method: CL_BSP_WD_HIST_MANAGER_BASE=>GET_VIEW_ASSEMBLY
    Please suggest what should i do to correct this(we are working on CRM 2007)
    Any help will be highly appreciated
    Regards
    Ashish

    Hi,
    Would you please show your solutions? I am facing the same problem. Thanks!
    BR,
    Hao

  • 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);          

  • How to expose plugin methods to JavaScript ?

    Hi, let's assume I develop a plugin in C++ that performs some tasks with textual tokens within the Acrobat viewer. Can I access my plugin methods from JavaScript in order to launch these tasks from outside the Acrobat frame ?
    Thanks
    Frederic

    It's your plugin - you can do whatever you want and expose them however you wish.

  • Urgent--Problem in Date validations in Javascript.

    Hi ,
    I am facing problem in date validation in javascript.The requirement is my PO delivery date should be greater than my Sysdate.For that I wrote Javascript programme as below-
    function sysValidate(item){
                        var itemValue=item;
    // alert(itemValue);
    /* if((itemValue == '')||(itemValue == null))
    return false;
                        var today = new Date();
                        var sysDay = today.getDate();
                        var sysMonth = today.getMonth()+1;
                        var sysYear = today.getFullYear();
                        var fieldArray = itemValue.split("/");
                        var itemDay = parseInt(fieldArray[0]);
                        var itemMonth = parseInt(fieldArray[1]);
                        var itemYear = parseInt(fieldArray[2]);
    if(itemYear > sysYear)
    return false;
                        else{
                             if(itemYear < sysYear)
                                  return true;
                             else{
                                  if(itemMonth > sysMonth)
                                       return false;
                                  else{
                                       if(itemMonth < sysMonth)
                                            return true;
                                       else{
    if(itemDay >=sysDay)
    return false;
                                            else
    return true;
    Now inspit of my PO delivery date greater than sysdate ,while saving record I am getting Alert as Save denied as delivery date prior to sysdate
    The code for alert is as follows-
    if(sysValidate(exdate))
    alert("Save denied as delivery date prior to sysdate");
    bool=false;
    return bool;
    Plz,help.As this problem is occuring on Production Server due to this my suppliers can't save record.
    Vaish...

    hi Vaish,
    here is the code i have modified
    <script>
    function sysValidate(item){
    var itemValue=item;
    var fieldArray = itemValue.split("/");
    var today = new Date();
    var sysdate=new Date(today.getFullYear(),today.getMonth(),today.getDate(),0,0,0);
    var inputdate=new Date(parseInt(fieldArray[2]),parseInt(fieldArray[0])-1,parseInt(fieldArray[1]),0,0,0);
    alert("sysdate "+sysdate);
    alert("inputdate "+inputdate);
    days=Math.round((sysdate.getTime()-inputdate.getTime())/1000/60.0/60.0/24.0);
    if(days<=0)
         return true;
    else
         return false;
    </script>
    call the validate method form here :
    <script>
    if(sysValidate("07/24/2005"))
    alert("Save denied as delivery date prior to sysdate");
    else{
    alert("Saved successfully")
    }

  • How can launch an event in javascript?

    Hi, i´m doing an app in jsp, but i´m using a framework in javascript, css... my problem is... how can launch an event in javascript?
    I have a menu bar in javascript, and i want launch an event in each option, how?
    Thanks,

    Hi Victor,
    well, onMouseUp("blablup");
    I do not finally get your problem - do you want to send an event? So just add it to the URL and send the URL  -or do you want to excut the form? Why then not add the "event" to a hiden field in the form and execut that form then?
    In the handler you can ask for the details of the hidden field.
    I think it is not exactly what you are fter - but it could be that this is anyay a solution.
    Regards,
    Oliver

  • Problem with JavaBeans in JSP.IT'S URGENT!!!

    Hi, i have problems with JavaBeans in JSP.
    In a jsp file( locating in ROOT directory of tomcat 4.0.6 :jakarta-tomcat-4.0.6\webapps\root ) i have this code:
    <jsp:useBean id="paramBean" class="licentza.ParamBean" />
    <jsp:setProperty name="paramBean"
    property="nume"
              value='<%= request.getParameter("numeUser") %>' />
    where ParamBean it's a "bean" class locating in jakarta-tomcat-4.0.6\webapps\examples\web-inf\classes\licentza (licentza is the package i'm using).
    And i get this error:
    Generated servlet error:
    D:\jakarta-tomcat-4.0.6\work\Standalone\localhost\_\dora\intrare2$jsp.java:67: Class licentza.ParamBean not found.
    ParamBean paramBean = null;
    What is the problem?Thank you.

    Hi,
    Put the class file or the package under :jakarta-tomcat-4.0.6\webapps\root\WEB-INF\classes.
    Rajesh

  • 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

  • I have problem with pay method

    I have problem with pay method. My card declined. I change card and I have the same problem. What can i do? Why declined my card again?

    Contact iTunes store support: https://ssl.apple.com/emea/support/itunes/contact.html.

  • Very simple question: Call JavaBean method on page load?

    Someone clicks on a URL that contains parameters like: http://server/page.jsf?param=b
    How do I trigger a JavaBean method to run during page load? I see many JSF examples where JavaBean methods get called during form clicks and that works great but here I want to run code on page load.
    This must be really simple; sorry I'm new to this technology.
    Must I use <% ... %> syntax or can I use actual JSF tags or configuration to accomplish this?
    Thanks very much in advance!

    Putting a lot of logic in getter( ) function is not the best idea considering that getter( ) could be called all over the place. Using constructor for same purpose is also a bad idea especially with request scope beans. This could also happen many times at different stages. You are right, having a page load concept could be useful. Unfortunately JSF framework does not support. You could architect around it in case desperate. Or if using JSF implementation of certain vendors like IBM, you can take advantage of their implementation that was extended to support pageLoad and postBack events (similar to .NET).
    Many postings on this forum dealt with topic. Feel free to review like this one:
    http://forum.java.sun.com/thread.jspa?forumID=427&threadID=541382

  • 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.

  • Problem with traverse method

    Hi, I am having this problem:
    I made a CustomItem, a TextField, now I overloaded the traverse method, so if the keycode is Canvas.UP or Canvas.DOWN then return false else return true.
    The problem is that when I press the left or rigth button it also returns false and not true.
    and there is another problem with traverse, before returning false or true I set a boolean and call to repaint to draw it on some way if its selected or not, the paint method is being called but it just dont draw as desired.
    protected void paint(Graphics g, int ancho, int alto) {
              System.out.println ("Dentro del paint, seleccionado="+seleccionado);
              try {
                   g.drawString(label, 0, 0, Graphics.TOP|Graphics.LEFT);
                   if (!seleccionado) {
                        g.setColor(120, 120, 120);
                   g.drawRect(0, 4, tama�oTexto+8, 25);
                   if (seleccionado) {
                        g.setColor(255, 255, 255);
                        g.fillRect(1, 5, (tama�oTexto+8-1), 23);
                   g.setColor(0, 0, 0);
                   if (!seleccionado) {
                        g.setColor(80, 80, 80);
                   g.drawString(texto, 4, 7, Graphics.TOP|Graphics.LEFT);
                   if (seleccionado) {
                        int cursorX=Font.getDefaultFont().charsWidth((texto.substring(0, idLetraActual)).toCharArray(), 0, texto.substring(0, idLetraActual).length())+4;
                        g.drawChar('|', cursorX, 7, Graphics.TOP|Graphics.LEFT);
              } catch (Exception E){
                   E.printStackTrace();
         }the traverse method set the seleccionado variable and calls to repaint but instead of being false the paint method is drawing it as true (most of times).

    I have a problem with findByxxx() method.. in
    Container managed bean.
    i have
    Collection collection =
    home.findByOwnerName("fieldValue");
    specified in my Client Program, where ownerName is the
    cmp fieldname..
    and
    public Collection findByOwnerName(String ownerName)
    throws RemoteException, FinderException
    defined in my home interface.
    i have not mentioned the findBy() method anywhere else
    (Bean class). You have to describe the query in the deployment descriptor.
    >
    Even if i have a same "fieldValue" in the database
    (Oracle), which i specified in findBy() method, iam a
    result of owner Not found, which is not the case as i
    have that owner name.
    for the same application if i use findByPrimaryKey(),
    it is working..
    Can any one please post me the solution.

Maybe you are looking for

  • How to set a specific starting time for the falling snow code snippet

    Hi everyone I want to use the falling snow code snipet but I don't want it it to start as soon the movie starts. So how to set a specific time to start the falling snow? Thanks Patricia

  • BB z10 won't start up after updating to bb link

    I accidentally dropped my phone on the floor, and it won't start up. here are the following steps that i already did: 1. I already tried to update it on the bb link, after successfully updating i remove the usb cable, however  it didn't start up. eve

  • Connecting You View & Apple TV

    Hi Just received my new You view box which doesn't have a phone connection socket like my BT vision box had. I used that socket to connect my Apple TV to the internet. How would you suggest I do this now - Split the ethernet connection on the comtren

  • How do i update my ipad to mac osx 10.5

    In trying to sync my ipad with my macbook Pro for the first time i get the error message ipad can't be used baceuse it needs mac osx 10.5 or later. Help.

  • Start up screen has two part before comes one

    I have a small video (about a minute or less) with the problem I have with my MacBook Pro 13" screen start up, I would like to submited to the forum, I have call Apple Support and trying to splain the problem, but it is hard to splain, since they hav