I am in the process of developing a small application which users use to order food at a restaurant using the mobile phone. The food items will be hard coded as a multiple choice group in the midlet. Using the getSelectedFlags() I am able to store the selected options in an array. However I would like to store these in an Access database. Is it possible to send the contents of the array to a database using
servlets. I have very limited knowledge about connecting servlets to midlets and writing servlets. In this instance would I use a GET and append the URL with the arrayname or would POST be easier.
One other small thing when
testing using System.out.println to see if the array was being populated only true or false was shown with no details about the item selected. Using the getString () I was able to display the name of the item being selected. How can I ensure that only selected items are stored in the array and those that are not selected are not in the array. I will apprecate any help
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class FormPizzaexp extends Form implements CommandListener {
private ChoiceGroup pizzaexpMenu;
private MainScreen midlet;
private Command cmdBack;
private Command cmdSelect;
public FormPizzaexp (
String title, MainScreen midlet ){
super (title);
this.midlet = midlet;
cmdBack = new Command("Back", Command.BACK, 1);
cmdSelect = new Command("Select",Command.OK, 2);
pizzaexpMenu = new ChoiceGroup ("What would you like to Order?", Choice.MULTIPLE,
new String [] {"ANTIPIZZE", "Garlic Bread �1.95", "Bruschetta �3.25", "Baked Dough Balls �1.95", "SALADS AND VARIATIONS", "Mozzarella and Tomato Salad �6.45", "Lasagne Pasticcate �7.10", "Tortellini �7.10", "PIZZE", "Margherita �4.95", "American Hot �7.70", "Soho Pizza �6.95", "Sloppy Giussepe �7.15", "WINE", "House White Bottle 75cl �10.95", "Half House White Bottle 37.5cl �5.95", "House Red Bottle 75cl �10.95", "Half House Red Bottle 37.5cl �5.95", "SOFT DRINKS", "Coke �1.65", "Sprite �1.65", "Mineral
Water �1.00", "Apple Juice �1.65", "DESSERTS", "Choclate Fudge Cake �3.85", "Tiramisu �3.85", "Vanilla Ice Cream �2.10"}, null);
append(pizzaexpMenu);
addCommand(cmdBack);
addCommand(cmdSelect);
setCommandListener(this);
}
public void commandAction(Command c, Displayable s) {
if (c == cmdBack)
midlet.displayMainForm ();
else if (c == cmdSelect){
boolean selected[] = new boolean [pizzaexpMenu.size()];
pizzaexpMenu.getSelectedFlags(selected);
for (int i=0; i<pizzaexpMenu.size(); i++)
System.out.println (pizzaexpMenu.getStrin(i) +(selected[i]));
}
}
}