<?xml version="1.0" encoding="UTF-8"?> <Module> <ModulePrefs height="100" title="My Simple Gadget" description="Test gadget" author="Anonymous" author_email="anonymous+gg@gmail.com"/> <UserPref name="profileId" display_name="Profile ID" datatype="string" urlparam="id" required="true"/> <Content type="url" href="http://yourappid.appspot.com/gadget.html" /> </Module>
Note that I used the urlparam attribute so that the querystring used to fetch the gadget content would be something like
http://yourappid.appspot.com/gadget.html?id=123.
My GWT code could now read this userpref like this:
public void onModuleLoad() { String id = Window.Location.getParameter("id"); . . . .
Unfortunately there is a minor issue with this. It seems that some gadget containers ignore the urlparam attribute. When the gadget is hosted in the iGoogle home page it works fine but in Blogger and some other places the id parameter was not coming through in the querystring. Instead you get something like like
http://yourappid.appspot.com/gadget.html?up_profileId=123Basically the UserPref name prefixed with up_. This meant a minor change to the GWT code:
public void onModuleLoad() { String id = Window.Location.getParameter("id"); if (id == null) { id = Window.Location.getParameter("up_profileId"); } . . . .
UPDATE:
It seems that Google have broken the URL type gadgets. The parameters are no longer sent in the URL to the server! See this iGoogle Developer blog post
This makes the above code rather useless. I'll be working on a new version...
UPDATE 2:
According to this forum post the problem has been fixed temporarily. I think the advice is to use HTML content type gadgets if you want to use UserPrefs. Shame.
UPDATE 3:
URL type gadgets are back for good! See this post. To summarize:
I've been talking with developers on the iGoogle team about the best way to go forward here and it looks like keeping UserPrefs in the query string for type url gadgets is the thing to do.
Jeremy,
ReplyDeleteI'm trying to include a google gadget into my custom button for google toolbar. The how-to for that is mentioned at http://www.google.com/tools/toolbar/buttons/apis/howto_guide.html#gadgetpageurl.
The I can pass the url etc. information from the button to gadget as explained in the example. However, it seems to work only if the gadget content type html. For url type, the parameters are sent to gmodules site just right, but when the request the redirected from there to my site, the query string does not include url, host etc. Any suggestions?
Hello,
ReplyDeletedo you know if we can pass the content url dynamically some how?