Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Update method

 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I couldn't see this thread in the forum. So I repost it.
Here is the question.
// Modifies the fields of a record. The new value for field n
// appears in data[n].
public void update(int recNo, String [] data)
throws RecordNotFoundException;
What should appear in String [] data?
1. {new_value, old_value, old_value, old_value}
OR
2. {new_value, null, null, null}
Many thanks.
Joyce
 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The string[] should contain {new first field value, new second field value .....}
Tony
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tony.
What about the old values? Do I need to include the old values inside the
[]data? i.e. data = {new first value, new second value, old third value}
Joyce
 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No just the values for the new record.
Tony
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,
So the values appear in data is in this form:
data = {new lst field value, new 2nd field value, null, null, null, null}
with the old values will be passed in as null. Am I right?
Joyce
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still confused. Are these the correct values that stored in the String [] data of update(...) method?
data = {new lst field value, new 2nd field value, null, null, null, null}
where the old values are being passed in as null.
Please help, thanks.
Joyce
 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Joyce,
What Tony explained to you is correct. Let us take it nice and easy; step-by-step:
1. A set of records is displayed in the JTable Swing UI widget.
2. The user is invited to select a record to update.
3. The user edits this record, may be modifies field number 1, and field number 3 and field number 6 for example.
4. You take the ENTIRE row or record both new values in fields 1, 3, and 6 TOGETHER with old values in fields 2, 4, and 5. The ENTIRE row or record both new and old values together is passed to the update method as an array of Strings. Therefore, your update method simply overwrites the ENTIRE old record with the passed array of Strings which will contain both the new and the old values (new values for fields 1,3, 6 and old values for 2, 4, 5. This way, your update method need not worry about which fields were modified and which were left alone.
Hope this helps.
Regards.
Bharat
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bharat and Tony. Yes, I got it now.
Joyce
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic