?
Solved

Js call Applet function with parameters problem

Posted on 2009-05-15
9
Medium Priority
?
846 Views
Last Modified: 2012-05-07
Hello all,

Thank you for your time.
I am in need of calling a java applet function from a JS function, that much I am able to do so far but if I need to pass a parameter to the function then I keep getting:
"java.lang.IllegalArgumentException: No method found matching name FileChecker and arguments [java.lang.String]]."
The JS funtion is sending a String and the Applet function is set to receive a String parameter so I dont know what could be wrong.

I tried following the guidance of http://www.woodger.ca/js_jvint.htm but did not work on my end.

Please note, the function without passing any parameter is working fine.

What could be wrong here??
// JS part:
<script type="text/javascript">
function testJava()
{
	var sInput = document.frmJava.input.value;
	var sFile = document.FileChecker.FileChecker(sInput);
	alert(sFile);
}
</script>
 
 
//
// Java function
public String FileChecker(java.lang.String sFile) 
{
	return "Ok I got the parameter: " + sFile;
}

Open in new window

0
Comment
Question by:mespinozae
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24393221
Did you name the applet 'FileChecker' in your html?
0
 
LVL 10

Expert Comment

by:bugada
ID: 24393277
This error happens beacause in your applet class FileChecker there is'nt a corrisponding method FileChecker.
If your goal is to access the contructor, then you can't. You must call a public method.

Something like that

/* frontend side */
 
function testJava()
{
        var sInput = document.frmJava.input.value;
        var sFile = document.FileChecker.getFile(sInput);
        alert(sFile);
}
 
/* in your java class, assuming a string type return value */
 
public class FileChecker ... {
 
   public String getFile(String input) {
      ...
      return theFile;
   }
}

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24393293
Also make sure you're using the very latest version of the applet - you might need to clear the cache to do that
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 2

Author Comment

by:mespinozae
ID: 24393295
@CEHJ: Yeap, I did name the applet like that:


@bugada: I have my class named like that (and I recompile every time I test it to make sure I get the latest changes right)

Still no luck..

// html
<APPLET codebase="" name="FileChecker" id="FileChecker" archive="....

Open in new window

0
 
LVL 10

Expert Comment

by:bugada
ID: 24393305
Please reread carefully my post, and if yua have doubts take a look at this page:

http://www.rgagnon.com/javadetails/java-0170.html
0
 
LVL 10

Accepted Solution

by:
bugada earned 500 total points
ID: 24393341
The problem is not the name of your class, that I presume is right. You must call a *public method* of that class.
You can't call the class constructor, because the class is initialized when the JVM is starting up.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24393355
It certainly *looks* like a ctor but isn't - it returns String. Method names should be in camel case
0
 
LVL 2

Author Comment

by:mespinozae
ID: 24393430
@bugada: Of course!!! Im sorry I didnt read carefully your message, that was the problem! I hadnt realized my method name was also the class name so it of course turned out to be the constructor... silly me!

Thank you both very much for you help!


0
 
LVL 10

Expert Comment

by:bugada
ID: 24393434
If it isn't a contructor,  it's really a BAD name for a java getter method.

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question