Monday, June 30, 2008

Save me !

Lets explore the RMS management available in Diamond Powder.
The MIDlet project save-me-diamond-powder deals with new records and enable old record edition through StorageManager.


The numbered arrows are related to the following relevant code fragments:

(1) The collector gains focus to receive a new record. There is no difference from previous sample (hello world)
(2) The collector finishes his job and a StorageManager saves collected data into a RMS record. We can store a new record or update an old one.


(3) The StorageManager is asked about all record numbers from a given schema. Afterwards, the StorageManager is manipulated to retrieve values from specific fields for each identified record. This gives us enough information to build a menu of old records.


(4) The StorageManager is manipulated to load a whole record into our collector. At this point we use the collector to edit a previously stored record.

6 comments:

  1. Hi Bellia !

    Great framework and blog, success !!!

    ReplyDelete
  2. I am trying to print out a saved schemas contents. I am having a problem getting the integer value for the gasStationBrand that is saved in the schema. How do I convert the Object to an integer?

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hi,
    The schema is the data collector structure - Actually the collected data is saved by StorageManager into device's RMS system.

    In order to get data from a choicegroup field, the 1st thing to do is to locate the related ListModel:

    ListModel listModel = (ListModel) getCollector().getMediator()
    .getChoiceGroupToListModel().get("field.gasStationBrand");


    If you intend to get the gasStationBrand from a collector that's been loaded by StorageManager:
    Item _item = getCollector().getMediator()
    .getField("field.gasStationBrand ");
    ChoiceGroup _choice = (ChoiceGroup) _item;
    int index = _choice.getSelectedIndex();
    String brandLabel = listModel.getLabels()[index];
    int brandValue = listModel.getValue(label);


    If you intend to retrieve the saved values directly from StorageManager.retrieveValues(...) method :

    Object[] values = StorageManager.retrieveValues(schemaName, recordNumber, fieldsList);
    int[] brandsValues = (int[]) values[p];
    // where "p" is the gasStationbrands defined position in the requested fields list
    String firstBrandLabel = listModel.getLabel(brandsValues[o]);

    ReplyDelete
  5. Where can I find the available mask values for putting things in the schema? the example has text, decimal is there an integer mask?

    ReplyDelete
  6. How do I add the source to my netbeans project? I have downloaded the source files... just do not know now to make it so when I ctrl click on a diamond powder method, it will take me to that section of code, so I can see how things are processing, etc.

    ReplyDelete

Note: Only a member of this blog may post a comment.