tags:

views:

87

answers:

2

I need to process few lines of code over and over in RFT (java) so custom method/function/procedure is the best (and only) solution to this.

I have no java experience so I need some help with that.

The method will receive some parameters and will return no value.

Basically it will be entering new records into a database (web based application). How many records? It depends on data so I need to make it argument based.

the current code looks like

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

in php the desired function would look like

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

so I can call it

   add_student(dpString("StudentName"),dpString("StudentSurnameName"));
+1  A: 

I'm a .net person more than a Java person but it should go something like the below, I've also never used RFT so I'm assuming that the inner text works. You will have to replace the ReplaceWithType with whatever type text__firstname and text_surname are.

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

I would recommend that you take a look at the Java API and get a good Java book.

BitOff
@BitOff: updated the question. Hope it is clearer now.
Radek
hope that helps.
BitOff
A: 

so I was looking for something like that

private boolean add_student($first_name,$surname){

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