Prev | Current Page 641 | Next

Frank Zammetti

"Practical DWR 2 Projects"

The one option used here, escapeHTML, is needed because
without it, the markup generated by the formatter will be displayed on the screen as-is, which
obviously isn??™t what we want.
Adding a favorite is handled by the addReportToFavorites() method, and this simple
method is seen here:
this.addReportToFavorites = function() {
if (this.username == null) {
alert("Sorry, you must be logged on to add favorites");
return;
}
var reportName = dwr.util.getValue("favorites_reportsList");
if (reportName == "") {
alert("Sorry, you must select a report first");
return;
}
reportName = reportName.split("~~")[0];
FavoritesWorker.addReportToFavorites(this.username, reportName,
{ callback : RePortal.updateFavoritesCallback }
);
}
After a check to ensure the user is logged in (otherwise he or she can??™t add favorites), the
dwr.util.getValue() method is used to retrieve the name of the currently selected report, and
this is checked to ensure a report is actually selected. Finally, a call is made to FavoritesWorker.
addReportToFavorites(), which is the remote class on the server that handles the database
update to add this favorite to the user??™s list of favorites. Finally, upon return from the server,
the updateFavoritesCallback() method is called, which updates the favorites list in the UI so
the new favorite shows up immediately.


Pages:
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653