Pemrograman Mobile RMS (Record Managements System

)

Oleh : I Putu Mahendra Pramadhitya (1104505027)

Jurusan Teknologi Informasi Fakultas Teknik Universitas Udayana 2013
RMS (record managements system) merupakan kombinasi antara file system dan database management system yang dapat kita gunakan untuk menyimpan data dalam bentuk

sama dengan struktur data pada tabel dalam sebuah database.baris dan kolom. EXIT dari Form tersebut . setelah itu click dan drag dari Form 1 ke Form seperti berikut : • Diperlukannya relasi dari OkCommand ( ke Form1 ) yang dimana bila kita menekan tombol OK pada applikasi Mobile tersebut maka dia akan masuk ke Form berikutnya dan sebaliknya BackCommand diperlukan untuk mengembalikan ke Form sebelumnya . Flow View Program • Masukan Back Command pada Form1 yang diman command back diperlukan untuk memgembalikan / back ke form sebelumnya . Setelah itu masuk kedalam Form itu sendiri yang dimana seperti berikut : 2. berikut contohnya : 1. Screen View Program • Form Input Data . BACK . Berikut adalah Menampilkan Nama dengan menggunakan Text Field -> String Item dari Form 1 Kedalam Form 2 . • Terdapat 2 Form yang akan digunakan seperti yang diatas dan diisi command untuk OK .

• Form Output Data 3. Kode program .

private TextField textField. */ public dataRMS() { } //<editor-fold defaultstate="collapsed" desc=" Generated Methods "> //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize "> /** * Initializes the application. choose Tools | Templates * and open the template in the editor.midlet. private Command backCommand1.microedition. private Command backCommand2. private Command exitCommand2. The method is called before the * <code>startMIDlet</code> method. It is called only once when the MIDlet is * started.microedition. private Form form1.*.rms.*. import javax. import javax. private RecordStore rs = null. private Command exitCommand1.*. //</editor-fold> /** * The dataRMS constructor. private Command backCommand3.lcdui. private Command backCommand4.microedition. */ import javax. private Command okCommand. /** * @author toshiba */ public class dataRMS extends MIDlet implements CommandListener { private boolean midletPaused = false./* * To change this template. private Command backCommand. private StringItem stringItem. //<editor-fold defaultstate="collapsed" desc=" Generated Fields "> private Form form. private Command exitCommand. . static final String REC_STORE = "ReadWriteRMS".

*/ public void resumeMIDlet() { // write pre-action user code here // write post-action user code here } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable "> /** * Switches a current displayable in a display. */ public void startMIDlet() { // write pre-action user code here switchDisplayable(null. The * <code>display</code> instance is taken from * <code>getDisplay</code> method. * if <code>null</code>. * * @param alert the Alert which is temporarily set to the display. This method is used by all actions in the * design for switching displayable.*/ private void initialize() { // write pre-initialize user code here // write post-initialize user code here } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet "> /** * Performs an action assigned to the Mobile Device MIDlet Started point. // write post-action user code here } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet "> /** * Performs an action assigned to the Mobile Device MIDlet Resumed point. then <code>nextDisplayable</code> is set * immediately * @param nextDisplayable the Displayable to be set */ . getForm()).

setCurrent(alert. // write post-action user code here } else if (command == okCommand) { switchDisplayable(null. getForm1()). Displayable nextDisplayable) { // write pre-switch user code here Display display = getDisplay(). Displayable displayable) { // write pre-action user code here if (displayable == form) { if (command == exitCommand2) { // write pre-action user code here exitMIDlet(). openRecord(). } else { display. getForm()).getString()). // write post-action user code here } else if (command == exitCommand) { // write pre-action user code here exitMIDlet().public void switchDisplayable(Alert alert. * * @param command the Command that was invoked * @param displayable the Displayable where the command was invoked */ public void commandAction(Command command. } // write post-switch user code here } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables "> /** * Called by a system to indicated that a command has been invoked on a * particular displayable.setCurrent(nextDisplayable). // write post-action user code here } } // write post-action user code here } . nextDisplayable). writeRecord(textField. } } else if (displayable == form1) { if (command == backCommand2) { // write pre-action user code here switchDisplayable(null. if (alert == null) { display. readRecords().

addCommand(getExitCommand()).setCommandListener(this). } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form1 "> /** * Returns an initialized instance of form1 component. form1.//</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form "> /** * Returns an initialized instance of form component. // write post-init user code here } return form1. form1. form.addCommand(getBackCommand2()).addCommand(getExitCommand2()). * * @return the initialized component instance */ public Form getForm() { if (form == null) { // write pre-init user code here form = new Form("masukan data". form1.setCommandListener(this). * * @return the initialized component instance */ public Form getForm1() { if (form1 == null) { // write pre-init user code here form1 = new Form("Hasil". new Item[] {getStringItem()}). // write post-init user code here } return form. form.addCommand(getOkCommand()). * . } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand "> /** * Returns an initialized instance of backCommand component. form. new Item[] {getTextField()}).

0). 0). // write post-init user code here } return backCommand1. // write post-init user code here } return backCommand.BACK. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand "> /** * Returns an initialized instance of okCommand component. Command. Command.BACK. * * @return the initialized component instance */ public Command getOkCommand() { if (okCommand == null) { // write pre-init user code here okCommand = new Command("Ok". // write post-init user code here } return okCommand. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand1 "> /** * Returns an initialized instance of backCommand1 component.* @return the initialized component instance */ public Command getBackCommand() { if (backCommand == null) { // write pre-init user code here backCommand = new Command("Back". * * @return the initialized component instance */ public Command getBackCommand1() { if (backCommand1 == null) { // write pre-init user code here backCommand1 = new Command("Back".OK. 0). Command. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated .

} //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem "> /** * Returns an initialized instance of stringItem component. Command.BACK. * * @return the initialized component instance */ public Command getBackCommand2() { if (backCommand2 == null) { // write pre-init user code here backCommand2 = new Command("Back". // write post-init user code here } .Getter: textField "> /** * Returns an initialized instance of textField component. TextField. * * @return the initialized component instance */ public StringItem getStringItem() { if (stringItem == null) { // write pre-init user code here stringItem = new StringItem("". * * @return the initialized component instance */ public TextField getTextField() { if (textField == null) { // write pre-init user code here textField = new TextField("Input Data". // write post-init user code here } return stringItem. ""). 32. 0). // write post-init user code here } return textField. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand2 "> /** * Returns an initialized instance of backCommand2 component. "".ANY).

} //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand "> /** * Returns an initialized instance of exitCommand component. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand3 "> /** * Returns an initialized instance of backCommand3 component. Command. Command.EXIT. // write post-init user code here } return exitCommand. * * @return the initialized component instance */ public Command getExitCommand1() { .BACK. 0).return backCommand2. * * @return the initialized component instance */ public Command getExitCommand() { if (exitCommand == null) { // write pre-init user code here exitCommand = new Command("Exit". 0). } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand1 "> /** * Returns an initialized instance of exitCommand1 component. // write post-init user code here } return backCommand3. * * @return the initialized component instance */ public Command getBackCommand3() { if (backCommand3 == null) { // write pre-init user code here backCommand3 = new Command("Back".

EXIT. // write post-init user code here } return backCommand4. * . 0). // write post-init user code here } return exitCommand1. * * @return the initialized component instance */ public Command getExitCommand2() { if (exitCommand2 == null) { // write pre-init user code here exitCommand2 = new Command("Exit".BACK. // write post-init user code here } return exitCommand2.EXIT. } //</editor-fold> /** * Returns a display instance. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand2 "> /** * Returns an initialized instance of exitCommand2 component. Command. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand4 "> /** * Returns an initialized instance of backCommand4 component. Command. Command. if (exitCommand1 == null) { // write pre-init user code here exitCommand1 = new Command("Exit".0). * * @return the initialized component instance */ public Command getBackCommand4() { if (backCommand4 == null) { // write pre-init user code here backCommand4 = new Command("Back". 0).

* @return the display instance. then the MIDlet has to be unconditionally * terminated and all resources has to be released. */ public void exitMIDlet() { switchDisplayable(null.openRecordStore(REC_STORE. null). } midletPaused = false. . * * @param unconditional if true. Checks whether the MIDlet have been * already started and initialize/starts or resumes the MIDlet. */ public void destroyApp(boolean unconditional) { } public void openRecord() { try { rs = RecordStore. startMIDlet(). */ public Display getDisplay() { return Display. destroyApp(true). } /** * Called when MIDlet is started. } /** * Called to signal the MIDlet to terminate. } /** * Exits MIDlet. */ public void pauseApp() { midletPaused = true. } /** * Called when MIDlet is paused. notifyDestroyed().getDisplay(this). } else { initialize(). */ public void startApp() { if (midletPaused) { resumeMIDlet().

choose Tools | Templates. //To change body of generated methods. i <= rs. 0).length) { recData = new byte[rs. String A = new String(recData. try { rs. stringItem.println("Gagal"). len). recData.getBytes().length).println(rs. 0. int len.").setText(A). Berikut adalah hasil running program proses input data dan output hasil : .getNumRecords(). } } catch (Exception e) { System.true).getRecordSize(i) > recData. } } } catch (Exception e) { } private void writeRecord() { throw new UnsupportedOperationException("Not supported yet. if (rs. } len = rs. i++) { System. } catch (Exception e) { } } public void readRecords() { try { byte[] recData = new byte[8].getRecordSize(i)].addRecord(rec.out. rec.getRecordSize(i)).getRecord(i. } } 4.out. for (int i = 1. 0. } public void writeRecord(String str) { byte[] rec = str.

Input data Gambar 2. Outuput Hasil .Gambar 1.