On Mon, Mar 8, 2010 at 1:11 PM, Zoran Jeremic <jeremic1...@yahoo.com> wrote:
> Hi,
>
>>Does it matter how your JavaScript communicates with the server
>>- does it just need to make request-response style calls to the server
>>so the protocols can be handled and hidden by Tuscany, or do you need
>>control over that, for example to use jsonp or jsonrpc or a particular
>>toolkit like Dojo or JQuery?
>
> I'm not sure in the moment if I will have some specific requests regarding
> the protocols. I think not, but I need to exchange json like data (used to
> generate jsTree component) between server and client.
> I have already tried to use Dojo, as it looks like nice solution to my
> problem, but I couldn't make it works. I used provided examples, but I don't
> know if I have missed something. Here is a code:
>
> <script type="text/javascript">
>          var djConfig = {
>                  parseOnLoad: true,
>                  baseRelativePath: "dojo",
>                  isDebug: true,
>                  debugContainerId: "dojoDebug"
>                  };
>                  djConfig.usePlainJson=true ;
>     </script>
>
>         <script type="text/javascript" src="js/dojo/dojo.js"></script>
>
>         <script type="text/javascript">
>             dojo.require("dojo.parser");
>
>             dojo.require("dojo.rpc.JsonService");
>         </script>
>
> ...
>
>          var smd=new
> dojo.rpc.JsonService("http://ZoranPC:8080/CreateLearningGoalsService?smd";);
>          var
> competences=smd.getAvailableCompetences().addCallback(contentCallBack);
>
>
> I always get error in Firebug
>
> smd.getAvailableCompetences is not a function.
>
> Did I miss something here. I didn't add anything Dojo related to the server.
> Do I need to use something there in other to connect client with Web
> Services.
>

Zoran, overall, your application looks ok, and after a slight
modification to make the services available from the same webapp [1] i
could retrieve the available competences from the backend service with
the following code :

          dojo.addOnLoad(function() {
            dojo.require("dojo.parser");
                        dojo.require("dojo.rpc.JsonService");

                         var smd=new
dojo.rpc.JsonService("http://localhost:8080/sample-intelleo-lpc-webapp/CreateLearningGoalsService?smd";);
                 var 
competences=smd.getAvailableCompetences().addCallback(contentCallBack);
                        });

Note that i have to access the application trough
(http://localhost:8080/sample-intelleo-lpc-webapp/lpc/index.html) to
get the javaScript included via relative paths to work.

Have said that, you need to think on how you want to partition your
application, as having your service being provided from a given
host:port and trying to access it via a JavaScript served from a
different host:port will hit JavaScript security constrains (see [2])
and you will need to use some type of proxy, component proxy (e.g a
local json-rpc component that references a remote json-rpc service),
jsonp or some other technique. Note that this is not a particular
limitation from Tuscany or SCA, but something related to how
JavaScript and Browser security works.

I hope this helps and let you make progress, don't hesitate to ask
further questions.

[1] http://people.apache.org/~lresende/tuscany/intelleo-lpc-webapp.tar.gz
[2] http://en.wikipedia.org/wiki/Same_origin_policy

-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Reply via email to