I showed how to call a Seam component with Flamingo from JavaFX. In this post I show how to invoke Hibernate Validator from JavaFX with Flamingo:
Entity (and Seam component):
@Entity
@Name ("icecream")
public class IceCream {
@Id @GeneratedValue
private Long id;
@Max(value=5, message="Sorry, you can't have more than {value} flavors")
private Integer flavors;
// getters and setters
}
JavaFX script (most interesting stuff is happening lines 17-21):
FXServiceFactory.URL = "http://localhost:8080/server-javafx/seam/resource/hessian/";
var message:String;
var textBox:TextBox = TextBox {
columns: 15
}
var label:Label = Label {
text : "How many flavors:"
style:"-fx-font-weight:bold"
}
var errorMessage:Label = Label {
text: bind message
style : "-fx-text-fill:red; -fx-font-weight:bold"
}
var button:Button = Button {
text: "Click"
action : function () {
var ev = FXServiceFactory.getService(EntityValidator.class,
"com.exadel.flamingo.service.validator.entityValidator")
as (EntityValidator);
message = ev.validate ("icecream.flavors", textBox.text)
}
}
Stage {
title: "Application"
width: 250 height: 100
scene: Scene {
content: [
VBox {
spacing: 5
content:[
label,
HBox {
spacing: 5
content: [
textBox,
errorMessage
]
}
button
]
}
]
}
};
Result:

That’s it.
Leave a Reply