Google web toolkits - multiple pages - gwt

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.

Related

add functionality layer to AtTask by plug-in on Internet Explorer

I would like to add functionality to the AtTask system by "adding a layer".
What I want to know is whether this can be achieved with a plug-in for Internet Explorer.
To give a concrete example:
This extra layer would allow users to click on "Online Edit" document (which is not available right now). The linked application will open, and when you click save, the file is loaded back to AtTask.
All this happens in the background via the AtTask API, and is transparent to the user.
The question is: is it possible to add functionality to a site by somehow adding layers?
Last comment: this plug-in (or whatever needs to be installed inbto the browser) will only be visible/active when accesing the AtTask website.
Thanks in advance for your responses.
Within the confines of AtTask your best bet is to use an "External Page" create a service that handles the data in the manner you need.
The Dashboard that contains your External Page can be added as a tab via Layout Templates.
Most of the heavy lifting would have to be handled by your application. You would have to link the document(s) you wish to edit.
Some sort of referrer would be necessary to place the revised document back into AtTask. The method in which the client can do this would be determined by your preference and requirements. I am sure you can find some sort of Wiz-Bang jQuery uploader.
Depending on the level of control you have with your user base, you could make an Application URL
Windows : Registering an Application to a URI Scheme
OS X : Launching Scripts from Webpage Links
I do not know of any other way to handle this other than what Steve suggested.
Having said that a possible solution to this is to create a new application and iframe in AtTask.
At the top or wherever on the page your application could have a link for "Online Edit". Then you would use javascript to extract the task id, project id or any other needed information you need for the api to get the needed content to edit. Then save using the same api information.
I have not tried this type of method but theoretically it could work.

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.

Best practices for designing GUI in GWT

I have recently started studying Google Web Toolkit. I have went through some walkthroughs, and I think I understand the basics and the idea. However, I have some questions on the overall architecture and design of the applications.
Let's start with the GUI. I want to build a "common" web application, where the user first sees a login page. After successful login, the user is redirected to some kind of index page and a menu is added. I created a new LoginComposite for the login page, and tried to design a nice looking HTML table using the GWT Designer. However, I find that really hard to do, as you cannot set any individual properties on the individual cells (TDs)? There's no way to specify colspan or rowspan, and I can't set any padding or margin on the cells themselves. In short, I know exactly how I would have written the HTML code, but I can't translate that to the designer. Is that just me?
Also, I am wondering about the best practice for code layout and design. I went through the StockWatcher tutorial, but that's really not a very realistic web application. For example, I would like to know how I should design different forms (should each be in a own class inheriting the Composite-class)? How should I switch between forms (for example, first a list view, then a form for editing a chosen item from the list, then a totally different page)? If I have one Composite for each page, and instantiate them when needed in my EntryPoint, would that mean that the client will download all the JavaScript for all those Composites at page load? Should I stick with only one HTML page, or should I have many?
These are questions not really covered by any GWT tutorial. If anyone know a good example of a "real" web application built using GWT, I would love to see it.
Thanks for your input!
There are a whole bunch of resources in Google IO talks. For example:
http://www.google.com/events/io/2011/sessions/high-performance-gwt-best-practices-for-writing-smaller-faster-apps.html
http://www.google.com/events/io/2011/sessions/highly-productive-gwt-rapid-development-with-app-engine-objectify-requestfactory-and-gwt-platform.html
http://www.google.com/events/io/2010/sessions/architecting-production-gwt.html
http://www.google.com/events/io/2010/sessions/architecting-performance-gwt.html
http://www.google.com/events/io/2010/sessions/gwt-ui-overhaul.html
http://www.google.com/events/io/2009/sessions/EffectiveGwt.html
Also, don't expect to be able to edit absolutely everything if you are using the GUI to build your GWT app. Good luck!

Web based plugin architecture for simple user interfaces

I have a web based application using Primefaces with a very basic plug-in like architecture. The configuration of these plug-ins was all handled with xml, which is not so user friendly system.
I would now like to allow for each plug-in to be configurable via the web application, what are my options?
I have looked into Portals and Portlets but that seems like a rather big change to my application and my plug-ins do not require such complex user interfaces, a textbox or two of configuration is more than enough.
Does anyone have any suggestions or advice and what would be the best route here?
Create a simple page , per plugin that read the XML file, parse the option that you want to change , present it to the user with a simple interface, and save back the XML file.
Take care of the saving part and password-protect this page!

What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?

