You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by vi...@wipro.com on 2008/08/25 13:10:35 UTC
Passing HTTP request parameters to URL gadgets
Hi,
I am looking for a solution to pass request parameters to a URL gadget.
Here is an example of what I am trying to do:-
1) I have a servlet that expects name in the HTTP request so that it
can respond with a Hello <name> message
2) I have created a URL gadget that points to my servlet like this:-
<Module>
<ModulePrefs
title="Hello World Gadget"
directory_title="Simplest Gadget"
title_url="Hello World Gadget"
description="A very simple gadget."
height="120"
author="Vinod Pillai"
/>
<Content href="http://localhost/sample/hello.do" type="url" />
</Module>
Where http://localhost/sample/hello.do is the URL of my servlet.
3) Is there a way to pass name as HTTP request parameter (GET or POST)
to hello.do through known gadget APIs provided with Shindig
distribution?
Any suggestions/pointers are greatly appreciated.
-vp
Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
RE: Passing HTTP request parameters to URL gadgets
Posted by vi...@wipro.com.
Hi Chris,
:) I certainly don't want to break the open social calls. I'll use
solution #1 as suggested by you.
Thanks for the invaluable advice. I truly appreciate it!
Thanks & regards,
Vinod
-----Original Message-----
From: Chris Chabot [mailto:chabotc@xs4all.nl]
Sent: Tuesday, August 26, 2008 2:14 PM
To: shindig-dev@incubator.apache.org
Subject: Re: Passing HTTP request parameters to URL gadgets
Hi Vinod,
I would advice to use solution #1.
While it is possible to use solution #2, it would break all the
OpenSocial calls since the domain / url of the gadget wouldn't be the
same as the social api server anymore, so ajax calls would be blocked,
so you can't retrieve any social information through javascript
anymore then (also things like rpc's for "set title", "resize", etc
would likely break).
With the first solution you would have to indeed extract & eval any
script, but in my experience (if your documents aren't 500kb monsters
that is:P) the overhead of that isn't so big that this would give any
noticeable slowdowns, and has the huge benefit that you can actually
use the OpenSocial API :)
-- Chris
On Aug 26, 2008, at 6:18 AM, <vi...@wipro.com>
<vinod.pillai@wipro.com
> wrote:
> Chris,
>
> Thanks for the prompt response.
>
> Since there was no mention of parameter passing in the gadget
> specification, I had a hunch that it may not be supported as yet. In
> the
> absence of a standard mechanism, I was planning to take one of the
> following routes:-
>
> 1) Instead of writing a URL gadget, write a small HTML gadget with the
> following algorithm:-
> a) parse location.href to get the request parameters
> b) set url = 'http://localhost/sample/hello.do'
> c) for (each parameter in the url) set url = url +
> parameter_name + '=' + parameter_value + '&';
> d) makeRequest(url, callback, {});
> e) get the HTML response of hello.do in callback() function and
> set root div.innerHTML = response.text;
>
> 2) Since div.innerHTML would not execute <script> tags in the response
> text, I'll have to parse the response text, extract the script tags
> and
> add them to the DOM tree in step 1e. Therefore, an easier way (no
> additional coding) would be to set location.href = url in step(d)
> instead of makeRequest; Step (e) is not required in this case.
>
> Although step (2) looks attractive, I'm not sure if setting
> location.href could break gadget rendering functionality of Shindig.
> Kindly confirm.
>
> Regards,
> Vinod
>
> -----Original Message-----
> From: Chris Chabot [mailto:chabotc@xs4all.nl]
> Sent: Monday, August 25, 2008 8:00 PM
> To: shindig-dev@incubator.apache.org
> Subject: Re: Passing HTTP request parameters to URL gadgets
>
> Hey Vinod,
>
> Currently that's not really possible unfortunately; There is a design
> discussion going on for how to solve these use cases by extending the
> templating proposal and allowing for such more clasic-style-
> webdevelopment, but that will be a little while more before that's in
> place.
>
> What does work, although it's a bit of a work around, is fetching your
> html output with an signed gadgets.io.makeRequest call, and parsing
> the information along on it's url. see:
> http://code.google.com/apis/opensocial/articles/makerequest-0.8.html
>
> The you can take the response from that, put that in your root div
> element... and you pretty much have the development model your looking
> for; Not the cleanest solution, but functional until we have another
> way to solve it.
>
> Hope that helps!
>
> -- Chris
>
>
> On Aug 25, 2008, at 1:10 PM, <vi...@wipro.com> wrote:
>
>> Hi,
>>
>>
>>
>> I am looking for a solution to pass request parameters to a URL
>> gadget.
>> Here is an example of what I am trying to do:-
>>
>>
>>
>> 1) I have a servlet that expects name in the HTTP request so that it
>> can respond with a Hello <name> message
>>
>> 2) I have created a URL gadget that points to my servlet like this:-
>>
>>
>>
>> <Module>
>>
>> <ModulePrefs
>>
>> title="Hello World Gadget"
>>
>> directory_title="Simplest Gadget"
>>
>> title_url="Hello World Gadget"
>>
>> description="A very simple gadget."
>>
>> height="120"
>>
>> author="Vinod Pillai"
>>
>> />
>>
>> <Content href="http://localhost/sample/hello.do" type="url" />
>>
>> </Module>
>>
>>
>>
>>
>>
>> Where http://localhost/sample/hello.do is the URL of my servlet.
>>
>>
>>
>> 3) Is there a way to pass name as HTTP request parameter (GET or
>> POST)
>> to hello.do through known gadget APIs provided with Shindig
>> distribution?
>>
>>
>>
>> Any suggestions/pointers are greatly appreciated.
>>
>>
>>
>> -vp
>>
>>
>>
>>
>> Please do not print this email unless it is absolutely necessary.
>>
>> The information contained in this electronic message and any
>> attachments to this message are intended for the exclusive use of
>> the addressee(s) and may contain proprietary, confidential or
>> privileged information. If you are not the intended recipient, you
>> should not disseminate, distribute or copy this e-mail. Please
>> notify the sender immediately and destroy all copies of this message
>> and any attachments.
>>
>> WARNING: Computer viruses can be transmitted via email. The
>> recipient should check this email and any attachments for the
>> presence of viruses. The company accepts no liability for any damage
>> caused by any virus transmitted by this email.
>>
>> www.wipro.com
>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of
> the addressee(s) and may contain proprietary, confidential or
> privileged information. If you are not the intended recipient, you
> should not disseminate, distribute or copy this e-mail. Please
> notify the sender immediately and destroy all copies of this message
> and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The
> recipient should check this email and any attachments for the
> presence of viruses. The company accepts no liability for any damage
> caused by any virus transmitted by this email.
>
> www.wipro.com
Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
Re: Passing HTTP request parameters to URL gadgets
Posted by Chris Chabot <ch...@xs4all.nl>.
Hi Vinod,
I would advice to use solution #1.
While it is possible to use solution #2, it would break all the
OpenSocial calls since the domain / url of the gadget wouldn't be the
same as the social api server anymore, so ajax calls would be blocked,
so you can't retrieve any social information through javascript
anymore then (also things like rpc's for "set title", "resize", etc
would likely break).
With the first solution you would have to indeed extract & eval any
script, but in my experience (if your documents aren't 500kb monsters
that is:P) the overhead of that isn't so big that this would give any
noticeable slowdowns, and has the huge benefit that you can actually
use the OpenSocial API :)
-- Chris
On Aug 26, 2008, at 6:18 AM, <vi...@wipro.com> <vinod.pillai@wipro.com
> wrote:
> Chris,
>
> Thanks for the prompt response.
>
> Since there was no mention of parameter passing in the gadget
> specification, I had a hunch that it may not be supported as yet. In
> the
> absence of a standard mechanism, I was planning to take one of the
> following routes:-
>
> 1) Instead of writing a URL gadget, write a small HTML gadget with the
> following algorithm:-
> a) parse location.href to get the request parameters
> b) set url = 'http://localhost/sample/hello.do'
> c) for (each parameter in the url) set url = url +
> parameter_name + '=' + parameter_value + '&';
> d) makeRequest(url, callback, {});
> e) get the HTML response of hello.do in callback() function and
> set root div.innerHTML = response.text;
>
> 2) Since div.innerHTML would not execute <script> tags in the response
> text, I'll have to parse the response text, extract the script tags
> and
> add them to the DOM tree in step 1e. Therefore, an easier way (no
> additional coding) would be to set location.href = url in step(d)
> instead of makeRequest; Step (e) is not required in this case.
>
> Although step (2) looks attractive, I'm not sure if setting
> location.href could break gadget rendering functionality of Shindig.
> Kindly confirm.
>
> Regards,
> Vinod
>
> -----Original Message-----
> From: Chris Chabot [mailto:chabotc@xs4all.nl]
> Sent: Monday, August 25, 2008 8:00 PM
> To: shindig-dev@incubator.apache.org
> Subject: Re: Passing HTTP request parameters to URL gadgets
>
> Hey Vinod,
>
> Currently that's not really possible unfortunately; There is a design
> discussion going on for how to solve these use cases by extending the
> templating proposal and allowing for such more clasic-style-
> webdevelopment, but that will be a little while more before that's in
> place.
>
> What does work, although it's a bit of a work around, is fetching your
> html output with an signed gadgets.io.makeRequest call, and parsing
> the information along on it's url. see:
> http://code.google.com/apis/opensocial/articles/makerequest-0.8.html
>
> The you can take the response from that, put that in your root div
> element... and you pretty much have the development model your looking
> for; Not the cleanest solution, but functional until we have another
> way to solve it.
>
> Hope that helps!
>
> -- Chris
>
>
> On Aug 25, 2008, at 1:10 PM, <vi...@wipro.com> wrote:
>
>> Hi,
>>
>>
>>
>> I am looking for a solution to pass request parameters to a URL
>> gadget.
>> Here is an example of what I am trying to do:-
>>
>>
>>
>> 1) I have a servlet that expects name in the HTTP request so that it
>> can respond with a Hello <name> message
>>
>> 2) I have created a URL gadget that points to my servlet like this:-
>>
>>
>>
>> <Module>
>>
>> <ModulePrefs
>>
>> title="Hello World Gadget"
>>
>> directory_title="Simplest Gadget"
>>
>> title_url="Hello World Gadget"
>>
>> description="A very simple gadget."
>>
>> height="120"
>>
>> author="Vinod Pillai"
>>
>> />
>>
>> <Content href="http://localhost/sample/hello.do" type="url" />
>>
>> </Module>
>>
>>
>>
>>
>>
>> Where http://localhost/sample/hello.do is the URL of my servlet.
>>
>>
>>
>> 3) Is there a way to pass name as HTTP request parameter (GET or
>> POST)
>> to hello.do through known gadget APIs provided with Shindig
>> distribution?
>>
>>
>>
>> Any suggestions/pointers are greatly appreciated.
>>
>>
>>
>> -vp
>>
>>
>>
>>
>> Please do not print this email unless it is absolutely necessary.
>>
>> The information contained in this electronic message and any
>> attachments to this message are intended for the exclusive use of
>> the addressee(s) and may contain proprietary, confidential or
>> privileged information. If you are not the intended recipient, you
>> should not disseminate, distribute or copy this e-mail. Please
>> notify the sender immediately and destroy all copies of this message
>> and any attachments.
>>
>> WARNING: Computer viruses can be transmitted via email. The
>> recipient should check this email and any attachments for the
>> presence of viruses. The company accepts no liability for any damage
>> caused by any virus transmitted by this email.
>>
>> www.wipro.com
>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of
> the addressee(s) and may contain proprietary, confidential or
> privileged information. If you are not the intended recipient, you
> should not disseminate, distribute or copy this e-mail. Please
> notify the sender immediately and destroy all copies of this message
> and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The
> recipient should check this email and any attachments for the
> presence of viruses. The company accepts no liability for any damage
> caused by any virus transmitted by this email.
>
> www.wipro.com
RE: Passing HTTP request parameters to URL gadgets
Posted by vi...@wipro.com.
Chris,
Thanks for the prompt response.
Since there was no mention of parameter passing in the gadget
specification, I had a hunch that it may not be supported as yet. In the
absence of a standard mechanism, I was planning to take one of the
following routes:-
1) Instead of writing a URL gadget, write a small HTML gadget with the
following algorithm:-
a) parse location.href to get the request parameters
b) set url = 'http://localhost/sample/hello.do'
c) for (each parameter in the url) set url = url +
parameter_name + '=' + parameter_value + '&';
d) makeRequest(url, callback, {});
e) get the HTML response of hello.do in callback() function and
set root div.innerHTML = response.text;
2) Since div.innerHTML would not execute <script> tags in the response
text, I'll have to parse the response text, extract the script tags and
add them to the DOM tree in step 1e. Therefore, an easier way (no
additional coding) would be to set location.href = url in step(d)
instead of makeRequest; Step (e) is not required in this case.
Although step (2) looks attractive, I'm not sure if setting
location.href could break gadget rendering functionality of Shindig.
Kindly confirm.
Regards,
Vinod
-----Original Message-----
From: Chris Chabot [mailto:chabotc@xs4all.nl]
Sent: Monday, August 25, 2008 8:00 PM
To: shindig-dev@incubator.apache.org
Subject: Re: Passing HTTP request parameters to URL gadgets
Hey Vinod,
Currently that's not really possible unfortunately; There is a design
discussion going on for how to solve these use cases by extending the
templating proposal and allowing for such more clasic-style-
webdevelopment, but that will be a little while more before that's in
place.
What does work, although it's a bit of a work around, is fetching your
html output with an signed gadgets.io.makeRequest call, and parsing
the information along on it's url. see:
http://code.google.com/apis/opensocial/articles/makerequest-0.8.html
The you can take the response from that, put that in your root div
element... and you pretty much have the development model your looking
for; Not the cleanest solution, but functional until we have another
way to solve it.
Hope that helps!
-- Chris
On Aug 25, 2008, at 1:10 PM, <vi...@wipro.com> wrote:
> Hi,
>
>
>
> I am looking for a solution to pass request parameters to a URL
> gadget.
> Here is an example of what I am trying to do:-
>
>
>
> 1) I have a servlet that expects name in the HTTP request so that it
> can respond with a Hello <name> message
>
> 2) I have created a URL gadget that points to my servlet like this:-
>
>
>
> <Module>
>
> <ModulePrefs
>
> title="Hello World Gadget"
>
> directory_title="Simplest Gadget"
>
> title_url="Hello World Gadget"
>
> description="A very simple gadget."
>
> height="120"
>
> author="Vinod Pillai"
>
> />
>
> <Content href="http://localhost/sample/hello.do" type="url" />
>
> </Module>
>
>
>
>
>
> Where http://localhost/sample/hello.do is the URL of my servlet.
>
>
>
> 3) Is there a way to pass name as HTTP request parameter (GET or
> POST)
> to hello.do through known gadget APIs provided with Shindig
> distribution?
>
>
>
> Any suggestions/pointers are greatly appreciated.
>
>
>
> -vp
>
>
>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of
> the addressee(s) and may contain proprietary, confidential or
> privileged information. If you are not the intended recipient, you
> should not disseminate, distribute or copy this e-mail. Please
> notify the sender immediately and destroy all copies of this message
> and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The
> recipient should check this email and any attachments for the
> presence of viruses. The company accepts no liability for any damage
> caused by any virus transmitted by this email.
>
> www.wipro.com
Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
Re: Passing HTTP request parameters to URL gadgets
Posted by Chris Chabot <ch...@xs4all.nl>.
Hey Vinod,
Currently that's not really possible unfortunately; There is a design
discussion going on for how to solve these use cases by extending the
templating proposal and allowing for such more clasic-style-
webdevelopment, but that will be a little while more before that's in
place.
What does work, although it's a bit of a work around, is fetching your
html output with an signed gadgets.io.makeRequest call, and parsing
the information along on it's url. see:
http://code.google.com/apis/opensocial/articles/makerequest-0.8.html
The you can take the response from that, put that in your root div
element... and you pretty much have the development model your looking
for; Not the cleanest solution, but functional until we have another
way to solve it.
Hope that helps!
-- Chris
On Aug 25, 2008, at 1:10 PM, <vi...@wipro.com> wrote:
> Hi,
>
>
>
> I am looking for a solution to pass request parameters to a URL
> gadget.
> Here is an example of what I am trying to do:-
>
>
>
> 1) I have a servlet that expects name in the HTTP request so that it
> can respond with a Hello <name> message
>
> 2) I have created a URL gadget that points to my servlet like this:-
>
>
>
> <Module>
>
> <ModulePrefs
>
> title="Hello World Gadget"
>
> directory_title="Simplest Gadget"
>
> title_url="Hello World Gadget"
>
> description="A very simple gadget."
>
> height="120"
>
> author="Vinod Pillai"
>
> />
>
> <Content href="http://localhost/sample/hello.do" type="url" />
>
> </Module>
>
>
>
>
>
> Where http://localhost/sample/hello.do is the URL of my servlet.
>
>
>
> 3) Is there a way to pass name as HTTP request parameter (GET or
> POST)
> to hello.do through known gadget APIs provided with Shindig
> distribution?
>
>
>
> Any suggestions/pointers are greatly appreciated.
>
>
>
> -vp
>
>
>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of
> the addressee(s) and may contain proprietary, confidential or
> privileged information. If you are not the intended recipient, you
> should not disseminate, distribute or copy this e-mail. Please
> notify the sender immediately and destroy all copies of this message
> and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The
> recipient should check this email and any attachments for the
> presence of viruses. The company accepts no liability for any damage
> caused by any virus transmitted by this email.
>
> www.wipro.com