sessionStorage issue (and kudos to beanFactory)

Good afternoon.

I am populating a bean (myBean) as part of a shopping cart payment
wizard. myBean just has firstName, lastName, city, state as
properties. The wizard accepts the aforementioned columns and then
goes to a validation page which accepts CC info. CC info is sent to
the merchant gateway and a return code comes back. if the return code
is true then we save myBean to the database, if false, then we reset.
So in summary:

1. Accept name, city, state (submit)
2. Review name, city, state and add credit card info (submit)
3. Respond with success or failure.

At step 2, I temporarily store myBean in a session. myBean is
populated using the beanFactory plugIn (btw, beanFactory works
great...i just hope it will work with the IBO stuff I've been piecing
together, but I digress). Once I submit the CC info from step 2, the
bean in my session is cleared out and replaced with the values from
the CC information. Does anyone have any idea what's going on here?
Code samples below:

[code name="admin.cfc" type="handler"]
<!--- STEP 1 PAGE --->
  <cffunction name="myAdmin" access="public" returntype="void"
    <cfargument name="Event" type="coldbox.system.beans.requestContext">

      Event.setValue("header", "My Person Administration");
      LOCAL.myService = CreateObject("component",
      Event.setValue("myProxy", LOCAL.myService.proxy());

<!--- STEP 2 PAGE --->
  <cffunction name="myConfirm" access="public" returntype="void"
    <cfargument name="Event" type="coldbox.system.beans.requestContext">

      LOCAL.myBean = CreateObject("component",

      Event.setValue("header", "Confirm New Information");
      Event.setValue("amount", 100.00);

      getPlugin("sessionStorage").setVar("myBean", LOCAL.myBean);



<!--- STEP 3 PAGE --->
  <cffunction name="mySave" access="public" returntype="void"
    <cfargument name="Event" type="coldbox.system.beans.requestContext">

      dump(getPlugin("sessionStorage").getVar("myBean")); // custom
function to convert bean to struct

[code name="myBean.cfc" type="bean"]
  <cfproperty name="firstName" type="any" />
  <cfproperty name="lastName" type="any" />
  <cfproperty name="city" type="any" />
  <cfproperty name="state" type="any" />

  <cffunction name="init" access="public" output="false"
    <cfreturn THIS/>

Any assistance would be greatly appreciated.

~possum jones

Some observations:

LOCAL.myBean = CreateObject(“component”,“”).init();

You can enhance it by doing:
LOCAL.myBean = getPlugin(“beanFactory”).populateBean(“”);

As for your problem, can you post step 3. You only have a dump there.

Thanks for the tip on populateBean. It works great and cuts back on
some of the code!

As for the admin.cfc code, the session value has changed at the time
of the dump() and abort(). Here is the remaining code:

[code name="admin.cfc" type="handler" special="continued"]
  LOCAL.myService = CreateObject("component",
    Event.setValue("header", "Save Successful");
    Event.setValue("header", "Save Failed");

Thanks a bunch because I have been on this bean/IBO/vo thing since the
last time we chatted last week. :D!

~possum jones

It's almost as if the beanFactory plugin persists across the requests
and continues to populate the sessionBean until the bean is destroyed
because even setting the value to SESSION.myBean gets updated on the
submit from 2-to-3.

Is there an alternate method for persisting across submissions thru
Coldbox? I am trying despiratly not to pass the values thrue the URL
or create a form of hidden variables underneath.

go into debug mode and check the timers panel. See if anything unusual is happening as the event object traverses the request. It might be there is something you have that is running. The factory does not persist or populate with out explicit calls, so it might be something else running. Check on reuqest start handler.

is this cf8? what version of coldbox?

CF8 Coldbox 2.6.0 RC1

Nothing else appears to be you think it may be because
the CC form in STEP 2 has City and State fields? This is what the bean
is being overwritten with.

BTW you use LOCAL scope. Did you declare it like ?

Doesn’t solve you problem though.

No, I've being using "LOCAL." going way back to CF5. I am a disciple
of all variables being scoped so local is a made-up derivative of

okay, here's what i did to get the desired effect:

PROBLEM: want to persist form values across multiple pages of a wizard
using a bean.

SOLUTION: I created a base class under a "beans package" which
contains a toStruct and fromStruct method. [toStruct] creates a
structure dynamically from the <cfproperty> name/value pairs.
[fromStruct] populates the bean from a passed struct. It skips any
struct key names which do not match names in the bean properties.

I was unable to resolve session bean persistence in my example, but I
stored the form values as a struct instead of the entire bean and it
persists across pages.

~possum jones

I think ernst is right. If you do LOCAL, then it will be “variables.local” that means that it will be persisted in the variables scope of the handler. The handler is cached by default, so you might end up with funky side effects.


Doesn’t mean its the solution to your problem, but its something to look at. Its hard to try and reproduce what you have, especially since its not an error.

Hi Possum,

I would suggest to take a hard look to populateBean method.

Its automatically populate bean from requestcontext---> (URL,FORM).

I am sure that if you look at your forms of each step, something might
be overriding.