Prev | Current Page 205 | Next

Frank Zammetti

"Practical DWR 2 Projects"

I then added a button to the JSP to call that method. I suggest taking a moment and using
this as a quick little exercise to help get these concepts embedded in your brain. Doing that same modification
(because it??™s not included in the downloaded code) would be a worthwhile endeavor I think.
CHAPTER 3 n ADVANCED DWR 104
As you can see, it isn??™t a whole lot different really, but the important point to take away is
that the bean that is returned is sent in the form of JSON. This is how a great deal of data interchange
between client and server is done in the Ajax world, and DWR is no exception.
WHAT??™S THIS JSON YOU SPEAK OF?
JSON, which stands for JavaScript Object Notation, is a simple data interchange format that is roughly similar
to array notation in most C-like languages. JSON is technically a subset of the object literal notation used in
JavaScript to define objects.
A quick and simple example of JSON is this: { firstName:"frank", lastName:"Zammetti" }.
If you were to execute var p = eval(json); where json is the example JSON shown here, what you
would have is an object with the fields firstName and lastName present and pointed to by the variable p
such that doing alert(p.


Pages:
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217