*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: Update method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: Update method" Watch "NX: Update method" New topic
Author

NX: Update method

Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
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

Joined: Jul 03, 2003
Posts: 435
The string[] should contain {new first field value, new second field value .....}
Tony
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
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

Joined: Jul 03, 2003
Posts: 435
No just the values for the new record.
Tony
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
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

Joined: Jul 11, 2003
Posts: 1392
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

Joined: Jul 30, 2003
Posts: 493
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


SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Thanks Bharat and Tony. Yes, I got it now.
Joyce
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: Update method
 
Similar Threads
Converting an application using xstl from struts to struts 2
need help in pivot
has anyone encountered this problem when using xpath
Auditing Table
need help in updating data using hibernate hql