Solved

Sahi scripting

Posted on 2010-08-24
4
483 Views
Last Modified: 2012-05-10
Adding this line: var $Array2 = getLinks();
to my code the "undefined variable" problem is gone. Now I have a different problem, with java I believe. My code:
var $Array1 = new Array("3 Face Blend on Mixed Walls", "Assimilation Blend Support", "Detect Loss of Blend Overflow");
function getLinks(){
      var $retVal = new Array();
      var $links = document.links;  
      for (var $i=0; $i<$links.length; $i++){
            $retVal[$i] = $links[$i].innerHTML;  //getText or some other function?
      }                                            //links.getElementById("").innerHTML;
      return $retVal;
}
importPackage(java.util.Arrays)
var $Array2 = getLinks();
var $check = java.util.Arrays.equals($Array1, $Array2);
if($check == false)
      Packages.java.lang.System.out.println("Projects' names don't come in the right order.");
else
      Packages.java.lang.System.out.println("Projects' names come in the right order.");
This is the error message I get:
JSERROR
The choice of Java constructor equals matching JavaScript argument types (object,object) is ambiguous; candidate constructors are:
boolean equals(char[],char[])
boolean equals(java.lang.Object[],java.lang.Object[])
boolean equals(float[],float[])
boolean equals(double[],double[])
boolean equals(boolean[],boolean[])
boolean equals(byte[],byte[])
boolean equals(long[],long[])
boolean equals(int[],int[])
boolean equals(short[],short[]) at 24-Aug-2010 12:02:50
I don't know how to carry on from here. Anyone any light on this?

Ana
      
0
Comment
Question by:ana-redondo-lopez
  • 3
4 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
What a weird thing to do

Do you mean

boolean equals = Arrays.equals(arrayOne, arrayTwo);  


0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 300 total points
Comment Utility
Why not just javascript?

var $Array1 = new Array("3 Face Blend on Mixed Walls", "Assimilation Blend Support", "Detect Loss of Blend Overflow");

function compareLinks(){

  var $links = document.links;  

  for (var $i=0; $i<$links.length; $i++){

    if ($Array1[$i]!==$links[$i].innerHTML) return false;

  }                                    

  return true;

}



if (compareLinks()) alert('They are the same');

Open in new window

0
 
LVL 3

Assisted Solution

by:gremwell
gremwell earned 200 total points
Comment Utility
Perhaps you better off not interfacing Java to compare arrays at all. Use scripting language itself to do the task, see the example at the bottom of http://www.hunlock.com/blogs/Mastering_Javascript_Arrays web page.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Ah

I see from gremwell's link that I should also compare length

function compareLinks(){
  var $links = document.links;  
if ($links.length !=$Array1.length) return false;
  for (var $i=0; $i<$links.length; $i++){
    if ($Array1[$i]!==$links[$i].innerHTML) return false;
  }                                    
  return true;
}

no need to recourse though
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to start Neon 20 49
HTML page and JavaScript 2 49
JavaScript error 1 33
addressing a specific html page 9 19
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now