Hi Luciano,

Thank you very much for your answer. It helps me very much as I was blocked to 
continue my work. I'm basically java programmer and didn't have experience with 
javascript before so please don't mind for my fundamental questions. 


>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.

As I understood this, there is no way to have a javascript outside of the Web 
service application? My idea was to extend some of the existing Web application 
like Elgg, Wiki etc., with additional Learning Web services accessible through 
a popup containers developed with javascript and jQuery. This javascript client 
should communicate with Web services to get its functionality. It is possible 
to let javascript client be part of the same application where Web services are 
stored, and include it in Elgg with absolute path to remote javascript file, or 
to make it be on the same server where Elgg is stored and then access Web 
services from javascript through absolute url. I hope you understand my idea, 
so I would like to hear your comment and idea what would be the best possible 
approach to make all these thinks work together. 
Do I have to put all three parts (Web services, javascript client and Elgg) in 
the same application?

Zoran



________________________________
From: Luciano Resende <[email protected]>
To: [email protected]
Cc: [email protected]
Sent: Thu, March 11, 2010 8:20:21 PM
Subject: Re: javascript client

On Mon, Mar 8, 2010 at 1:11 PM, Zoran Jeremic <[email protected]> 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