komasoftware / gwt-google-apis

Automatically exported from code.google.com/p/gwt-google-apis
0 stars 0 forks source link

malformation gadget xml by using @InjectModulePrefs #421

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Found in Release: 1.2 

Detailed description:
 I have put all my ModulePrefs in a text file and used @InjectModulePrefs(files = {"prefInject.txt"})

an extra "<ModulePrefs>" element is created in the gadget xml file.

Workaround if you have one: Delete manually

Links to the relevant GWT Developer Forum posts:

Original issue reported on code.google.com by yuvalhef...@gmail.com on 29 Sep 2010 at 7:03

GoogleCodeExporter commented 9 years ago
Can you share the contents of this file?

Original comment by ericzun...@gmail.com on 17 Oct 2010 at 2:23

GoogleCodeExporter commented 9 years ago
Hi,

1. Originally I split my ModulePrefs between my init class and external text 
file 
with @InjectModulePrefs(files = {"prefInject.txt"}). 

2. Now I just use @InjectModulePrefs(files = {"prefInject.txt"})

I tried to renove ModulePrefs from my prefInject.txt but then I get xml parsing 
error.

3. The result is the gadget xml like this (duplicated "ModulePrefs"):

<?xml version="1.0" encoding="UTF-8"?><Module><ModulePrefs><ModulePrefs 
author="????" author_affiliation="??" author_email="????" description="...." 
directory_title="??height="350" screenshot="screenshot.png" 
thumbnail="thumbnail.png" title="__MSG_title__" title_url="......">
    <Require feature="opensocial-0.8"/>
    <Require feature="locked-domain"/>
    <Require feature="dynamic-height"/>
    <OAuth>
      <Service>
        <Access method="GET" url="https://www.google.com/accounts/OAuthGetAccessToken"/> 
        <Request method="GET" url="https://www.google.com/accounts/OAuthGetRequestToken?scope=http://www.google.com/m8/feeds/"/> 
        <Authorization url="https://www.google.com/accounts/OAuthAuthorizeToken?oauth_callback=http://oauth.gmodules.com/gadgets/oauthcallback"/> 
      </Service>
    </OAuth>

