I think following the pattern that iGoogle uses is probably the best route for now. Throwing a NPE is something we should avoid.
The more I think about this problem the more I'm thinking there's a bit of a bad pattern that we may run into. We make a metadata request, providing the view as a param, then we get back the iframeurl with that view in it as a url param. All of this happens before we know what views the gadget is able to render. I guess one could perform some substitution on the iframeurl for the view that they really want... or perhaps make two metadata requests, the first to get the views and the second to get the iframeurl, but that's a bit wasteful. Have others run into this odd situation before? -Stanton From: Ryan J Baxter/Westford/IBM@Lotus To: [email protected], Cc: Stanton Sievers/Westford/IBM@Lotus Date: 03/10/2011 15:07 Subject: Re: NPE in DefaultIframeUriManager when no default view is provided by the gadget Yeah I took a look at the spec as well and couldn't find anything that covers this case. This document from Google shows how iGoogle handles this case though... http://code.google.com/apis/gadgets/docs/ui.html We may way to consider doing what they do, which is displaying nothing. -Ryan Email: [email protected] Phone: 978-899-3041 developerWorks Profile From: Paul Lindner <[email protected]> To: [email protected], Cc: Stanton Sievers/Westford/IBM@Lotus Date: 03/10/2011 02:14 PM Subject: Re: NPE in DefaultIframeUriManager when no default view is provided by the gadget The spec doesn't really cover this case.. If there's a view-less content section then it might make sense to add a view=default attribute. For cases where we're requesting a view that the gadget does not define then we should return some minimal default empty view for the gadget so things don't blow up. On Thu, Mar 10, 2011 at 9:51 AM, Stanton Sievers <[email protected]>wrote: > Hi, > > I've run into a NullPointerException in > org.apache.shindig.gadgets.uri.DefaultIframeUriManager.makeRenderingUri in > the case where the gadget spec document neither defines a Content section > with no "view" attribute nor a Content section with a "view" attribute > containing "default". An example gadget is posted below. > > The NPE is thrown because the gadget.getCurrentView() call in > makeRenderingUri() returns null. The value returned by > gadget.getCurrentView() is the same as the value returned by > org.apache.shindig.gadgets.process.Processor.getView(GadgetContext, > GadgetSpec). Looking through the code, it seems that if the "view" param > defined in the request is not found for the gadget or not defined at all, > then we try to fall back to the "default" view. However, if that doesn't > exist either, then we get this NPE. > > I'm wondering what the expected behavior here should be? I'd rather we > pick a random view for the rendering url then throw a NPE. > > Thanks, > -Stanton > > > <?xml version="1.0" encoding="UTF-8"?> > <Module> > <ModulePrefs title="BadViews" > author="[email protected]"> > </ModulePrefs> > <Content type="html" view="profile"> > </Content> > <Content type="html" view="canvas"> > </Content> > </Module> > > > -- Paul Lindner -- [email protected] -- linkedin.com/in/plindner
