Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
How to send a data from scala to a particular div tag in Html page

I have a List[List[String]] in my Scala side which I have to send to a div tag of a particular HTML page.

    <div class="pagecolumn" style="background-color: #FFFFFF;">
         <button class="collapsible">Data Info</button>

        <div id="resultDiv" >
          
        </div>
    </div>
   
     
def getResultantValues(modelObject: String, keyName: String):Unit = {
var result = modelObject.replaceAll("\\[","").split("]")
var resultList : mutable.MutableList[mutable.MutableList[String]]= null
for (i<-0 until result.length) {
  resultList += result(i).split(",")
}}`

I have to send ResultList to the resultDiv.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Without providing details it's quite hard to understand exactly why you need to process the modelObject like that or what is the point of keyName in your code, but assuming you have ResultList of type List[List[String]], and you just need a way to send resultList to resultDiv, here's how you can do that in Scala:

object Something extends App {

  def getResultantValues(modelObject: String): String = {
    val rawSentences: List[String] =
      modelObject
        .replaceAll("makes no sense", "is nonsense")
        .split("\\.")
        .toList
    val resultList: List[List[String]] =
      for (word <- rawSentences) yield word.strip.split(",").toList
    resultList.flatten.mkString("\"", ".", "\"")
  }

  val resultDiv = getResultantValues(
    "This sentence makes no sense. This sentence makes no sense too."
  )

  val htmlString =
    s"""
       |<div class="pagecolumn" style="background-color: #FFFFFF;">
       |    <button class="collapsible">Data Info</button>
       |
       |    <div id=$resultDiv >
       |          
       |    </div>
       |</div>
       |""".stripMargin

  println(htmlString)
}

Outputs:

<div class="pagecolumn" style="background-color: #FFFFFF;">
    <button class="collapsible">Data Info</button>

    <div id="This sentence is nonsense.This sentence is nonsense too" >
          
    </div>
</div>
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!