Jefferson
Declarative UIs in pure Java
Like Thomas Jefferson advocated a "wall of separation between church and state," the Jefferson add-on helps you create a clean separation between presentation and content in your Vaadin app.
Benefits/Advantages:
- Style your content without touching your application logic.
- Core API of only 4 classes.
- Convenience classes included for common use cases.
- Makes your content structure more discoverable, readable and understandable.
- Encapsulates your views, making your code more modular and easier to change or reuse.
- Plays nicely with MVC and MVP.
- NEW in 1.3: Now includes a time-saving SmartPresentation that automatically lays out your content with minimal input required, letting you do rapid prototyping.
Jefferson lets you define your content structure separately from your app's data and behavior, and then lets you render this content with any presentation you like. Your content defines only the semantic structure of your app on screen, while your presentation gets to decide exactly what Components to render them with and how to style them. Once these two have been put together, all that is left is to implement the logic that injects the data and defines your app's behavior, which you can do as you would in any other Vaadin app.
For best practices, see the demo project to the right and the code examples below.
Sample code
public class SimpleAddressBook extends SimpleComposite { … private ContactEditor contactEditor = new ContactEditor(); private ContactList contactList = new ContactList(); private ButtonControl contactAdd = new ButtonControl( ADD_CONTACT, new ContactAddHandler()); private ContactRemoveControl contactRemoveControl = new ContactRemoveControl( contactList); private SimpleComposite nav = new SimpleComposite(NAVIGATION); private SimpleComposite toolbar = new SimpleComposite(TOOLBAR); public SimpleAddressBookView() { super("Content root"); setChildren( nav.setChildren( contactList, toolbar.setChildren( contactAdd, contactRemoveControl, new FilterControl( Contact.LAST_NAME, contactList), new FilterControl( Contact.FIRST_NAME, contactList), new FilterControl( Contact.COMPANY, contactList))), contactEditor); … } … }
public class SimpleAddressBookDemo extends Application { @Override public void init() { setMainWindow(new Window("Address Book", new SmartPresentation(Orientation.HORIZONTAL).visit( new SimpleAddressBookView()))); } }
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Vaadin 7 compatibility
- Released
- 2012-04-13
- Maturity
- EXPERIMENTAL
- License
- GNU Affero General Public License v3.0
Compatibility
- Framework
- Vaadin 7.0+
- Vaadin 6.5+ in 1.3.0
- Browser
- Browser Independent
Jefferson - Vaadin Add-on Directory
Declarative UIs in pure JavaDiscussion Forum
Example Project
Author Homepage
Source Code
Jefferson version 0.0.1
Initial release.
Jefferson version 0.0.2
* Generics.
* More visual, declarative way of defining content.
* Java 5 compliance.
Jefferson version 0.0.3
* Better use of reflection and generics.
* Var-arg method rules.
* Run-time type checking.
Jefferson version 0.0.4
* Documentation updates.
* Method name changes.
* Improvements in View API.
Jefferson version 0.1.0
Major refactoring of the API (breaks compatibility with 0.0.x releases). Greatly reduces the number of classes in the content API. You will no longer need to subclass as often either.
Jefferson version 1.0.0
Completely refactored
Jefferson version 1.1.0
* Added the Control class, which is a View that provides an easy way to register a listener to its rendition.
* Refactored convenience classes in the .content package to extend the new Control class.
* All renditions now get a generated style name, enabling easier CSS styling out of the box.
Jefferson version 1.2.0
* Fixed some issues with listener handling in Control class.
* To ensure better type safety, Presentation.render(…) methods are now themselves responsible for calling setRendition(View).
* Method View.getRendition() is now protected to prevent accidental abuse.
* New methods: Presentation.getRendition(View); SelectionControl.setModel(…), .getModel(…), .setSelection(…) and getSelection(…); and TextControl.getText().
Jefferson version 1.3.0
Introducing the SmartPresentation!
Jefferson version 1.3.0.Vaadin7
Vaadin 7 compatibility