presentation - Wellington Java User Group

Download Report

Transcript presentation - Wellington Java User Group

Service Side Ajax
Richard Schmidt
hangstrap @ gmail . Com
Metservice
Our Situation / Requirement



Rich(ish) Application.
Easy to deploy / standard browser.
Not many users.




Max 50 sessions
Very little concurrency
Hardware costs are not important.
Main cost is developer salaries.
Some Web Frameworks

JSF (yea right!)


Tapestry, Wicket


Scaled down Java
Java client (applet / web start)


Another language
GWT


Component based.
Flex


Ajax?
Will the client have JAVA installed?
Something else?
Server Side Ajax




Server downloads a javascript app. to
browser.
Server then sends list of components that
javascript app. renders in the browser.
User events are sent back to server using
Ajax.
Server processes events and then send
changes to components back to client...
Advantages


Only one language
Can use full features of Java



No writing of HTML or Javascript!
Write using components that fire events.



not like GWT
Swing like.
KISS: One less physical layer
All code runs on one VM, easier to debug,
test etc.
Disadvantages

Each user has a large session variable.


More network traffic to / from server.





Not going to work for Google!
(but not much more!)
Not mainstream technology.
'Stuck' with the basic components supplied by
the framework.
Set of components – still have to write a
application framework!
Different browsers.
Players

Thinwire


Echo2/3


Based on Swing components.
J-Seamless


Well known.
Wing-S


Stable, not much development.
Uses Flex as a renderer.
ULC Canoo


Commercial, Java proxy on client
Test framework, visual editor, support, rich
functionality.
Code Example
public static void main(String[] args) {
//Create and set initial position for components
final Dialog dialog = new Dialog("Hello World, ThinWire
Style!");
Label label = new Label("Hello, what is your name?");
final TextField input = new TextField();
Button button = new Button("Ok");
//When button is clicked, close modal dialog and say hello
button.addActionListener("click", new ActionListener() {
public void actionPerformed(ActionEvent ev) {
MessageBox.confirm("Hello " + input.getText() + "!");
dialog.setVisible(false);
}
});
//Add components to dialog
dialog.getChildren().add(label);
dialog.getChildren().add(input);
dialog.getChildren().add(button);
//Show dialog and wait for "OK" press
dialog.setVisible(true);
Using Beans Binding
ATestBean bean = new ATestBean();
Property<ATestBean, Boolean> pt1Client =
BeanProperty.create("enabled");
TextField tf = new TextField();
Property<TextField, Boolean> tfProp =
BeanProperty.create("enabled");
Binding<ATestBean, Boolean, TextField, Boolean> binding =
Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
bean, pt1Client, tf, tfProp);
binding.bind();
Demos




Echo2
Wing-S
Canoo ULC
Our App