Hi,
Whenever I'm working in JS, I find myself times and times again using a
certain pattern in order to avoid an extra call to the server. I dump
into the web page a JSON object (serialized by the server) inside a
SCRIPT tag that is then interpreted by the browser as part of the normal
flow. The alternative would be to make an additional Ajax request, which
is unnecessary form my point of view.
For example:
<script>
var DB_DATA = {
users: <?php echo json_encode(fetch_users_from_db()); ?>
};
window.onload = function () {
// disp
display_users(DB_DATA.users);
refreshButton.onclick = function () {
fetch_users_from_server(function (users) {
display_users(users);
});
};
};
</script>
As far as my GWT knowledge goes, I can do the same thing in GWT using
JSNI, with something like this:
public native void displayUsers()/* {
display_users(DB_DATA.users);
} */;
However, I was wondering if there's some GWT specific pattern, that
would also allow some compile time checks for the presence of the
generated JS variable (similar to how CSS files are checked to see if
all the required CSS classes are declared).
Thanks!
--
Ionuț G. Stan | http://igstan.ro
--
You received this message because you are subscribed to the Google Groups "Google
Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.