如果我有多个具有不同ID的对象,但是单击它们时它们都调用相同的函数。有什么方法可以跟踪或找到哪个对象称为函数。
例如
org.apache.spark.sql.AnalysisException: Path does not exist: file:/User/myname/documents/data/xyz.csv;
at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$14.apply(DataSource.scala:382)
at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$14.apply(DataSource.scala:370)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:241)
at scala.collection.immutable.List.flatMap(List.scala:344)
at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:370)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:152)
at org.apache.spark.sql.DataFrameReader.csv(DataFrameReader.scala:415)
at org.apache.spark.sql.DataFrameReader.csv(DataFrameReader.scala:352)
... 47 elided
欢呼
答案 0 :(得分:1)
如果您正在使用
Path inputFile = Paths.get("src/inware/users.txt");
Path outputFile = Paths.get("src/inware/usersT.txt");
try {
try (BufferedReader in = Files.newBufferedReader(inputFile);
PrintWriter out = new PrintWriter(Files.newBufferedWriter(outputFile))) {
for (String line; (line = in.readLine()) != null; ) {
line = line.trim();
if (! line.isEmpty())
out.println(line);
}
}
Files.delete(inputFile);
Files.move(inputFile, outputFile);
} catch (IOException ex) {
Logger.getLogger(ManageStudentController.class.getName()).log(Level.SEVERE, null, ex);
}
在元素中进行更改,以便将其自身传递给函数:
onclick="test()"
然后函数接收对象作为参数。
onclick="test(this)"
答案 1 :(得分:0)
只需执行以下操作:
function test(id) {
document.getElementById('div').style.backgroundColor = 'red';
var objectID = id;
document.getElementById('textbox').innerHTML = objectID;
}
var object = {
id = "AnObject",
testFunction: function() {
test(this.id);
}
};
object.testFunction();