class LinkButton(override val p: com.vaadin.ui.Button with ButtonMixin = new com.vaadin.ui.Button with ButtonMixin) extends Button(p) {
p.setStyleName(BaseTheme.ButtonLink)
}
If I create a vaadin.scala.Button, it lacks the ButtonMixin. But if I make a com.vaadin.ui.Button, I’m not sure how to bring the mixin in. I’d have expected the Scala class would have it, but it doesn’t.
The class vaadin.scala.Button also uses ButtonMixin for its constructor parameter just like LinkButton does.
If you want something that looks and behaves like a button, use a Button. If you want something that looks and behaves like a link, use a Link.
ButtonLink is for the rare cases where you want a button to look like a link but its clicks be handled on the server side. However, this restricts what can be done with it (the browser does not allow certain actions to be initiated by the server), and the user will not be able to use “open in new tab” etc.
Good question. Currently there are no built-in wrappers for the validators provided by Vaadin (although there should be), but luckily it’s quite easy to wrap them yourself. You can either do a separate class for the wrapping, or do it like the test I just wrote for Scaladin:
test("Use Java Vaadin validators, inline wrap") {
import scala.util._
import scala.util.control.Exception._
val field1 = new TextField
field1.validators += Validator(value => {
catching(classOf[com.vaadin.data.Validator.InvalidValueException]
) withTry (new com.vaadin.data.validator.EmailValidator("foo").validate(value.orNull)) match {
case Success(value) => Valid
case Failure(exception) => Invalid(List(exception.getMessage))
}
})
field1.value = "foo"
assert(field1.validate === Invalid(List("foo")))
field1.value = "test@email.com"
assert(field1.validate === Valid)
}