Solved

Sahi scripting

Posted on 2010-08-24
4
489 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
[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
  • 3
4 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33509873
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
ID: 33509893
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
ID: 33509940
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
ID: 33509988
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Difference between Leaflet and MapBox? 5 45
Slow Down an Animation 3 28
Submit button if clicked twice submits twice 1 24
Java regex 5 21
This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

734 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