Prev | Current Page 176 | Next

Frank Zammetti

"Practical DWR 2 Projects"

Perhaps a simpler explanation
is that functions in JavaScript can have inner functions. These inner functions are allowed to access all the
local variables of the containing function, and most importantly, even after the containing function returns.
Each time a function is executed in JavaScript, an execution context is created. This is conceptually the
environment as it was when the function was entered. That??™s why the inner function still has access to the
outer function??™s variables even after return: the execution context of the inner function includes the execution
context of the outer function.
So, in the previous example, the proxy stub forms an execution context that contains a reference to the
extraInformation variable. So, when it calls the realCallback() function, extraInformation is
included in the context.
Interacting with DWR on the Server
As I mentioned previously, you will generally want to write your server-side code in such a
way that it isn??™t aware that it??™s being called from DWR. This will usually not be a problem, but
sometimes it may be. With that in mind, there are some facilities DWR makes available to
interact with it from the server-side code, and that??™s what we??™re going to look at now.


Pages:
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188