Hi Alexander,

Am 14.03.2007 um 09:25 schrieb Alexander Weisser:

[snip]
>       var rpc = new qx.io.remote.Rpc(
>                   "http://localhost:8080/qooxdoo/.qxrpc";,
>                   "qooxdoo.test"
>       );
>       rpc.setCrossDomain(true);
[snap]

> It is the standart skeletton with another EventHandler. But this  
> doesn´t
> work on another PC. I think the rpc.setCrossDomain(true); doesn´t  
> work.

The problem is that you're still using "localhost" as the target  
domain. Of course, this only works when your browser is on the same  
machine as the server application.

Maybe I should explain the development and testing of RPC calls in  
more detail: Usually, you package your application in a .war file  
that looks like this:

/
   index.html
   script/
     ...
   WEB-INF/
     lib/
       ...
     web.xml

You request the index.html in a browser (either on the local machine  
or a remote one), the index.html loads the scripts, and you make RPC  
calls _without_ calling setCrossDomain(true) (since the service is on  
the same machine where you load the HTML page from).

To setup the RPC instance, you can use code like this:

     var rpc = new qx.io.remote.Rpc(".qxrpc", "qooxdoo.test");

This should work no matter whether you're accessing the page as  
http://localhost/... or http://server-address/...  The only downside  
is that you have to re-package the .war file every time a script of  
yours changes, so your turnaround time during development becomes  
unnecessarily long. One solution is to use a development environment  
where you can directly edit the webapp resources (without  
repackaging). The other is to use cross-domain calls during  
development. This way, you can load the HTML page (and therefore -  
indirectly - the scripts) from the file system, and a refresh in the  
browser is enough to see the changes.

To make your application work both ways, you can set up the RPC  
instance like this:

     var href = location.href;
     var rpc;
     if (href.indexOf("file") == 0) {
         rpc = new qx.io.remote.Rpc("http://localhost:8080/ 
qooxdoo/.qxrpc",
                                    "qooxdoo.test");
         rpc.setCrossDomain(true);
     } else {
         rpc = new qx.io.remote.Rpc(".qxrpc", "qooxdoo.test");
     }

When the page is loaded from the file system, the localhost URL is  
used. When it's loaded in the usual way (from the Java server), the  
actual server URL is used.

To make the file:// part work, you also have to disable referrer  
checking during development in your web.xml (since Firefox doesn't  
send referrers for file:// URLs):

         <servlet-name>rpc</servlet-name>
         <servlet-class>
             net.sf.qooxdoo.rpc.RpcServlet
         </servlet-class>
         <init-param>
             <param-name>referrerCheck</param-name>
             <param-value>public</param-value>
         </init-param>

Now you can call your server code from pages loaded from anywhere.  
However, don't use this configuration for production! Ever! Before  
deploying a production version, make sure the referrerCheck is set to  
strict (or just remove the whole parameter).

Regards,

   Andreas


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to