This document presents an overview of a subset of new Visual Designer custom components. The new custom components main functionality is easy to use UI connectivity with any kind of data source. The Databinding support should also contains set of predefined DataSets components to speed up development of applications. New Datasets components should help developers in technologies such as Scalable Vector Graphics, Personal Information Management or provide possibility to create custom DataSet.
A subset for designing real JavaME applications targeted mostly to corporate users is the objective, but helping other types of users with certain tasks is also goal of this feature.
New Data Binding Components should be a subset of MIDP 2.0 components and should utilize Data Binding libraries which are already included in Netbeans 6.0. Source code for the Visual Midlet would be generated based on the attached DataSets and custom property editors. Components with Databinding support:
Forms Items:
All Items has possibility of using Databinding support in Label property.
List of available DataSets:
Default Expression: No default expression for this component.
Code of of the Dataset (empty):
public DataSet getDataSet() {
if (dataSet == null) {
// write pre-init user code here
dataSet = new DataSet();
// write post-init user code here
}
return dataSet;
}
private DataSet_ implments DataSet() {
// declaration field
public Class getType(String type) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
public Object getValue(String name) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
public void setValue(String name, Object value) throws IllegalStateException {
//TODO Implement this methode
DataBinder.fireDataSetChanged(this , name);
}
public void setAsString(String name, String stringValue) throws IllegalStateException {
//TODO Implement this methode
DataBinder.fireDataSetChanged(this , name);
}
public boolean isReadOnly(String readOnly) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
}
}
Default Expression: No default expression for this component.
Code of of the IndexableDataset (empty):
public IndexableDataSet getIndexableDataSet() {
if (indexableDataSet == null) {
// write pre-init user code here
indexableDataSet = new IndexableDataSet_();
// write post-init user code here
}
return indexableDataSet;
}
private class IndexableDataSet_ implements IndexableDataSet {
// declaration field
public int getSize() {
throw new IllegalStateException("Not implemented yet.");
}
public Object getRow(int index) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
public void setRow(int index, Object value) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
public void insertRow(int index, Object row) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
public void deleteRow(int index) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
public Class getType(String name) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
public Object getValue(String name) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
public void setValue(String name, Object value) throws IllegalStateException {
//TODO Implement this methode
DataBinder.fireDataSetChanged(this , name);
}
public void setAsString(String name, String stringValue) throws IllegalStateException {
//TODO Implement this methode
DataBinder.fireDataSetChanged(this , name);
}
public boolean isReadOnly(String readOnly) throws IllegalStateException {
throw new IllegalStateException("Not implemented yet.");
}
public boolean isReadOnly() {
throw new IllegalStateException("Not implemented yet.");
}
};
Default Expression: ContactsDataSet(index).type_of_data.ItemData(index2)
The Databinding should be accessible from every property custom editor with Databinding support. The Databinding Property Editor should help developers to bind data (through chosen Dataset) with application UI.
Screenshot of Databinding Property Editor:
Screenshot of property sheet with Databinding support:
Code generated based on the information shown on the screenshot:
The Read tab should allow developers to define following parameters Dataset:
Screenshot of Read tab:
Source Code generated based on data shown in the screenshot above:
public StringItem getStringItem() {
if (stringItem == null) {
// write pre-init user code here
stringItem = new StringItem("Name", "Hello, World!");
//Start of the Databinding generated code
DataBinder.registerDataSet(getDataSet(), "dataSet");
DataBinder.bind("dataSet.name", new StringItemBindingProvider(), getStringItem(), StringItemBindingProvider.FEATURE_TEXT);
//End of the Databinding generated code
// write post-init user code here
}
return stringItem;
}
Screenshot of Write tab:
The Source Code generated based on the information shown on the screenshot above. This code pushes back data(writes) to the DataSet.
public void commandAction(Command command, Displayable displayable) {
// write pre-action user code here
if (displayable == form) {
if (command == save) {
// write pre-action user code here
//Start of the Databinding generated code
DataBinder.writeValue("dataSet.name",getStringItem().getText());
//End of the Databinding generated code
exitMIDlet();
// write post-action user code here
}
}
// write post-action user code here
}
The Read tab for indexable Datasets should be similar to the non indexable Dataset Read tab. One additional parameter should be available - Index.
Screenshot of indexable Read tab:
The Source code generated based on the screenshot shown above. The Source code is very similiar to the code generated by the non indexable DataSet except for different expression which contains Index parameter.
public StringItem getStringItem() {
if (stringItem == null) {
// write pre-init user code here
stringItem = new StringItem("Name", "Hello, World!");
//Start of the Databinding generated code
DataBinder.registerDataSet(getDataSet(), "dataSet");
DataBinder.bind("dataSet[index].name", new StringItemBindingProvider(), getStringItem(), StringItemBindingProvider.FEATURE_TEXT);
//End of the Databinding generated code
// write post-init user code here
}
return stringItem;
}
Shown code is a part of the method public void commandAction(Command command, Displayable displayable). Full listing of this method is shown at the end of this document.
} else if (command == save) {
// write pre-action user code here
//Start of the Databinding generated code
DataBinder.writeValue("dataSet["+index+"].name",getStringItem().getText());
//End of the Databinding generated code
exitMIDlet();
// write post-action user code here
}
The Indexable tab is available only for indexable DataSets. Contains following parameters:
The Indexable tab screenshot:
Code generated based on the information shown in the Indexable tab and Write tab:
public void commandAction(Command command, Displayable displayable) {
// write pre-action user code here
if (displayable == form) {
if (command == next) {
// write pre-action user code here
//Start of the Databinding generated code
if (index < indexableDataSet.getSize() - 1) {
index++;
DataBinder.bind("dataSet["+index+"].name", new StringItemBindingProvider(), getStringItem(), StringItemBindingProvider.FEATURE_TEXT);
}
//End of the Databinding generated code
// write post-action user code here
} else if (command == previous) {
// write pre-action user code here
//Start of the Databinding generated code
if (index > 0) {
index--;
DataBinder.bind("dataSet["+index+"].name", new StringItemBindingProvider(), getStringItem(), StringItemBindingProvider.FEATURE_TEXT);
}
//End of the Databinding generated code
// write post-action user code here
} else if (command == save) {
// write pre-action user code here
//Start of the Databinding generated code
DataBinder.writeValue("dataSet["+index+"].name",getStringItem().getText());
//End of the Databinding generated code
exitMIDlet();
// write post-action user code here
}
}
// write post-action user code here
}
contact: Karol Harezlak
| DatabindingExample.zip | ![]() |
374217 bytes |
| dataSet1.png | ![]() |
24055 bytes |
| dataSet2.png | ![]() |
21821 bytes |
| indexable1.png | ![]() |
24740 bytes |
| indexable2.png | ![]() |
22151 bytes |
| indexable3.png | ![]() |
20118 bytes |
| propertyEditor1.png | ![]() |
38703 bytes |
| propertyEditor2.png | ![]() |
16602 bytes |