Skip to content

Instantly share code, notes, and snippets.

@ikennaokpala
Forked from wfaler/NewWidgetForm.scala
Created April 3, 2011 20:23
Show Gist options
  • Save ikennaokpala/900759 to your computer and use it in GitHub Desktop.
Save ikennaokpala/900759 to your computer and use it in GitHub Desktop.
import org.bowlerframework.view.squery.component.ValidationFeedbackPanel._
import org.bowlerframework.view.squery.Component
import org.bowlerframework.RequestScope
class NewWidgetForm extends Component{
val request = RequestScope.request
$("#errorPanel").contents = showErrorMessages
request.getSession.getValidatedModel match{
case None => bindModel(Widget(0, null, null, null))
case Some(seq) => bindModel(seq.head)
}
def bindModel(widget: Widget){
$("form input[name='widget.id']").attribute("value", valueOrEmpty(widget.id))
$("form input[name='widget.name']").attribute("value", valueOrEmpty(widget.name))
$("form input[name='widget.yearMade']").attribute("value", valueOrEmpty(widget.yearMade))
$("form input[name='widget.description']").attribute("value", valueOrEmpty(widget.description))
}
implicit def Any2Widget(e: Any): Widget = e.asInstanceOf[Widget] // Converting Type Any to Widget i think !! wfaler don't shot me lol
}
@ikennaokpala
Copy link
Author

may be something like this.. i assume it's of type Any & could be implicitly converted to Widget on the fly. my 2Cents..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment