On Mon, Jun 8, 2009 at 8:56 AM, Ashish
Malviya<[email protected]> wrote:
>
>
>
> Hi Team,
>
>
>
> As I can understand from this example, this SCA component is included in the
> web app by using a Javascript scaDomain.js.
>
>
>
> <script type="text/javascript" src="SCADomain/scaDomain.js"></script> is
> added to the html.
>
>
>
> Is there any way I can use this scaDomain.js in some other webapp and call
> the methods.
>
>
>
> Suppose the name of the application which is generating this Javascript is
> helloworld , we get this javascript on
>
> http://localhost:8080/helloworld/SCADomain/scaDomain.js
>
>
>
> What I want is to use this link in another application eg myhelloworld, so I
> want to do something like the following in the myhelloworld application
>
> <html>
>
> <head>
>
> <script
> src=”http://localhost:8080/helloworld/SCADomain/scaDomain.js”</script>
>
> </head>
>
> <body>
>
> </body>
>
> </html>
>
>
>
>
>
> Please let me know if it’s possible or not.
>
>
>
> Thanks and Regards
> Ashish Malviya
No i don't think that would work, and nor will trying
<implementation.widget as suggested on the other thread. The problem
is that the client requests will get sent relative to the client not
to the origin of where the SCADomain script is loaded from so the
requests get sent to the client webapp which doesn't host the services
instead of the webapp where the scadomain script was loaded from.
We might be able to fix the scripts to make this work by determining
the script origin during initilization, however its likely you'd
sooner or later endup being hit by the browser "same origin policy"
restriction. The problem is that this isn't really what the JSONRPC is
for, we should really use the JSONP protocol to do what you want but
we've not finished that binding yet.
In the meantime you can "fiddle" things to make what you want work by
explicitly defining the service yourself. So in your myhelloworld html
replace the script line:
<script type="text/javascript" src="SCADomain/scaDomain.js"></script>
with these lines:
<script type="text/javascript"
src="http://localhost:8080/sample-helloworld-jsonrpc-webapp/SCADomain/scaDomain.js"></script>
<script language="JavaScript">
scaDomain.HelloWorldService = new
JSONRpcClient("http://localhost:8080/sample-helloworld-jsonrpc-webapp/HelloWorldService");
HelloWorldService = scaDomain.HelloWorldService.Service;
</script>
...ant