Saya memiliki halaman dengan 50 catatan aktif dan ketika Anda menyimpan nilai, ia mengaktifkan 31 parameter formulir untuk masing-masing dari 50 catatan. Jadi ini berarti banyak kode yang tidak dapat dikompilasi karena batasan JVM. Ini juga kode yang sangat berulang.

Jadi saya ingin membuat metode seperti ini:


  def formParams(recordNumber : String) = {
      .formParam("DMX.DUMMY_OCCURRENCES.MENSYS." + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.1-" + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.2-" + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.3-" + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.4-" + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.5-" + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.6-" + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.7-" + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.13-" + recordNumber, "CDL_RECM")
      .formParam("VALUE.DUMMY_FIELDS.MENSYS.13-" + recordNumber, "1")
      .formParam("VALUE.DUMMY_FIELDS.MENSYS.15-" + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.15-" + recordNumber, "CDL_SCOR")
      .formParam("VALUE.DUMMY_FIELDS.MENSYS.16-" + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.16-" + recordNumber, "CDL_NOTE")
      .formParam("%.DUMMY_FIELDS.MENSYS.1-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.2-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.3-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.4-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.5-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.6-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.7-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.8-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.9-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.10-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.11-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.12-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.13-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.14-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.15-" + recordNumber, "")
      .formParam("%.DUMMY_FIELDS.MENSYS.16-" + recordNumber, "")
  }

Dan kemudian panggil ini di exec saya seperti:

.exec(http("store OD")
        .post("/urd/sits.urd/run/SIW_DMX_LITE")
        .headers(headers_36)
        .formParam("NKEY.DUMMY.MENSYS.1", "${SEARCHNKEY}")
        .formParam("RUN_MODE.DUMMY.MENSYS.1", "ACT")
        .formParam("SORT_FILTER.DUMMY_PAGER.MENSYS.1", "")

        //CALL METHOD HERE......

        .formParam("FIRST_VALUE.DUMMY_PAGER.MENSYS.1", "1")
        .formParam("PREVIOUS_VALUE.DUMMY_PAGER.MENSYS.1", "-49")
        ....
     
  }

Saat ini tidak dapat menyelesaikan simbol untuk .formparam pertama

Saya juga mencoba ini menggunakan contoh lain yang saya lihat:

 def formParams(recordNumber : String, form : HttpRequestBuilder) = {
    form
      .formParam("DMX.DUMMY_OCCURRENCES.MENSYS." + recordNumber, "")
      .formParam("CODE.DUMMY_FIELDS.MENSYS.1-" + recordNumber, "")
      ....
  }

Metode itu sendiri tidak error, tetapi ketika saya memanggil metode itu melempar kesalahan simbol tidak dapat diselesaikan dalam kode exec.

Adakah yang punya ide yang bisa saya coba?

0
christopher harris 6 Juli 2020, 16:58

1 menjawab

Jawaban Terbaik

Jika masalah Anda adalah kedalaman tumpukan kompiler, Anda dapat menggunakan formParamMap dan meneruskan Peta:

  def formParams(recordNumber : String): Map[String, String] =
    Map(
      "DMX.DUMMY_OCCURRENCES.MENSYS." + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.1-" + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.2-" + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.3-" + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.4-" + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.5-" + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.6-" + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.7-" + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.13-" + recordNumber -> "CDL_RECM",
      "VALUE.DUMMY_FIELDS.MENSYS.13-" + recordNumber -> "1",
      "VALUE.DUMMY_FIELDS.MENSYS.15-" + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.15-" + recordNumber -> "CDL_SCOR",
      "VALUE.DUMMY_FIELDS.MENSYS.16-" + recordNumber -> "",
      "CODE.DUMMY_FIELDS.MENSYS.16-" + recordNumber -> "CDL_NOTE",
      "%.DUMMY_FIELDS.MENSYS.1-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.2-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.3-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.4-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.5-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.6-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.7-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.8-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.9-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.10-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.11-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.12-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.13-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.14-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.15-" + recordNumber -> "",
      "%.DUMMY_FIELDS.MENSYS.16-" + recordNumber -> ""
  )

???
.exec(http("store OD")
        .post("/urd/sits.urd/run/SIW_DMX_LITE")
        .headers(headers_36)
        .formParam("NKEY.DUMMY.MENSYS.1", "${SEARCHNKEY}")
        .formParam("RUN_MODE.DUMMY.MENSYS.1", "ACT")
        .formParam("SORT_FILTER.DUMMY_PAGER.MENSYS.1", "")

        //CALL METHOD HERE......
        .formParamMap(formParams(0))

        .formParam("FIRST_VALUE.DUMMY_PAGER.MENSYS.1", "1")
        .formParam("PREVIOUS_VALUE.DUMMY_PAGER.MENSYS.1", "-49")
        ....
     
  }
1
Stéphane LANDELLE 6 Juli 2020, 14:09