Download - Wicket And Swing From One Codebase
Wicket and Swing from one code base
Johan Compagner
Who is Johan Compagner
• Senior Java Developer at Servoy (and Topicus)• 10+ years of Java experience
– Swing and the Web (Struts/Tapestry)
• Core Wicket developer since September 2004
Agenda
• How does Servoy work.• Wicket/Web compared to Swing.• One codebase -> 2 Clients• Q&A
How does Servoy work
• Own Drag'N'Drop RAD IDE• Developers use Javascript to code.
– Those scripts are attached to events (onaction)– Those scripts can alter the form components.
• Repository based, no code generation.• First only a Swing rich client (via webstart)• Web client introduced in 2005• Full AJAX based webclient in 2006
The IDE
The Eclipse Servoy IDE
Wicket compared to Swing
• Both component based (MVC)• Wicket even “more” MVC then Swing.• Pull against Push.• Swing has setLocation/setBackground/Ect.• Swing is richer (even when using AJAX)• Web has browsers....
One codebase -> 2 clients
• We kept the Model part of the MVC.• Controller and View are generated based
on client type.
The Controller part
• IComponentFactory– IButton createButton(..);
• 2 Component Factories– SwingComponentFactory– WicketComponentFactory
• Swing Button uses ActionListener interface.• Wicket Button generates onclick attribute.
The View part
• Swing has this build in (the controller)• Template Generator
– HTML per form.– CSS per form.
• Custom IResourceStreamLocator
Use of AJAX
• All events are done by AJAX.• Basic AJAX support build in a few days..• But.. a Servoy developer can do anything in
a script.– button.setLocation/button.setBackground.
ChangeRecording
• AJAX event is coming in.• Calls the events method.• All components are recording the changes
when touched• An IVisitor walks over the page collecting
the changed components.• And are added to the AjaxRequestTarget.
The Result (Swing)
The Result (Web)
Q/A
?