Skip to content

Instantly share code, notes, and snippets.

@wfaler
Created February 23, 2011 21:44
Show Gist options
  • Save wfaler/841249 to your computer and use it in GitHub Desktop.
Save wfaler/841249 to your computer and use it in GitHub Desktop.
CarDropdown.scala
import org.bowlerframework.view.scalate.ComponentRenderSupport
import com.recursivity.jpa.Jpa._
import collection.mutable.MutableList
/**
* Created by IntelliJ IDEA.
* User: wfaler
* Date: 20/02/2011
* Time: 23:40
* To change this template use File | Settings | File Templates.
*/
object MakeDropdownComponent extends ComponentRenderSupport{
def show(make: Make): String = {
transaction{
val makes = entityManager.createQuery("from Make as m").getResultList.asInstanceOf[java.util.List[Make]]
val list = new MutableList[Make]
val iterator = makes.iterator
while(iterator.hasNext)
list += iterator.next
if(make != null)
render(make, list.toList)
else render(list.toList, new Make("Yibberish that will never be selected"))
}.asInstanceOf[String]
}
def show: String = show(new Make("Yibberish that will never be selected"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment