Maintaining state [message #4812] |
Wed, 08 July 2015 16:10 |
rafs
Messages: 69 Registered: May 2015
|
Member |
|
|
It seems that Radicore saves the state of the page before going down into a sub-page, then loads the saved state upon return. I am wondering how common this technique is in other webapp frameworks. I took a webapp development class a decade ago and I seem to recall that we saved state by passing parameters into subpages, but I can't be sure.
|
|
|
|
|
|
Re: Maintaining state [message #4937 is a reply to message #4910] |
Wed, 26 August 2015 21:46 |
rafs
Messages: 69 Registered: May 2015
|
Member |
|
|
I am back to this. I have read about your use of $_SESSION superglobal to pass 'state'.
What is your advice on the best way to view the state info as each new script (page) is called?
I want to see what the $where contains that is being called for the new page.
The technique I am testing (with Eclipse) is to set a breakpoint just after the standard transactions controllers at the initSession().
There under $_SESSION >> 'pages', I see my new (child) page that is being called with a few items: task_id, task_array, pattern_id, 'mypage(link1)', but I am looking for the element that I selected in the parent, 'gid' = '1', but it is not there.
[Updated on: Wed, 26 August 2015 21:59] Report message to a moderator
|
|
|
Re: Maintaining state [message #4940 is a reply to message #4937] |
Thu, 27 August 2015 06:08 |
AJM
Messages: 2368 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
If you look at the initSession() function inside include.session.inc you will see that it looks for an entry in $_SESSION['pages'][$PHP_SELF]), and then extracts $_SESSION['pages'][$PHP_SELF][$task_id] into a global variable called $script_vars. The contents of $script_vars is then extracted into individual variables such as $where, $search, et cetera.
There is a separate copy of $script_vars for each script and this is is constructed BEFORE the script is called by the calling script. This means that if script "A" calls script "B" then $script_vars for "B" will be constructed by "A" using the scriptNext() function, and this will include any arguments that need to be passed from "A" to "B". When control is passed from "A" to "B" the $script_vars for "A" will remain in $_SESSION so that when control is returned to "A" it will be able to resume from where it left off. When "B" terminates the scriptPrevious() function will cause $script_vars for "B" to be dropped (unless the "Keep data" option on MNU_TASK is set), update the $script_vars for "A" with any values that need to be returned, then cause "A" to be reactivated. Script "A" will then be able to resume from where it left off, but now it will also have any values that were returned from script "B".
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|