event.paramValue improvement

Could we add a new function named paramValues() that params a set of
values so we don't have to call paramValue() a bunch of times in
succession?

So this code:

event.paramValue("myvar1", 1 )
  .paramValue("myvar2", 2)
  .paramValue("myvar3", 3);

Would turn into:

event.paramValues( params = { "myvar1" = 1, "myvar2" = 2, "myvar3" =
3 }, private=false );

A simple structAppend could be used to get them into the event
collection.

If this were to happen I think it would be better than if
event.paramValue() returned the set value rather than the event
object. That way we could use the event.paramValue inline with other
operations.

So instead of:

event.paramValue("orderby", "name");
items = service.list("entityName", {}, event.getValue("orderby") );

I could simply do:

items = service.list("entityName", {}, event.paramValue("orderby",
"name") );

Yes I could use the default argument of getValue() but the advantage
of using paramvalue() it set's the value so I don't have to provide
the default for each getValue(). Less refactoring if I want to change
the default too.

thoughts?

.brett

Aside: You can use the request context decorator to make this behave however you desire or to add that functionality for yourself.

  • Gabriel

Yep, already using one. Just don't like to keep all the good ideas to
myself.

.brett

Isn’t event.paramValue(“foo”,""); basically as convenient as param name=“foo” default=""; ? This seems like an unnecessary change to the core in my opinion.

Yeah it is, and it is not necessary. CFScript sucks though but if I
am going to use the event variable functions I would like it to do
more than what CFScript does. Less coding is what is better for me.

.brett