This is driving me nuts because i can tell i'm not explaining what i mean well
- mea culpa.
Let's use an example:
I have a person bean, with fields id, name, and email.
I have an instance of this bean:
id 1
name Matt
email [EMAIL PROTECTED]
I have a person DAO, with methods
load(id) -> returns person bean
save(person bean) -> returns boolean.
I have two forms: one used to edit both the name and email of a person, one
used to edit only the email. Both embed the id in a hidden field so i know
which user to update.
My problem: how to avoid "blanking out" the name field of a person when
processing the second form.
Solution: for both forms, follow this method:
- user submits form
- use id field to load the person bean
- call the appropriate setters, depending on which form you used:
form one: call setName and setEmail
form two: call setEmail ONLY
- call personDAO.save() and pass it your bean.
Now, in the case of form two, you will NOT overwrite the name (Matt) because
the value of getName() *IS* "Matt". You will not need to use a bunch of ugly IF
statements in your SQL, you will update every database field each time - but in
this case, the before and after values are *both* "Matt"
Does that make more sense?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:236615
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54