Creating and Assigning Variables

There are four types of variables: user, system, table and personalized.

To create user variables, add the variable in BOBCUIDefinition:

addVariable(VARIABLE_HISVAR, "hisVarValue",
  VariableProperties.VARIABLE_TYPE_USER, 
  MBOAttribute.SCHEMA_TYPE_STRING);

To use a user variable in controls:

case LABEL2:
  Label locallabel2 = (Label) object;
  locallabel2.setFontStyle(styleLabel_Style);
  //locallabel2.setFooterField(null);
  locallabel2.setFocusFontStyle(styleDefault_Style);
  locallabel2.setWrapText(false);
  locallabel2.setVariableLabel(new ControlVariable(
      BOBCUIDefinition.VARIABLE_HISVAR,
      VariableProperties.VARIABLE_TYPE_USER, null,
      null));
To persist a user variable:
String key = "variableName";
		// NOTE: Sybase only supports this type.
		String keyType = VariableProperties.VARIABLE_TYPE_USER;
		String schemaType = MBOAttribute.SCHEMA_TYPE_BOOLEAN;
		Object value = "true";
		Util.addVariable( key, value, keyType, schemaType );

System variables are used in a similar manner.

To create table variable and bind to text input:

localtextInput4.setVariableInput(
    new ControlVariable("dept_head_id",
        VariableProperties.VARIABLE_TYPE_TABLE,
        BOBCUIDefinition.MBO_A_B_C_DEPARTMENT, null));

You must save a Context before table variables can be used by a context action.

case MENU6:
  MenuAction menu6 = (MenuAction) object;
  //Create list of actions
  ActionList actionList13 = new ActionList();
  IBOBAction connectionAction9 = 
     new ScreenAction(
        UIDefinition.getScreen("screen4"), false, null);
  menu6.setAction(actionList13);
  IBOBAction contextAction4 = 
      new SaveMobileDataContextAction(cellTable1);
  actionList13.addAction(contextAction4);
  actionList13.addAction(connectionAction9);
  cellTable1.setDefaultAction(actionList13);