Difference between revisions of "Teams Winter 2011/team1/BlackBerry/Add Elements to Add Screen"

From CDOT Wiki
Jump to: navigation, search
(Created page with '=== 6. Add elements to Add Screen === 6.1. This application is using a dialog window to add a student.<br/> 6.2. Implement <code>AddCommandHandler</code> by implementing <code>Co…')
 
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
=== 6. Add elements to Add Screen ===
+
=== 6. Implement Add Student Option ===
 
6.1. This application is using a dialog window to add a student.<br/>
 
6.1. This application is using a dialog window to add a student.<br/>
 
6.2. Implement <code>AddCommandHandler</code> by implementing <code>CommandHandler</code> as anonymous class:
 
6.2. Implement <code>AddCommandHandler</code> by implementing <code>CommandHandler</code> as anonymous class:
  <pre>
+
  <source lang="java">
 
   addItem.setCommand(new Command(new CommandHandler() {
 
   addItem.setCommand(new Command(new CommandHandler() {
 
         public void execute(ReadOnlyCommandMetadata metadata, Object context) {
 
         public void execute(ReadOnlyCommandMetadata metadata, Object context) {
Line 20: Line 20:
 
           }
 
           }
 
         }));
 
         }));
  </pre>
+
  </source>
 
6.3. Run the application and select "''Add student''" from the menu:<br/>
 
6.3. Run the application and select "''Add student''" from the menu:<br/>
[[Image: BB_add.png | 300px ]]]
+
[[Image: BB_add.png | 300px ]]<br/>
 +
6.4. Type in the student's first and last name, and e-mail address:<br/>
 +
[[Image: BB_add2.png | 300px]]<br/>
 +
6.5. Click save. The list should get updated:<br/>
 +
[[Image: BB_add3.png | 300px]]

Latest revision as of 19:39, 10 April 2011

6. Implement Add Student Option

6.1. This application is using a dialog window to add a student.
6.2. Implement AddCommandHandler by implementing CommandHandler as anonymous class:

  addItem.setCommand(new Command(new CommandHandler() {
         public void execute(ReadOnlyCommandMetadata metadata, Object context) {
             String[] selections = {"Add","Cancel"};           
             Dialog addDialog = new Dialog("Add Student", selections, null, 0, null);          
             EditField inputField1 = new EditField("Student's firstName: ","");           
             addDialog.add(inputField1); 
             EditField inputField2 = new EditField("Student's lastName: ","");           
             addDialog.add(inputField2);                 
             EditField inputField3 = new EditField("Student's email: ","");           
             addDialog.add(inputField3);
               
             // Display the dialog and add a new element to the list
             if(addDialog.doModal() == 0) {
                 addElementToList(new Student(inputField1.getText(),inputField2.getText(),inputField3.getText()));
             }
          }
        }));

6.3. Run the application and select "Add student" from the menu:
BB add.png
6.4. Type in the student's first and last name, and e-mail address:
BB add2.png
6.5. Click save. The list should get updated:
BB add3.png