Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda