Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda