0

我需要在 RFT (java) 中一遍又一遍地处理几行代码,因此自定义方法/函数/过程是最好的(也是唯一的)解决方案。

我没有java经验,所以我需要一些帮助。

该方法将接收一些参数并且不会返回任何值。

基本上它会将新记录输入数据库(基于 Web 的应用程序)。有多少记录?这取决于数据,所以我需要让它基于参数。

当前代码看起来像

    text__firstname(ANY,NO_FLAGS).setText(dpString("StudentName"));
    text__surname(ANY,NO_FLAGS).setText(dpString("StudentSurnameName"));

在 php 中,所需的功能看起来像

   function add_student($first_name,$surname){
    text__firstname(ANY,NO_FLAGS).setText($first_name);
    text__surname(ANY,NO_FLAGS).setText($surname);
   }

所以我可以称之为

   add_student(dpString("StudentName"),dpString("StudentSurnameName"));
4

3 回答 3

1

你可以写一个这样的方法..

public void setTextValues(TestObject firstName , TestObject surName){

while(dp.dpnext()){
firstName(ANY,NO_FLAGS).setText(dpString("StudentName")); 
    surName(ANY,NO_FLAGS).setText(dpString("StudentSurnameName"));


}

}

dpnext 命令自动迭代到数据池中的下一条记录。

希望这对你有帮助!!

于 2011-05-17T07:47:01.657 回答
1

我是一个 .net 人而不是 Java 人,但它应该像下面这样,我也从未使用过 RFT,所以我假设内部文本有效。您必须将 ReplaceWithType 替换为 text__firstname 和 text_surname 的任何类型。

public void AddStudent(ReplaceWithType text__firstname, ReplaceWithType text__surname)
{
    text__firstname(ANY,NO_FLAGS).setText(dpString("StudentName")); 
    text__surname(ANY,NO_FLAGS).setText(dpString("StudentSurnameName"));
}

我建议您查看 Java API 并获得一本好的 Java 书籍。

于 2010-09-20T00:52:47.090 回答
-1

所以我一直在寻找类似的东西

private boolean add_student($first_name,$surname){

  text__firstname(ANY,NO_FLAGS).setText($first_name);
  text__surname(ANY,NO_FLAGS).setText($surname);
  return true;
}
于 2010-10-07T04:33:15.510 回答