Hey Mark,
That is what I would usually do, but I'm guessing from his email that
he's storing the user object in the session scope and is worried that
if they don't fix their user data up, the unvalidated, unsaved data
will now show on all other pages.
For example, you change your last name to
Chumbawumbachumbawumbachumbawumbachumbawumba but last name has a 20
character max length. If he does session.User.save(LastName ,
form.LastName), the session.User.isValid() will return false, but the
session.User.getLastName() used to welcome you to every page as hello
FirstName LastName will show the invalid version for the rest of the
session.
Michael - was that the concern you had? If so I'd consider instead of
editing (what I call) the SiteUser, just load and edit a User object
and then you can session.SiteUser =
UserService.getByID( session.SiteUser.getID() ); to reload any changes
to the site user in session scope once the new User object has been
successfully validated and saved.
Would that work?
Best Wishes,
Peter
On Sep 24, 2008, at 1:56 AM, Mark Mandel wrote:
>
> Where is the validation failing? At a form level, or at the object
> level?
>
> I will commonly have code that looks like:
>
> obj.setFoo(value);
> if(object.validate());
> {
> save(obj);
> }
>
> return obj;
>
> Then if the object doesn't validate, I can pass it back to my view,
> and it can display the invalid data just as it would do normally.
>
> That make sense?
>
> Mark
>
> On Wed, Sep 24, 2008 at 3:27 PM, Michael Sharman <[EMAIL PROTECTED]>
> wrote:
>>
>> Hi guys,
>>
>> I'm after some suggestions for a quite common scenario. I have a site
>> where users are registered (i.e. they have a profile) and have the
>> option of updating their details after logging in.
>>
>> I load the "update" form's controls from a User.cfc
>>
>> e.g. <input type="text" name="email" id="email"
>> value="#oUser.getEmail()#" />
>>
>> Now when the form gets submitted validation takes place and if that
>> validation fails the update form is reloaded with an error message.
>> The problem is that I want to display the new information that the
>> user has entered even though it hasn't yet been updated in the
>> database.
>>
>> I feel I can't update the User objects "state" if the validation
>> fails
>> as the user may navigate away from the update form and as the rest of
>> the site depends on the User object's information this would be
>> potentially incorrect.
>>
>> Would I be looking at some kind of memento pattern here? Some kind of
>> a global #request.input# struct? How do people get around this,
>> hopefully without complicating/messing up views with a cfparam for
>> each User property etc
>>
>> Thanks
>>>
>>
>
>
>
> --
> E: [EMAIL PROTECTED]
> W: www.compoundtheory.com
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---