2010-09-20 61 views
0

我需要在RFT(java)中反复处理几行代码,因此自定义方法/函数/过程是最好的(也是唯一的)解决方案。如何在java中编写自定义函数/方法? (RFT)

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

该方法将收到一些参数,并将不返回任何值。

基本上它将输入新的记录到数据库(基于网络的应用程序)。有多少条记录?它取决于数据,所以我需要使它基于参数。

当前的代码看起来像

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")); 

回答

0

所以我迭代,查找类似的东西

private boolean add_student($first_name,$surname){ 

    text__firstname(ANY,NO_FLAGS).setText($first_name); 
    text__surname(ANY,NO_FLAGS).setText($surname); 
    return true; 
} 
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书。

+0

更新了问题。希望现在更清楚。 – Radek 2010-09-20 01:11:43

+0

希望有所帮助。 – 2010-09-22 04:23:24

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命令自动数据池的下一个记录。

希望这可以帮助你!

相关问题