concept proxy in category gwt

appears as: proxy, proxies, proxies
GWT in Action

This is an excerpt from Manning's book GWT in Action.

When you fetch data from the server, RequestFactory copies the data into the proxy instance, and when you save a proxy, RequestFactory copies it back to the server-side model. Because you aren’t sharing classes, you have almost no restrictions on your server-side classes. In contrast, with GWT-RPC you use your domain objects on both the client and server sides, so you can use GWT-compatible code and it must be serializable.

In this section we’ll be grabbing YouTube data yet again, but this time it will be returned as an XML document. Because of the browser’s same-origin policy, we can’t fetch the XML document from Google directly and will need to use a proxy.

Listing 12.10. Adding the proxy servlet to the web.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>proxy</servlet-name> <servlet-class>com.manning.ch12.xml.server.Proxy</servlet-class> </servlet> <servlet-mapping> <servlet-name>proxy</servlet-name> <url-pattern>*.proxy</url-pattern> </servlet-mapping> <!-- ...other stuff omitted... --> </web-app>

12.6.2. Calling the proxy from GWT

Calling the proxy from GWT is going to look similar to the RequestBuilder example from the beginning of this chapter. If you missed that discussion, you can read all about it in section 12.2.