I've just noticed that the long, convoluted Facebook URLs that we're used to now look like this:
http://www.facebook.com/example.profile#!/pages/Another-Page/123456789012345
As far as I can recall, earlier this year it was just a normal URL-fragment-like string (starting with #), without the exclamation mark. But now it's a shebang or hashbang (#!), which I've previously only seen in shell scripts and Perl scripts.
The new Twitter URLs now also feature the #! symbols. A Twitter profile URL, for example, now looks like this:
http://twitter.com/#!/BoltClock
Does #! now play some special role in URLs, like for a certain Ajax framework or something since the new Facebook and Twitter interfaces are now largely Ajaxified?
Would using this in my URLs benefit my Web application in any way?
This technique is now deprecated.
This used to tell Google how to index the page.
https://developers.google.com/webmasters/ajax-crawling/
This technique has mostly been supplanted by the ability to use the JavaScript History API that was introduced alongside HTML5. For a URL like www.example.com/ajax.html#!key=value, Google will check the URL www.example.com/ajax.html?_escaped_fragment_=key=value to fetch a non-AJAX version of the contents.
The octothorpe/number-sign/hashmark has a special significance in an URL, it normally identifies the name of a section of a document. The precise term is that the text following the hash is the anchor portion of an URL. If you use Wikipedia, you will see that most pages have a table of contents and you can jump to sections within the document with an anchor, such as:
https://en.wikipedia.org/wiki/Alan_Turing#Early_computers_and_the_Turing_test
https://en.wikipedia.org/wiki/Alan_Turing identifies the page and Early_computers_and_the_Turing_test is the anchor. The reason that Facebook and other Javascript-driven applications (like my own Wood & Stones) use anchors is that they want to make pages bookmarkable (as suggested by a comment on that answer) or support the back button without reloading the entire page from the server.
In order to support bookmarking and the back button, you need to change the URL. However, if you change the page portion (with something like window.location = 'http://raganwald.com';) to a different URL or without specifying an anchor, the browser will load the entire page from the URL. Try this in Firebug or Safari's Javascript console. Load http://minimal-github.gilesb.com/raganwald. Now in the Javascript console, type:
window.location = 'http://minimal-github.gilesb.com/raganwald';
You will see the page refresh from the server. Now type:
window.location = 'http://minimal-github.gilesb.com/raganwald#try_this';
Aha! No page refresh! Type:
window.location = 'http://minimal-github.gilesb.com/raganwald#and_this';
Still no refresh. Use the back button to see that these URLs are in the browser history. The browser notices that we are on the same page but just changing the anchor, so it doesn't reload. Thanks to this behaviour, we can have a single Javascript application that appears to the browser to be on one 'page' but to have many bookmarkable sections that respect the back button. The application must change the anchor when a user enters different 'states', and likewise if a user uses the back button or a bookmark or a link to load the application with an anchor included, the application must restore the appropriate state.
So there you have it: Anchors provide Javascript programmers with a mechanism for making bookmarkable, indexable, and back-button-friendly applications. This technique has a name: It is a Single Page Interface.
p.s. There is a fourth benefit to this technique: Loading page content through AJAX and then injecting it into the current DOM can be much faster than loading a new page. In addition to the speed increase, further tricks like loading certain portions in the background can be performed under the programmer's control.
p.p.s. Given all of that, the 'bang' or exclamation mark is a further hint to Google's web crawler that the exact same page can be loaded from the server at a slightly different URL. See Ajax Crawling. Another technique is to make each link point to a server-accessible URL and then use unobtrusive Javascript to change it into an SPI with an anchor.
Here's the key link again: The Single Page Interface Manifesto
First of all: I'm the author of the The Single Page Interface Manifesto cited by raganwald
As raganwald has explained very well, the most important aspect of the Single Page Interface (SPI) approach used in FaceBook and Twitter is the use of hash # in URLs
The character ! is added only for Google purposes, this notation is a Google "standard" for crawling web sites intensive on AJAX (in the extreme Single Page Interface web sites). When Google's crawler finds an URL with #! it knows that an alternative conventional URL exists providing the same page "state" but in this case on load time.
In spite of #! combination is very interesting for SEO, is only supported by Google (as far I know), with some JavaScript tricks you can build SPI web sites SEO compatible for any web crawler (Yahoo, Bing...).
The SPI Manifesto and demos do not use Google's format of ! in hashes, this notation could be easily added and SPI crawling could be even easier (UPDATE: now ! notation is used and remains compatible with other search engines).
Take a look to this tutorial, is an example of a simple ItsNat SPI site but you can pick some ideas for other frameworks, this example is SEO compatible for any web crawler.
The hard problem is to generate any (or selected) "AJAX page state" as plain HTML for SEO, in ItsNat is very easy and automatic, the same site is in the same time SPI or page based for SEO (or when JavaScript is disabled for accessibility). With other web frameworks you can ever follow the double site approach, one site is SPI based and another page based for SEO, for instance Twitter uses this "double site" technique.
I would be very careful if you are considering adopting this hashbang convention.
Once you hashbang, you can’t go back. This is probably the stickiest issue. Ben’s post put forward the point that when pushState is more widely adopted then we can leave hashbangs behind and return to traditional URLs. Well, fact is, you can’t. Earlier I stated that URLs are forever, they get indexed and archived and generally kept around. To add to that, cool URLs don’t change. We don’t want to disconnect ourselves from all the valuable links to our content. If you’ve implemented hashbang URLs at any point then want to change them without breaking links the only way you can do it is by running some JavaScript on the root document of your domain. Forever. It’s in no way temporary, you are stuck with it.
You really want to use pushState instead of hashbangs, because making your URLs ugly and possibly broken -- forever -- is a colossal and permanent downside to hashbangs.
To have a good follow-up about all this, Twitter - one of the pioneers of hashbang URL's and single-page-interface - admitted that the hashbang system was slow in the long run and that they have actually started reversing the decision and returning to old-school links.
Article about this is here.
I always assumed the ! just indicated that the hash fragment that followed corresponded to a URL, with ! taking the place of the site root or domain. It could be anything, in theory, but it seems the Google AJAX Crawling API likes it this way.
The hash, of course, just indicates that no real page reload is occurring, so yes, it’s for AJAX purposes. Edit: Raganwald does a lovely job explaining this in more detail.