More Related Content Similar to Ext GWT 3.0 Data Widgets (20) Ext GWT 3.0 Data Widgets2. DATA WIDGETS
Colin Alworth, Sencha
colin.alworth@sencha.com @ambisinister
8. ValueProvider and
PropertyAccess
public interface PersonProperties extends PropertyAccess<Person> {
@Path("email")
ModelKeyProvider<Person> key();
ValueProvider<Person, String> firstName();
ValueProvider<Person, String> lastName();
ValueProvider<Person, String> email();
ValueProvider<Person, String> favoriteColor();
ValueProvider<Person, Integer> height();
}
...
PersonProperties properties = GWT.create(PersonProperties.class);
11. Field Cells
GWT AbstractInputCell
AbstractEventInputCell
FieldCell
ValueBaseFieldCell
CheckBoxCell TextInputCell TriggerFieldCell
ComboCell DateCell
13. Custom Cell<String>
public class MyEmailLinkCell extends AbstractCell<String> {
interface Template extends XTemplates {
@XTemplate("<a href='mailto:{email}'>{email}</a>")
SafeHtml emailTemplate(String email);
}
private Template t = GWT.create(Template.class);
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
sb.append(t.emailTemplate(value));
}
}
15. Grid<Person>
ColumnConfig<Person, String> firstName = new ColumnConfig<Person,
String>(properties.firstName(), 80, "First Name");
ColumnConfig<Person, String> lastName = new ColumnConfig<Person,
String>(properties.lastName(), 80, "Last Name");
lastName.setCell(new TextInputCell());
ColumnConfig<Person, Integer> height = new ColumnConfig<Person,
Integer>(properties.height(), 80, "Height");
height.setCell(new NumberCell<Integer>(new IntegerPropertyEditor()));
21. Loader DataProxy Server
DataReader
22. Purposes
Loader: Builds requests, sends to DataProxy
DataProxy: Makes request to server
DataReader: Translates wire-format to objects
DataWriter: Translates objects to wire-format
23. Readers and AutoBeans
All JSON and XML structures represented using AutoBeans
interface ContactCollection { <?xml version="1.0" encoding="ISO-8859-1"?>
<records>
@PropertyName("records/record")
<record>
List<Contact> getValues(); <Name>Middleton, Wendy V.</Name>
} <Email>morbi.tristique@iaculisquis.org</Email>
interface Contact { <Phone>5574291911</Phone>
@PropertyName("Name") </record>
<record>
String getName();
<Name>Stark, Olivia P.</Name>
<Email>urna.suscipit.nonummy@faucibusleo.edu</Email>
@PropertyName("Email") <Phone>1666312154</Phone>
String getEmail(); </record>
<record>
<Name>Shannon, Rhea D.</Name>
@PropertyName("Phone")
<Email>Integer@nibhPhasellusnulla.org</Email>
String getPhone(); <Phone>2413489010</Phone>
} </record>
24. Generics
private Loader<String, List<Person>> getPersonLoader() {
JsonReader<List<Person>, JsonResults> reader
= new JsonReader<List<Person>, JsonResults>(abf, JsonResults.class) {
@Override
protected List<Person> createReturnData(Object loadConfig, JsonResults records){
return records.getPeople();
}
};
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, "/people.json");
HttpProxy<String> proxy = new HttpProxy<String>(rb);
return new Loader<String, List<Person>>(proxy, reader);
}