how to integrate or call or interface with a 3rd party widget within a GWT app? - gwt

I am making an app in GWT. It is like a dashboard and will have out of the widgets.
Now when we ship this out, there is a use case that the customer might want to create their own GWT widget and use this in the dashboard app.
As I understand it, they will not be able to do this since we cannot ship our source code which is needed to compile the whole app again once tag of their widget/module gets into the gwt.xml file of my app.
I cannot use anything other that GWT to make this dashboard. And their widget could be say a flash heapmap, a jquery widget/plugin, another GWT module, a jsp page that renders a visualization from back end.
So far my thoughts have been to provide a widget in my app which is a wrapper in the form of an Iframe and call their main page (they will provide url), and have an api to let my app and their widget talk.
But I would like to know if there are other / better approaches?

This is exactly the problem solved by google's OpenSocial widgets. There are a few opensource implementations: http://shindig.apache.org/ is one. You can look into integrating that in to your app. An added bonus is that you can then display widgets from other applications (such as atlassian jira) that also serve opensocial widgets.

Depending on how closed source your application is (can custom JS/HTML be added to pages?), you could always provide a native Javascript (JSNI) API for some custom dashboard widgets. The simplest solution I'm thinking of would be a JSNI method which your customers could call to set the HTML content of said widget. This method would allow them to use a variety of options such as JQuery widgets, their own GWT widget generated HTML or even an IFrame pointing to their JSP pages etc... You could then provide additional JSNI API methods which would allow them to interact with your app/widget in other ways as well. This would be better than the IFrame method because you wouldn't have to deal with cross domain scripting security issues.

Related

GWT website routing

I visited new GWT website and noticed that after clicking on tree items - link is changing without adding hash (for example, http://www.gwtproject.org/books.html). I know how to do url routing using hashes, but how URL routing is made in GWT website (and possibly can be made)?
Thanks in advance.
It's commonly called HTML5 PushState. A new way of dealing with the browser history by changing the URL without necessarily reloading the page. By listening on popstate events you can dynamically change your page just like using the hashtag method, with the benefit of having cleaner URLs and out of the box crawlability.
Have a look at the gwt website source. Internally uses the GQuery library (jQuery port for GWT) that leverages such pushState methodology.
EDIT: If you want to take benefit of pushState right from GWT (since it does not natively support it), you can also have a look at Johannes Barop's pushState project.

Google web toolkits - multiple pages

On the google website there an example of a simple GWT appliatoin, following is a link:
http://code.google.com/webtoolkit/doc/1.6/tutorial/create.html
The above application has a host page:StockWatcher.html
and StockWatcher.java is the entry point.
If I wanted to add more html pages to this application, we keep one single host page and the entry point will add different panels depending on which link the user clicked on? In this case, how to know which link the user clicked on? If I create a navigation panel and each link has a request parameter, then after the user clicks on the link, How to get the request parameter?
Are there any tutorials available online on how to create a fully functional application? The one example google provides is too simple.
Thanks so much in advance
You have two options to have multiple page web application using gwt.
1) Use gwt history feature and listen for the history change. In this approach at the initial page load itself browser downloads all the javascripts(Including the widgets which are not useful in current link). Still this can be avoided by using gwt code splitting.
2) Create multiple modules. In this case you have to create multiple html pages and GWT entry points. For each major functionality create a gwt module and link that with [modulename].html file. In this approach browser downloads only particular feature's javascript. Not all the javascripts.
Based on your application requirement you can pick one of the option. IMHO I would suggesst second option.

How to safely add page content via CMS?

If I were to build a custom CMS that allowed someone to log in and build a page using a WYSIWYG would it be possible to make it secure and allow JavaScript code in the content? There are times where someone wants to add a video embed code or a widget that grabs an RSS feed, these embed codes and widgets are in JavaScript. So how do I allow them to add that to their page through a CMS? My main concern is XSS/vulnerabilities.
You could store tags with references to widgets in your rich text content, like <video>id</video>, and render the javascript only in frontend... or you could choose to use any of the modern CMS's out there with plugins for video and widgets that already solved the problem for you.

GWT widget library that doesn't want to be the whole app framework?

I've looked at all of the libraries listed in: Best GWT widget library?
Honestly, gwt-ext looks the best, but it's no longer being maintained (and the old project lead for some reason recommends SmartGWT instead.) I don't like the approach of SmartGWT, both because it wraps Javascript, and because it wants me to wrap my backend classes in its various data components (I don't want to have to translate my model objects just to use its widgets). Vaadin looks nice, but again doesn't seem to want to let me just use it as a client widget library; I have to use its server components. GXT looks fine, but the open source license doesn't apply to my organization.
Everything else on the list hasn't been updated in a long time.
Is there no GWT widget library that just focuses on providing better widgets, and doesn't want to force you to use its architecture to develop your UI?
GWT Mosaic is another widget library using the more lenient Apache license

GWT/java and javascript

can i design my web pages in html and css instead of java methods and use gwt only in parts of page that i need ajax? and which one is better gwt, extgwt, vaadin(it run apps in server-side.can i also use it in client-side?), etc...? do i also need to know javascript for using gwt?
thanks
can i design my web pages in html and
css instead of java methods and use
gwt only in parts of page that i need
ajax?
Yes, you can. You can create a div on your HTML page and insert your GWT widget there.
which one is better gwt, extgwt,
vaadin(it run apps in server-side.can
i also use it in client-side?)
I don't know about vaadin but Ext-GWT is a set of ready made components to use with GWT which make your life easier especially if you want to build an web app that looks and feels like a desktop application.
do i also need to know javascript for
using gwt?
No, it can be useful sometimes but is not necessary.