如何用java编写自定义函数/方法?(RFT)

如何用java编写自定义函数/方法?(RFT),java,function,rft,Java,Function,Rft,我需要在RFT(java)中反复处理几行代码,因此自定义方法/函数/过程是最好(也是唯一)的解决方案 我没有java经验,所以我需要一些帮助 该方法将接收一些参数,并且不会返回任何值 基本上是将新记录输入数据库(基于web的应用程序)。有多少张唱片?这取决于数据,所以我需要使其基于参数 当前代码看起来像 text__firstname(ANY,NO_FLAGS).setText(dpString("StudentName")); text__surname(ANY,NO_FLAG

我需要在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"));

我是一个.net的人,而不是一个Java的人,但它应该像下面这样,我也从来没有使用过RFT,所以我假设内部文本可以工作。您必须将ReplaceWithType替换为text\u firstname和text\u姓氏的任何类型

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书籍。

所以我正在寻找类似的东西

private boolean add_student($first_name,$surname){

  text__firstname(ANY,NO_FLAGS).setText($first_name);
  text__surname(ANY,NO_FLAGS).setText($surname);
  return true;
}

您可以编写这样的方法

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命令自动迭代到数据池中的下一条记录

希望这对你有帮助