public class HelloworldClient { public static HelloworldClient CLIENT; private String _url; private HelloworldClient(String string) { _url = string; } private HelloService _service; public static void setServerUrl(String url) { CLIENT = new HelloworldClient(url); } private HelloService getService() { if (_service == null) { try { //通过Hessian调用服务器端服务 HessianProxyFactory factory = new HessianProxyFactory(); _service = (HelloService) factory.create(HelloService.class, _url); } catch (MalformedURLException ex) { System.out.println(ex); } } return _service; } //供JavaFX调用 public String hello(String s) { return getService().hello(s); }}
class Hello { attribute name:String; attribute str:String;}var helloModel = new Hello();HelloworldClient.setServerUrl(ARGUMENTS:String);Frame { width: 300 height: 200 title: "Exadel Flamingo Helloworld Spring Sample" centerOnScreen: true onClose: operation(){ System.exit(0);} content: GridPanel { border: EmptyBorder { top: 30 left: 30 bottom: 30 right: 30 } rows: 3 columns: 1 vgap: 10 cells: [TextField { value: bind helloModel.name }, Button { text: "Say Hello!" action: operation() { //调用Controller控制器HelloworldClient的hello方法 //将返回结果赋值给JavaFX的数据对象helloModel helloModel.str = HelloworldClient.CLIENT.hello(helloModel.name); } }, Label { text: bind "Server says: {helloModel.str}" }] } visible: true};