Re: D2W Custom component
Re: D2W Custom component
- Subject: Re: D2W Custom component
- From: Chuck Hill <email@hidden>
- Date: Thu, 21 Apr 2005 10:23:11 -0700
Yes, using the EOStateTransition interface will work for this.
However, if the method below is setPassword and you are just encrypting
it, then it might not be a horrible thing to do. However, doing it
like that you risk having EOF call this method with the already
encrypted password and double encrypting it. I'd add another method,
setPlainTextPassword(), bind to that, and then in that method do the
encrypting and pass the value off to setPassword().
Chuck
On Apr 21, 2005, at 3:51 AM, Erwin wrote:
As I use D2W for the first time, I try to understand where and when I
can modify EO records before Save..
I found a trick but its only a trick :
in D2WEditPassword
public void setValue(String newValue) {
Siteuser aUser = (Siteuser) new Administrator();
String epwValue = aUser.getEncryptedPassword(newValue);
object.takeValueForKey(epwValue, key);
}
It works fine , I can save a new record with encrypted password...
BUT I am sure that's not the correct way to do that...
In Siteuser.java, I can initialize the EO record with :
public void awakeFromInsertion(EOEditingContext editingContext) {
...
}
I should be able also to modify a value before insertion... using
saveChange() or better
using willUpdate() in the EOStateTransition interface from PWO maybe
I am not sure ...
Erwin
Le Apr 21, 2005, à 2:18 AM, John Bruce a écrit :
I set values in my D2W components this way:
public void takeValuesFromRequest(WORequest request, WOContext
context) throws NSValidation.ValidationException {
super.takeValuesFromRequest(request, context);
if (isEdit()) {
object().takeValueForKeyPath(value, propertyKey());
}
}
also in this case I'd separate out the encrytion method and call it
directly - so for example I would have in Siteuser.java
public void encryptAndSetPassword(final String password) {
this.setPassword(transformString(password, Cipher.ENCRYPT_MODE));
}
then modify the D2W component to include:
public void takeValuesFromRequest(WORequest request, WOContext
context) throws NSValidation.ValidationException {
super.takeValuesFromRequest(request, context);
if (isEdit()) {
Siteuser user = (Siteuser)object();
user.encryptAndSetPassword(value);
}
}
I'm not sure what specifically is causing your problem without seeing
more code but the above is the way I would've implemented it.
HTH
Cheers,
John
On 4/21/05, Erwin <email@hidden> wrote:
I am trying to use (for the 1st time) D2W to test my EOModel
I have a D2WEditPassword custom component that's doing its job (take
the value in a pwd Txtfield)
D2WEditpassword.java (extends WOComponent)
.....
public String value() {
return (String) object.valueForKey(key);
}
public void setValue(String newValue) {
object.takeValueForKey(newValue, key);
}
.....
I would like this value to be encrypted via the setPassword() in my
Siteuser class before being written to the DB
(as it will be in my WOApp) but I just get the String value in my
DB..... why ? how can I do it ? (hint in doc...)
Thanks erwin
Siteuser.java (extends EOGenericRecord)
.....
public void setPassword(String password){
setCredential(transformString(password,
Cipher.ENCRYPT_MODE));
}
....
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
village.net
This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden