MobilityDatabinding

Java ME Data Binding Library Support for Visual Designer - DRAFT

Contents


Abstract

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.

Objective

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.

Functionality

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:

  • StringItem - Text property
  • ImageItem - Image property
  • DateField - Date property
  • TextField - Text property

All Items has possibility of using Databinding support in Label property.

List of available DataSets:

  • DataSet (empty dataset)
  • IndexableDataSet (empty IndexableDataSet)
  • ContactsDataSet (PIM)
  • PIMDataSet (optional)
  • NameDataSet (optional)
  • ContactDataSet (optional)
  • AddressDataSet (optional)

Components with Databinding support

Following components should have Databinding support:

Form Items

All Form Items have Databinding support implemented in the property Label. This property is String type.

StringItem

The Databindig should be available in the property Text. This property is String type.

ImageItem

The Databindig should be available in the property Image. This property is Image type.

DateField

The Databindig should be available in the property Date. This property is Date type.

TextField

The Databindig should be available in the property Text. This property is String type.

Overview of available Datasets.

DataSet (empty)

This component should represent "empty" implementation of DataSet interface. It should allows developers to create non indexable dataset and it should not contains logic. Logic should be created by developer. In this component like in the rest of the Dataset components to access data developers should use Expression Language.

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.");
                }
                
            }
            
        }
      

IndexableDataSet (empty)

This component should represent "empty" implementation of IndexableDataSet class. It should allow developers to create indexable dataset and it should not contain logic. Logic should be created by developer. All indexable datasets have possibility to iterate through data using chosen (Next/Previous) Commands. Selection of commands, indexes and expressions should be done using Databinding PropertyEditor.

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.");
        }

    };

ContactsDataSet

This component should help developers to access information in the PIM and bind it with Midlets UI.

Default Expression: ContactsDataSet(index).type_of_data.ItemData(index2)

Databinding Property Editor

Overview

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:

Image:propertyEditor1_MobilityDatabinding.png

Screenshot of property sheet with Databinding support:

Image:propertyEditor2_MobilityDatabinding.png

Code generated based on the information shown on the screenshot:

DataSet

The Read tab should allow developers to define following parameters Dataset:

  • Help to chose DataSet from list of available DataSets in the combo box.
  • Allows to provide expression to "read" data from Dataset (Expression Language) in the EL Read.
  • Look up if Chosen Dataset if it's Read/Write or Read Only. (If particular DataSet id read only it means that change data cant be push back to the Dataset.)

Screenshot of Read tab:

Image:dataSet1_MobilityDatabinding.png

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;
    }


\ The Write tab should allow developers to define following parameters:

  • Combo box with list of commands which could be used as an action to push back data to the Dataset. It should be only active when particular DataSet is Read/Write.
  • The expression to push back data to the Dataset. Default value of thsi parameter should be same as expression in the EL Read. It should be possible to edit this value by unselecting checkbox under the expression text field.

Screenshot of Write tab:



Image:dataSet2_MobilityDatabinding.png

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 Indexable tab. The Indexable tab should be inactive for non Indexable Datasets.

\
\

DataSetIndexable

The Read tab for indexable Datasets should be similar to the non indexable Dataset Read tab. One additional parameter should be available - Index.

  • The Index parameter should allow to select or create new Index parameter. New parameter Index should be created when "<Create New Index>" is selected. This option allow to create global Midlet variable which controls index of Dataset.

Screenshot of indexable Read tab:
\
\ Image:indexable1_MobilityDatabinding.png
\
\ 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;
    }


\ The Write tab for indexable Datasets should work similar to the Write tab for non indexable Datasets.
\ Image:indexable2_MobilityDatabinding.png

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 Next Command combo box. This parameter indicates which command should be responsible for iteration through data available in the indexable Dataset.
  • The Previous Command combo box. This parameter indicates which command should be responsible for iteration through data available in the indexable Dataset.

The Indexable tab screenshot:

Image:indexable3_MobilityDatabinding.png

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
    }

Databinding Example

This example shows one of many use cases how to use Databinding. It shows hot to binds data available on the server side to the UI on mobile client. It uses empty DataSet and empty IndexableDataSet so logic is created manually. Example has two projects:

  • Web application
  • Mobility application

Download Example



contact: Karol Harezlak

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo