|
|
GWT-Masterview library is an extension to Google Web Toolkit that provides widgets to filter, sort and paginate your data. It's easy to use, it's widgets are fast and it works right out of the box: you can display your objects with just 3-4 lines of code.
Initially I started to look for a replacement to the Displaytag library, which can't be used in pure GWT applications. Some GWT-extending libraries provided tables, but these tables either were just wrappers of external JavaScript toolkits, or didn't have filter or paging functionality. So I wrote my own small library, with API similar to the one that Displaytag has, and named it Masterview, because I find it simple to create master screens using it.
NOTE: The beta is ready. I'll import it into svn in a day or two.
A tutorial on how to start using the library can be found here.
Masterview library has several predefined themes, but default one looks like this (you can read more about using predefined themes or creating your own here):
The main features of the library
- The Masterview library uses no external JavaScript, only extending basic GWT widgets. It has several advantages:
- Smooth integration with standart GWT widgets and their extensions.
- Easy debugging in browser hosted mode.
- Advantage of improving GWT compiler's optimization.
- The API is similar to the one Displaytag library has. The only difference is that you write Java code instead of jsp tags. For example, instead of writing something like this
<display:table name="people" pagesize="16">
<display:column property="firstName" title="First name" sortable="false" style="width: 40%"/>
<display:column property="lastName" title="Last name" sortable="true" style="width: 60%"/>
</display:table>you'll write
MasterView masterView = GWT.create(Person.class);
masterview.setItems(people);
masterview.appendColumn(new Column("firstName", "First name", false, "40%");
masterview.appendColumn(new Column("lastName", "Last name", true, "60%");
RootPanel.get().add(masterview);- You don't have to rewrite any existing code, except one thing: you need to mark beans that are to be displayed in a table with IsMasterviewBean interface. After that the library will create your table with the help of GWT's generators.
- Library is provided with a number of default themes.
- Built-in paging and sorting.
- Items can be filtered based on simple regular expressions (your can read about it here).
The limitations of the library
- If you want to display a bean, which has associated bean as a property, than you can't display properties of the associated bean. For example, if there is a Person bean with a getAddress() method thatreturns an Address bean, it's not possible to display city property of the Address bean like that:
MasterView masterView = GWT.create(Person.class);
masterview.appendColumn(new Column("address.city", "Person's city", true, "100%");One possible solution (if there is an absolute need to display person's city in a table) is to add getCity() method to Person bean with code like this:public String getCity() { Address address = getAddress(); if (null == address) { return "---"; //or something } return address.getCity(); }and create the grid's column like this:MasterView masterView = GWT.create(Person.class); masterview.appendColumn(new Column("city", "Person's city", true, "100%");
