cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Hermann <christoph.herm...@guschtel.de>
Subject Re: Binding framework & changing value before update.
Date Mon, 08 Aug 2005 09:51:22 GMT
Aurelien DEHAY schrieb:

Hello,

> I'm a really great beginner with the binding framework. My question is
> very simple: I've got a password field I'd like to md5() before putting
> it in my exist database.

I do that in flow:

	form = new Form("cforms/definition/editUser_def.xml");
	form.createBinding(bindingURI);
	
	form.load(document);
	
	var oldhash = form.lookupWidget("pass").getValue();
	print ("oldhash: " + oldhash);
	// prevent password value from leaving server
	form.lookupWidget("pass").setValue(null);
	
	// display form
	form.showForm("editUser-display-pipeline");
	
	// hash pass if entered
	if (form.lookupWidget("pass").getValue() != null) {
		//hash password
		print("hashing...");
		var hash =
Packages.de.iif.chermann.crypt.MD5.md5(form.lookupWidget("pass").getValue());
		form.lookupWidget("pass").setValue(hash);
	} else {
		print("pass not given, setting original hash");
		form.lookupWidget("pass").setValue(oldhash);
	}
	form.save(document);
	//save bean back to eXist xml db
	saveDocumentAuth(document, docName, docBaseURI, "user", "pass", "true");

HTH
Christoph

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message