You are on page 1of 14

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

BACK . • Terdapat 2 Form yang akan digunakan seperti yang diatas dan diisi command untuk OK . 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 . sama dengan struktur data pada tabel dalam sebuah database. 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.baris dan kolom. EXIT dari Form tersebut . Screen View Program • Form Input Data . berikut contohnya : 1. Berikut adalah Menampilkan Nama dengan menggunakan Text Field -> String Item dari Form 1 Kedalam Form 2 .

Kode program .• Form Output Data 3.

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

// 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. This method is used by all actions in the * design for switching displayable. */ public void startMIDlet() { // write pre-action user code here switchDisplayable(null.*/ 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. getForm()). * * @param alert the Alert which is temporarily set to the display. */ 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. then <code>nextDisplayable</code> is set * immediately * @param nextDisplayable the Displayable to be set */ . The * <code>display</code> instance is taken from * <code>getDisplay</code> method. * if <code>null</code>.

} else { display.public void switchDisplayable(Alert alert. } // 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. Displayable displayable) { // write pre-action user code here if (displayable == form) { if (command == exitCommand2) { // write pre-action user code here exitMIDlet(). getForm()). // write post-action user code here } else if (command == exitCommand) { // write pre-action user code here exitMIDlet(). nextDisplayable). openRecord(). // write post-action user code here } } // write post-action user code here } . getForm1()). if (alert == null) { display.setCurrent(nextDisplayable). // write post-action user code here } else if (command == okCommand) { switchDisplayable(null.setCurrent(alert. * * @param command the Command that was invoked * @param displayable the Displayable where the command was invoked */ public void commandAction(Command command. } } else if (displayable == form1) { if (command == backCommand2) { // write pre-action user code here switchDisplayable(null. readRecords(). Displayable nextDisplayable) { // write pre-switch user code here Display display = getDisplay(). writeRecord(textField.getString()).

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

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

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

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

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

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

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

Input data Gambar 2.Gambar 1. Outuput Hasil .