One important thing to remember is that it's not always necessary to
over-complicate things . Simply because you CAN do it with reactor doesn't
mean that you HAVE to. Although I think Qasim solution is an elegant one
there doesn't seem any reason to be stuck on something like this. A simple
standard validation template can be run in Model-Glue doing normal
validation methods.

Alas, it's hard to practice what you preach and I did end up using reactor
for the solution. Here are the code snippets of how I solved this issue:

// Point to the reactor adaptor
reactorAdapter = getModelGlue().getOrmAdapter();

// Load the user record based on the user id
userRecord=reactor.createRecord("oe_user").load(user_id=userID);

// Validate the user data
validation = reactorAdapter.validate("oe_user", userRecord);

// Custom Validation to ensure the password and the confirm password were
the same
if(arguments.event.getValue('password') NEQ arguments.event.getValue
('password_confirm'))
 validation.addError('password', 'The password and password confirmation
must be the same.');

// If there was an error throw a validation error
if((userRecord._getErrorCollection().hasErrors())){
 // Assign the validation errors and setup the object for validation
 arguments.event.setValue("oe_userValidation", validation.getErrors());
 arguments.event.setValue("oe_userRecord", userRecord);
 arguments.event.addResult("validationError");
 return;
}

Hope that helps,
Roy


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to