السلام عليكــم ورحمـة الله وبركاتــه
احنا طالبات تخرج
مشروعنا باختصار عبارة عن برنامج على الجوال يقوم بتوجيه الطالبة آليا للقاعة المحددة
بالإضافة لخدمات أخرى
استخدمنا النت بينز لكتابة كود الجي تو مي
والسيرفليت للتعامل مع قاعدة البيانات الموجودة على الـ
MY SQL
عندنا عدة أسئلة أتمنى تساعدونا فيها
وربي يفرج عنكم كرب الدنيا والآخرة
1-
السيرفليت لما يتصل بقاعدة لبيانات يعبي البيانات في
List
عشان يقدر يتعامل معاها
بس الـ
List
تنحفظ في الجوال .. فهل هذا الشيء صحيح أو إنه لازم يجيبها كل مرة من السيرفر ؟؟؟
2-
هل يكون عندي سيرفليت واحد احط فيه كل طلباتي من قاعدة البيانات أو لكل طلب سيرفليت منفصل ؟؟؟
وممكن لو سمحتوا تشرحوا لي كيف ارسل باراميتر للسيرفليت ، يعملله معالجة ثم يرجع لي الإجابة ؟؟
3-
برمجة المسار على الجوال راح تكون على أساس اختيار الـ
shortest path
واحتمال نشتغل على الـ
aunt algorithm
فهل تنصحونا نخلي البرمجة على الجوال .. يعني هل حيقدر يتحملها ؟؟
أو نخليها على السيرفليت ويرسلها لنا كـ صورة ؟؟
4-
في السيرفليت .. تطلع لي هذي المسج أحيانا
com.mysql.jdbc.Driver
بس ماتطلع على جهاز صحبتي مع اننا شغالين على نفس الكود .. وين المشكلة ؟؟؟
هذا جزء من كودنا يشرح طريقة التعامل مع القاعة
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import java.io.*;
import java.util.Vector;
import javax.microedition.rms.*;
//import org.netbeans.microedition.lcdui.SplashScreen;
public class Midlet extends MIDlet implements CommandListener {
Display display = null;
private Form form = null;
Form form2 = null;
private TextField location ,floor;
String str = null;
private List list;
private List Room;
private List list3;
//private SplashScreen splashScreen;
private Form First;
private Form formsh;
private ChoiceGroup choiceGroup;
private int replyIndex;
private ChoiceGroup chGroup,cGroup;
private int rpyIndex,rpIndex; // Index of "reply" in choice group
private int choiceGroupIndex;
private Form Help1;
private Form HelpRoom;
private Command okCommand;
private Command exitCommand;
private Command itemCommand;
private Command okCommand1;
private Command backCommand;
private Command Open1;
private Command HomePage;
private Command Help;
private Command schedule;
private Command Exit;
private Font font1;
private Image image1;
private Font font2;
// private Command show;
String url = "http://localhost:8080/WebApplication1/NewServlet";
//Command backCommand12 = new Command("Back", Command.BACK, 0);
Command backCommand1 = new Command("OK", Command.OK, 0);
Command submitCommand = new Command("Submit", Command.OK, 2);
Command exitCommand12 = new Command("Exit", Command.STOP, 3);
private Test test;
private Command show;
//public Midlet() {}
public Midlet()
{
display = Display.getDisplay(this);
// Create an exclusive (radio) choice group
choiceGroup = new ChoiceGroup("Selected one of a Colleges:", Choice.EXCLUSIVE);
// Append options, with no associated images
replyIndex = choiceGroup.append("Faculty of Computer and Information Technology", null);
choiceGroup.append("College of Home Economics", null);
choiceGroup.append("Faculty of Economics and management", null);
choiceGroup.append("College of Arts and Human Sciences", null);
// Set "reply" as the default/selected option
choiceGroup.setSelectedIndex(replyIndex, true);
exitCommand = new Command("Exit", Command.EXIT, 1);
okCommand = new Command("View", Command.SCREEN,2);
show= new Command("display the guidance", Command.SCREEN, 3);
schedule=new Command("schedule of study", Command.SCREEN, 3);
Open1 = new Command("open", Command.OK, 0);
HomePage = new Command("HomeBage", Command.OK, 0);
Help = new Command("Help", Command.OK, 2);
backCommand1 = new Command("Back", Command.BACK, 0);
//text field
floor= new TextField("No. Floor:", "", 30, TextField.ANY);
location = new TextField("The nearest place", "", 30, TextField.ANY);
// Create Form, add components, listen for events
First = new Form("");
choiceGroupIndex = First.append(choiceGroup);
First.addCommand( exitCommand);
First.addCommand(okCommand);
First.setCommandListener(this);
list3 = new List("Employee List", Choice.IMPLICIT);
list3.append(" Room", null);
list3.append(" Faculty members ", null);
list3.append(" Administrative Affairs", null);
list3.append(" Else", null);
list3.addCommand(backCommand1);
list3.addCommand( Open1);
list3.addCommand(HomePage);
list3.addCommand(Help);
list3.addCommand( exitCommand);
list3.setCommandListener(this);
Room = new List("Room Choice", Choice.IMPLICIT);
Room.append("Search for Specific Class", null);
Room.append("Search for empty Class", null);
Room.addCommand(backCommand1);
Room.addCommand( Open1);
Room.addCommand(HomePage);
Room.addCommand(Help);
Room.addCommand( exitCommand);
Room.setCommandListener(this);
form = new Form("");
form.append("Select your location");
form.append(floor);
form.append(location);
form.addCommand(backCommand1);
form.addCommand(show);
form.addCommand(schedule);
form.addCommand(exitCommand );
form.addCommand(HomePage );
form.setCommandListener(this);
//=======================================================
//=======================================================
chGroup = new ChoiceGroup("Selected one of a Colleges:", Choice.EXCLUSIVE);
rpyIndex = chGroup.append("Saturday", null);
chGroup.append("Sunday", null);
chGroup.append("Monday ", null);
chGroup.append("Tuesday ", null);
chGroup.append("Wednesday", null);
// Set "reply" as the default/selected option
chGroup.setSelectedIndex(rpyIndex, true);
//======================================================
//======================================================
cGroup = new ChoiceGroup("Selected one of a Colleges:", Choice.EXCLUSIVE);
rpIndex = cGroup.append("Saturday", null);
cGroup.append("Sunday", null);
cGroup.append("Monday ", null);
cGroup.append("Tuesday ", null);
cGroup.append("Wednesday", null);
// Set "reply" as the default/selected option
cGroup.setSelectedIndex(rpIndex, true);
//=========================================================
//=========================================================
form2 = new Form("");
choiceGroupIndex = form2.append(chGroup);
form2.addCommand(backCommand1);
form2.addCommand(show);
form2.addCommand(schedule);
form2.addCommand(exitCommand );
form2.addCommand(HomePage );
form2.setCommandListener(this);
//===================================================
formsh = new Form("");
choiceGroupIndex = formsh.append(cGroup);
formsh.addCommand(backCommand1);
formsh.addCommand(show);
formsh.addCommand(schedule);
formsh.addCommand(exitCommand );
formsh.addCommand(HomePage );
formsh.setCommandListener(this);
}
public void startApp() throws MIDletStateChangeException {
display.setCurrent(First);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
class Test implements Runnable {
Midlet midlet;
private Display display;
String text;
public Test(Midlet midlet) {
this.midlet = midlet;
display = Display.getDisplay(midlet);
}
public void start() {
Thread t = new Thread(this);
t.start();
}
public void run() {
StringBuffer sb = new StringBuffer();
char[] s=new char[8];
try {
HttpConnection c = (HttpConnection) Connector.open(url);
c.setRequestProperty(
"User-Agent","Profile/MIDP-1.0, Configuration/CLDC-1.0");
c.setRequestProperty("Content-Language","en-US");
//c.setRequestMethod(HttpConnection.POST);
// DataOutputStream os =
// (DataOutputStream)c.openDataOutputStream();
// os.writeUTF(text.trim());
// os.flush();
// os.close();
// Get the response from the servlet page.
DataInputStream is =(DataInputStream)c.openDataInputStream();
// is = c.openInputStream();
int ch;
String m="";
int x;
// sb = new StringBuffer();
list = new List("Employee List", Choice.IMPLICIT);
//show = new Command("Show", Command.OK, 1);
while ((ch = is.read()) != -1) {
sb.append((char)ch);
if ((char)ch == '\n')
{ //break;
//sb.toString();
x=sb.length();
list.append(sb.toString(), null);
sb.delete(0, x);
}
//display = Display.getDisplay(this);
}
// showAlert(sb.toString());
is.close();
c.close();
list.addCommand(backCommand1);
list.addCommand(show);
list.addCommand(schedule);
list.addCommand(exitCommand );
list.addCommand(HomePage );
display.setCurrent(list);
list.setCommandListener(midlet);
} catch (Exception e) {
//showAlert(e.getMessage());
}
}
/* This method takes input from user like text and pass
to servlet */
public void getServlet(String text) {
this.text = text;
}
/* Display Error On screen*/
private void showAlert(String err) {
Alert a = new Alert("");
a.setString(err);
a.setTimeout(Alert.FOREVER);
display.setCurrent(a);
}
}
public void commandAction(Command c, Displayable d) {
if (d == First){ if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();
} else if (c == backCommand1) {
display.setCurrent(form);
} else if (c == okCommand) {
display.setCurrent(list3);
}}
else if (d == list3){
if (c == Open1){
display.setCurrent(Room);
//str = tb.getString();
}else if (c == backCommand1) {
display.setCurrent(First);}
else if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();}
else if (c == List.SELECT_COMMAND){
String roomch=list3.getString(list3.getSelectedIndex());
if(roomch != null)
{
if(roomch.equals(" Room")){
display.setCurrent(Room);
}
}
}
}
else if (d == Room){
if (c == Open1){
//str = tb.getString();
test = new Test(this);
test.start();
test.getServlet(str);
}
else if (c == backCommand1) {
display.setCurrent(list3);}
else if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();}
else if (c == List.SELECT_COMMAND){
String roomch=Room.getString(Room.getSelectedIndex());
if(roomch != null)
{
if(roomch.equals("Search for Specific Class")){
test = new Test(this);
test.start();
test.getServlet(str);
}
if(roomch.equals("Search for empty Class")){
display.setCurrent(formsh);
/*test = new Test(this);
test.start();
test.getServlet(str);*/
}
}
}
}
else if (d == list){
if (c == show){
display.setCurrent(form);
//str = tb.getString();
}else if (c == backCommand1) {
display.setCurrent(Room);}
else if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();}
else if (c == schedule) {
display.setCurrent(form2);}
}
else if (d == form){
if (c == show){
display.setCurrent(form);
//str = tb.getString();
}else if (c == backCommand1) {
display.setCurrent(list);}
else if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();}
else if (c == schedule) {
display.setCurrent(form2);}
}
else if (d == form2){
if (c == show){
display.setCurrent(form);
//str = tb.getString();
}else if (c == backCommand1) {
display.setCurrent(list);}
else if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();}
}
else if (d == formsh){
if (c == show){
display.setCurrent(form);
//str = tb.getString();
}else if (c == backCommand1) {
display.setCurrent(Room);}
else if (c == exitCommand) {
destroyApp(true);
notifyDestroyed();}
}
}
}
/*
