Search code examples
javafunctionrft

how to write custom function/method in java? (RFT)


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

Solution

  • 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;
    }