Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Suggestion: event.paramValue()
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Robert Rawlins  
View profile  
 More options Dec 19 2011, 9:25 am
From: Robert Rawlins <rob...@supporttime.com>
Date: Mon, 19 Dec 2011 14:25:46 +0000
Local: Mon, Dec 19 2011 9:25 am
Subject: Re: [Model-Glue] Suggestion: event.paramValue()

Hi Dan,

You're quite right - it does sort of do it. I use the getValue default argument on a regular basis within my views - but I hadn't realised that it would set the value too if it didn't already exist before returning it.

This will certainly do the job - it just looks a little odd from a semantic point of view within the controller. Calling get when what I'm really intending to do it set.

Given that it's a simple implementation do you think there is a case for adding a new method to the API as I suggested? It would make code within the controller more meaningful if I was calling pramValue() I think.

Robert

On 19 Dec 2011, at 14:11, Dan Wilson wrote:

> I think the event.getValue() method sort of does this.

> Take a look here:  http://docs.model-glue.com/wiki/ReferenceMaterials/EventApi#GetValuen...

> DW

> On Mon, Dec 19, 2011 at 7:11 AM, Rawlins <rob...@supporttime.com> wrote:
> Hello Guys,

> I'm finding myself with an increasing need to param a value into the event (set it only if it does not already exist).

> One example use case for this is form validation.

> In my controller method for the form I need a validation result object, which contains all the errors and other failure information.

> This object could come from two places - It could be that the user has been passed back to this form page after a failed validation, with the result object preserved in the event, or if one doesn't already exist and this is the first time viewing the form, I'll create a new result object for them.

> This results in handler code that looks something like this:

>                    <!--- Param the validation result into the object too. --->
>                    <cfif NOT event.valueExists("ValidationResult")>
>                            <cfset event.setValue("ValidationResult", Beans.ValidateThis.newResult()) />
>                    </cfif>

> This works just fine, but it's needlessly verbose. I'd like to propose a change to the event object API that makes this much easier - here are a couple of ideas:

> event.paramValue('name', 'value');

> or a modification to the current setValue() method, which adds a 3rd argument that defines if the value should be overwritten, if false and a previous value exists for the key then it's left intact.

> event.setValue("name", "value", false);

> Does anyone else have some ideas on this? am I looking at this situation in completely the wrong way? does something already exist like this?

> Thanks.

> Robert

> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog

> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to model-glue@googlegroups.com
> To unsubscribe from this group, send email to
> model-glue+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en

> --
> Plutarch - "The mind is not a vessel to be filled but a fire to be kindled."

> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog

> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to model-glue@googlegroups.com
> To unsubscribe from this group, send email to
> model-glue+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.