</ModulePrefs></ModulePrefs><UserPref datatype="string" 
default_value="example.com" display_name="__MSG_domainName__" 
name="userDomainName" required="true"/><Content type="html"><![CDATA[<!DOCTYPE 
html><style type="text/css">

5. my init class
@InjectModulePrefs(files = {"prefInject.txt"})
@InjectContent(files={"css.html","divs.html"})

@UseLongManifestName(false)
@AllowHtmlQuirksMode(false)

public class PhoneBook extends Gadget<phoneBookPreferences>{

  protected void init(final phoneBookPreferences prefs) {

    ................

   }

}

Original comment by yuvalhef...@gmail.com on 17 Oct 2010 at 7:05

GoogleCodeExporter commented 9 years ago
I'd like to suggest adding more documentation on the oauth process in gwt 
gadgets api and/or, injection process that could allow this to work. I'm still 
unclear how to use the oauth process using the gwt gadget api. The sample 
gadgets are great. Also adding a sample oauth gadget would be nice to see. 

Original comment by branflak...@gmail.com on 2 Jan 2011 at 6:11

GoogleCodeExporter commented 9 years ago
The @InjectContent should not contain "{}". Also the file should be in the same 
package as the preferences class.

This works in my configuration.
@com.google.gwt.gadgets.client.Gadget.InjectContent(files="OAuth.txt")

Original comment by branflak...@gmail.com on 2 Jan 2011 at 6:30

GoogleCodeExporter commented 9 years ago
This works too, so I have to take back using brackets, they can be used for the 
files array. 

@com.google.gwt.gadgets.client.Gadget.InjectContent(files={"OAuth.txt", 
"Test.txt"})

Original comment by branflak...@gmail.com on 2 Jan 2011 at 6:38

GoogleCodeExporter commented 9 years ago
Source code for the test that compiles correctly with injected content: 
http://code.google.com/p/gwt-examples/source/browse/trunk/DemoGwtGadgetOauth/src
/org/gonevertical/gadgetoauth/client/DemoGwtGadgetOauth.java

Original comment by branflak...@gmail.com on 2 Jan 2011 at 6:44

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for your advice ... but note that InjectModulePrefs and InjectContent 
are not the same, they are use to inject content in different section of the 
Gadget xml.
Doesn't seems to work for me ...

Original comment by yuvalhef...@gmail.com on 3 Jan 2011 at 7:41

GoogleCodeExporter commented 9 years ago
Hi,

I have been doing few Qauth/GWT gadgets in the last 6 month here is a short 
description:
In general you need to extend OauthRequest and implement the method 
processResults.

In order to have the initial Oauth process done you need to add this stuff to 
your gadget xml:
  <script src="http://gadget-doc-examples.googlecode.com/svn/trunk/opensocial-gadgets/popup.js"></script>

<div id="done"></div>
<div id="approval" class="div-hidden">
     <a href="#" id="personalize">please approve</a>
</div>

<div id="waiting" class="div-hidden">
   <a href="#" id="approvaldone">in process</a>
</div>

    function showOneSection(toshow) {
      var sections = [ 'approval', 'waiting','done' ];
      for (var i=0; i < sections.length; ++i) {
        var s = sections[i];
        var el = document.getElementById(s);
        if (s === toshow) {
          el.style.display = "block";
        } else {
          el.style.display = "none";
        }
      }
    }
  </script> 

Original comment by yuvalhef...@gmail.com on 3 Jan 2011 at 8:15

Attachments:

GoogleCodeExporter commented 9 years ago
I spaced earlier, your correct on the @InjectModulePrefs and @InjectContent. 
I'm trying something similar to what your code shows. I'm working something up 
and getting some success, but having some issues still to work out. I'm working 
up a demo, and should have something by end of next week if all goes well.

This is under development, and is still rough, but I'll share it so far. (this 
is version 2302, take off number to see changes) - . I'm going to construct a 
popup to replace popup.js with java code shortly after I finish testing for 
correct response.
http://code.google.com/p/gwt-examples/source/browse/trunk/DemoGwtOAuthPopUp/src/
org/gonevertical/demogwtoauthpopup/client/DemoGwtOAuthPopUp.java?r=2302

I extended request options like you did to get the headers configured properly.
    RequestOptionsExtended options = RequestOptionsExtended.newInstanceEx();
    options.setMethodType(MethodType.GET);
    options.setAuthorizationType(AuthorizationType.OAUTH);
    options.setOAuthServiceName("google");
    options.setOAuthUseToken("always");

    String url = "http://www.blogger.com/feeds/default/blogs";
    IoProvider.get().makeRequestAsText(url, handler, options);

Original comment by branflak...@gmail.com on 4 Jan 2011 at 2:49

GoogleCodeExporter commented 9 years ago
Hi,

would be nice to have it 100% GWT. I have never had the time to try and do so...
I'm developing a Gadgets+GAE json service platform and sure going to use that.

Original comment by yuvalhef...@gmail.com on 4 Jan 2011 at 6:06

GoogleCodeExporter commented 9 years ago
Here  working demo using 100% GWT gadget. I use a little JSNI for the Window 
object, but I don't have to include the popup.js, besides its doing very 
little. I'm sure this could have more error checking and do a little more, but 
it shows how do do the entire personalization process in GWT. Hope this helps. 
I give a working example of the injection methods that can be used as well.

 http://code.google.com/p/gwt-examples/wiki/DemoGwtGadgetOAuthPopup - Source and Gadget Demo here.

Original comment by branflak...@gmail.com on 4 Jan 2011 at 11:17

GoogleCodeExporter commented 9 years ago

Original comment by zundel@google.com on 28 Oct 2011 at 4:45