Changes

Jump to: navigation, search
no edit summary
8.1. In order to Implement the Edit Student menu option, firs we have to make sure that our Student class has all setters and getters we need, so we have to add the following methods to the <code>Student</code>:
<presource lang="java">
public String getFirstname(){
}
</presource>
8.2. Then we should make sure that our StudentList class which extends SortedReadableList, can edit it's elements, so we have to add the following method to the class <code>StudentList</code>:
<presource lang="java">
void updateElement(Object oldElement, Object newElement){
}
</presource>
8.3. Now we need to add edit menu option to our application, so we should add it to <code>ViewStudentApp</code> class:
<presource lang="java">
// Added for Edit Student
));
</presource>
If we are at the main screen of the application and press the menu button of our device we ca see the result:<br/>
First we need a method in <code>ViewStudentApp</code> class, which updates student list and refreshes the view:
<presource lang="java">
void editListElement(Student studentOld, Student studentNew){
}
</presource>
Then we need to modify the execute() method of the editItem's CommandHandler:
<presource lang="java">
public void execute(ReadOnlyCommandMetadata metadata, Object context) {
// TODO Auto-generated method stub
}
</presource>
8.5. Here is how the result looks like:<br/>
1
edit

Navigation menu