<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Really Aced &#187; JavaScript</title>
	<atom:link href="http://blog.sommestad.net/category/development/javascript-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sommestad.net</link>
	<description>Web and Cocoa development through the eyes of Kristofer Sommestad, a SWAD developer.</description>
	<lastBuildDate>Sun, 23 Jan 2011 12:21:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Trying Google Web Toolkit again – and liking it</title>
		<link>http://blog.sommestad.net/2010/01/trying-google-web-toolkit-again-and-liking-it/</link>
		<comments>http://blog.sommestad.net/2010/01/trying-google-web-toolkit-again-and-liking-it/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 10:26:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[google web toolkit]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://blog.sommestad.net/?p=265</guid>
		<description><![CDATA[A while back, I tried out Google Web Toolkit to see if it was any interesting. My main concerns after that early glance was the stability of the applications and the possibilities to mix GWT code with plain JavaScript code. Giving it another stab I decided to give it another go last week, when re-building [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, <a href="http://blog.sommestad.net/2009/03/a-first-glance-at-gwt-2/">I tried out Google Web Toolkit</a> to see if it was any interesting. My main concerns after that early glance was the stability of the applications and the possibilities to mix <a href="http://code.google.com/intl/en/webtoolkit/overview.html">GWT</a> code with plain JavaScript code.</p>
<h3>Giving it another stab</h3>
<p>I decided to give it another go last week, when re-building the <a href="http://www.spotiseek.com/mixtape/Coldplay">mixtape interface</a> for my side project <a href="http://www.spotiseek.com">Spotiseek</a>. A few things led me to creating an &#8220;Ajax&#8221; application with GWT:</p>
<ul>
<li>quite a few requests are required to present the view &#8211; I needed the requests to be cached in the client to reduce the server load</li>
<li>I needed an application built on stable and easily maintainable code</li>
<li>I figured it would be a good chance to learn more about GWT</li>
</ul>
<div id="attachment_269" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.sommestad.net/wp-content/2010/01/spotiseek_mixtape_screen.png"><img class="size-medium wp-image-269" title="Spotiseek Mixtape" src="http://blog.sommestad.net/wp-content/2010/01/spotiseek_mixtape_screen-300x231.png" alt="Spotiseek Mixtape based on Coldplay" width="300" height="231" /></a><p class="wp-caption-text">Spotiseek Mixtape interface</p></div>
<h3>Drawing some conclusions</h3>
<p>After completing the first release of the new interface, I feel confident enough to draw a few conclusions:</p>
<h4>Positive: It&#8217;s Java!</h4>
<p>When looking to write stable and easily maintained code, I really can&#8217;t find any better candidate than Java. Since I&#8217;ve been working with Java for a number of years, I&#8217;m of course very comfortable with developing GWT apps.<br />
The syntax is nice and clean and of course the magic of the fantastic <a href="http://www.jetbrains.com/idea/">IntellJ IDEA</a> is indispensible.</p>
<h4>Positive: It does what I want it do do</h4>
<p>It might appear a ridiculuous header, but I have to say it&#8217;s very easy to create widgets that does exactly what you want. There&#8217;s little confusion on how to actually construct the application.</p>
<h4>Negative: Problematic project setup in the IDE</h4>
<p>Even though IntelliJ is a fantastic IDE, there&#8217;s appearantly some improvements that could be made to the setting up of GWT projects.</p>
<p>Just setting up a GWT project is not a huge matter, but trying to add a GWT project module to an existing web project was a lot of hassle. There was a lot of problems getting the built-in build/make process to put the files in the right place etc.</p>
<h4>Negative: Surprisingly poor community support</h4>
<p>I honestly thought that the usage of GWT would be more widely spread across the internet. But when I &#8211; from time to time &#8211; got stuck with an issue, there wasn&#8217;t really that much help from Googling.</p>
<p>There are of course a few good forums and such where many questions are answered, but unfortunately not the answers I was looking for. I had to dig deeper in the Google documents in  order to get enough info to draw my own conclusions.</p>
<p>EDIT: One nice resource I&#8217;ve found is <a href="http://raibledesigns.com/rd/entry/developing_and_testing_gwt_client">Matt Raible&#8217;s blog</a>.</p>
<p>Maybe it&#8217;s not inadequate for most issues, but I had expected more&#8230;</p>
<h4>(Sort of) Negative : Building everything from scratch</h4>
<p>Usually, you try to mix as much HTML and JavaScript as possible in order to write code more efficiently. Building it all up from scratch is often a quite expensive process and rarely gives you the most maintainable code.</p>
<p>But with GWT I didn&#8217;t really see any way of not building everything from scratch. Partly because it&#8217;s very easy to do so, but also because I didn&#8217;t find any good way of reusing existing HTML components.</p>
<p>I&#8217;m not sure it&#8217;s a true negative having to build everything from scratch, but it requires a somewhat different approach than you might be used to.</p>
<h3>To sum it up&#8230;</h3>
<p>Even though there was a few problems during the development, <strong>I&#8217;m glad I chose to develop the application in GWT</strong>. It&#8217;s resulted in a nice (enough) application, built on code that is stable and easy to maintain.</p>
<p>Also, I&#8217;ve learned a lot about GWT development and will have no problems going forward with the development.</p>
<p>(Apart from the conclusions I&#8217;ve drawn, there&#8217;s of course <a href="http://code.google.com/intl/en/webtoolkit/overview.html">a bunch of positives</a> that comes with developing GWT applications. )</p>
<h4>Maybe not suitable for all products</h4>
<p>As I&#8217;ve stated before, I still feel that you should always consider if GWT is the best approach for your particular application.<br />
I guess a certain amount of complexity is required, as it&#8217;s probably more tedious to write GWT Java code than regular JavaScript. If you&#8217;re going to develop a small-sized application, you&#8217;re probably best of doing it the old fashion way.</p>
<h4>SEO issues with JavaScript applications</h4>
<p>Of course, there are some issues with building your applications in JavaScript. One of them being the drawback in Search Engine Optimization (SEO), as your content is hidden from the indexing robots.<br />
I know <a href="http://googlewebmastercentral.blogspot.com/2009/10/proposal-for-making-ajax-crawlable.html">Google have proposed a new standard</a> for specifying JavaScript content, in order to make the robots understand how to activate the content. But we&#8217;ll see what happens there&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sommestad.net/2010/01/trying-google-web-toolkit-again-and-liking-it/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sometimes you&#8217;re just an honest guy trying to script</title>
		<link>http://blog.sommestad.net/2009/05/sometimes-youre-just-an-honest-guy-trying-to-script-2/</link>
		<comments>http://blog.sommestad.net/2009/05/sometimes-youre-just-an-honest-guy-trying-to-script-2/#comments</comments>
		<pubDate>Wed, 27 May 2009 17:04:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[onbeforeunload]]></category>
		<category><![CDATA[onunload]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[security issues]]></category>
		<category><![CDATA[unload confirmation]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://reallyaced.wordpress.com/?p=97</guid>
		<description><![CDATA[Today, I ran into some JavaScript security issues that cost me a few hours too many of my life. I wanted to show the user a confirmation message when closing a pop-up (OK I know, but sometimes you just got to use them!) to make sure he doesn&#8217;t lose any data when leaving. But we [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I ran into some JavaScript security issues that cost me a few hours too many of my life.</p>
<p>I wanted to show the user a confirmation message when closing a pop-up (OK I know, but sometimes you just got to use them!) to make sure he doesn&#8217;t lose any data when leaving.</p>
<h3>But we can do this! Right&#8230;?</h3>
<p>This isn&#8217;t really any big issue, as the <em>onBeforeUnload</em> event can be used for these exact scenarios, with a nice message too:</p>
<pre style="padding-left:30px;">window.onbeforeunload = function (event) {
    <span style="color:#888888;">// message to display (in between the standard message provided by the browser)</span>
    return "Leaving now will have you lose everything."
};</pre>
<p>The special case here was that I had a SWF running in the window, which needs to be unloaded (close its connections etc) when closing the browser window. That has to be done in the <em>onBeforeUnload</em> event as well, since it&#8217;s too late when we&#8217;re at <em>onUnload</em>.<br />
The problem is that there&#8217;s no way of knowing what the user answered to the question arisen from <em>onBeforeUnload</em>, other than finding out when the event&#8217;s traveled onwards to the <em>onUnload</em> event. By which time it is too late.</p>
<p>So I ended up in a situation where everything was fine if the user decided to keep the browser window open (&#8220;Cancel&#8221; in the confirmation box), but should he close the window &#8211; which is fine too &#8211; I had no way of closing the connections etc in the SWF.</p>
<h3>But why?</h3>
<p><strong> </strong>The reason to this is of course a security matter. Some clever fellas have set some restrictions to what you can do with Javascript to avoid misuse, for example extreme annoyance with pop-up ads or such. There&#8217;s nothing wrong with that.<br />
But sometimes you just want to yell to JavaScript&#8217;s mom and tell her that I&#8217;m a perfectly honest guy trying to make the world better for my users! <img src='http://blog.sommestad.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>What would&#8217;ve helped me</h3>
<p><strong> </strong>So what do I want, then? Well, it would&#8217;ve been nice if I could&#8217;ve gotten an answer from the confirmation box rendered with my custom message (&#8220;OK, leaving now&#8230;&#8221;).<br />
It&#8217;s perfectly fine that the unload event cannot be stopped once the user&#8217;s said &#8220;OK, close&#8221;. But at least I would&#8217;ve wanted the chance to act upon the user&#8217;s choice before the document was unloaded.</p>
<p>So my final solution was just to warn the user that everything was hitting the fan, and at the same point notify my SWF that it was to be unloaded etc. It&#8217;s an OK solution, but not perfect from a usability perspective&#8230;</p>
<p>End of rant.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sommestad.net/2009/05/sometimes-youre-just-an-honest-guy-trying-to-script-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A first glance at GWT</title>
		<link>http://blog.sommestad.net/2009/03/a-first-glance-at-gwt-2/</link>
		<comments>http://blog.sommestad.net/2009/03/a-first-glance-at-gwt-2/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 14:12:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://reallyaced.wordpress.com/?p=46</guid>
		<description><![CDATA[Web applications of today are often required to be quite complex &#8211; AJAX offers lots of nifty ways of giving the user a great experience. But developing stable applications using lots of JavaScript code can be quite challenging. Even though there&#8217;s help from great libraries such as Prototype, YUI and jQuery, it&#8217;s tricky to keep [...]]]></description>
			<content:encoded><![CDATA[<p>Web applications of today are often required to be quite complex &#8211; AJAX offers lots of nifty ways of giving the user a great experience. But developing stable applications using lots of JavaScript code can be quite challenging. Even though there&#8217;s help from great libraries such as Prototype, YUI and jQuery, it&#8217;s tricky to keep the code bullet-proof and fully tested.<br />
Also, it can be difficult maintaining a decent architecture as the application grows, i.e. how to implement an MVC solution.</p>
<p>There&#8217;s of course a few people out there trying to address these issue, one of which being Google Web Toolkit (GWT).<br />
We&#8217;ve discussed GWT from time to time, but haven&#8217;t really made a true effort of delving into it. I decided to try to find out how it really works and if it&#8217;s something for us to use in our applications.</p>
<h3>Do we really need it?</h3>
<p>I guess the first question you need to ask yourself is if you really need anything like GWT. Is our goal to build a full-feathered AJAX site without any browser reloading of pages? Do we want something with features like Gmail (from dialogues to rich-text editors)?</p>
<p>After researching GWT for a while, my feeling is that you either fully implement it (with effects on server-side and all) or you stick to using &#8220;old, self-developed&#8221; Javascript code. If you&#8217;re to have any kind of client-server communication (which you are), you&#8217;ll probably have to make some adjustments on the server-side as well.</p>
<p>Anyway&#8230; I tested a sample implementation usin GWT and as a Java fan, I was of course enjoying writing nice, strict Java code with full IDE support instead of regular JavaScript. There was really nothing to complain about when it comes to writing GWT code and it was fairly easy to get started and the compilation was quick enough and provided a nice debugging tool.</p>
<h3>Are there any limitations?</h3>
<p>My main concern is that using GWT will come with some limitations:</p>
<ul>
<li>What if I don&#8217;t what to write the code exactly like it&#8217;s done with GWT? Will I have to write all my code using GWT?</li>
<li>How painful is it really to mix &#8220;regular&#8221; Javascript with GWT code (they offer a way of doing it, but it doesn&#8217;t seem like something you&#8217;d really want to do)?</li>
<li>Is it really stable enough for an entire application/game? To be honest, the GWT site itself is actually quite buggy&#8230;</li>
</ul>
<p>One nice feature that comes with GWT is the support for creating modules. It seems quite easy to create a smaller module (perhaps a text-editor) and plug it in to your application. I&#8217;d say that doing so would be a first good test of GWT, as it still feels a bit scary to rely on it for an entire application (i.e. creating entire pages, browser history states etc).<br />
Maybe using it for smaller modules the best use of GWT in our case? It would be really nice if server-developers (Java guys) could implement advanced client-side features without being afraid to mess it all up&#8230; <img src='http://blog.sommestad.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>To sum it up&#8230;</h3>
<p>I guess these questions never will be answered unless I/we actually try it out in a real implementation (or at least a real-enough prototype). There&#8217;s obviously a whole lot of things with GWT that is really nice, but I wouldn&#8217;t feel fully comfortable relying on it as of today. Trying it out in a module or two would probably be the best way to draw some real conclusions.</p>
<p>In the end, it&#8217;s all about what you and your product really need.</p>
<h3>References</h3>
<p><a href="http://code.google.com/intl/sv/webtoolkit/overview.html">Google Web Toolkit Website</a></p>
<p><a href="http://www.scribd.com/doc/7246148/Manning-GWT-in-Practice">GWT in Practice &#8211; Ebook</a> (lots of reading)</p>
<p><a href="http://extjs.com/explorer/#editablegrid">Ext GWT Library (great widgets)</a></p>
<p><a href="http://www.gwtsite.com/">Unofficial GWT blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sommestad.net/2009/03/a-first-glance-at-gwt-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Changing page without reloading browser</title>
		<link>http://blog.sommestad.net/2009/03/changing-page-without-reloading-browser-2/</link>
		<comments>http://blog.sommestad.net/2009/03/changing-page-without-reloading-browser-2/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 12:11:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sofea]]></category>

		<guid isPermaLink="false">http://reallyaced.wordpress.com/?p=25</guid>
		<description><![CDATA[I wanted to investigate if we can build web applications that doesn&#8217;t require reloading of pages in the browser, according to the principles of  Life above the Service Tier. Evaluation I started by reading the &#8220;Life Above the Service Tier&#8221; document, which was a description how it works today (and its flaws) and what the [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to investigate if we can build web applications that doesn&#8217;t require reloading of pages in the browser, according to the principles of  <a href="http://wisdomofganesh.googlegroups.com/web/Life+above+the+Service+Tier+v1_1.pdf">Life above the Service Tier</a>.</p>
<h3>Evaluation</h3>
<p>I started by reading the &#8220;Life Above the Service Tier&#8221; document, which was a description how it works today (and its flaws) and what the proposed solution is.<br />
Also, I browsed the web for more articles, blog posts and comments on the issue.</p>
<h3>Summary</h3>
<p>The ideology (called SOFEA: Service-Oriented Front-End Architecture) is basically to put more rendering logic on the client side and only use the server side to transport data back and forth.</p>
<p>The principles of SOFEA could be implemented with help from AJAX. The controller resides on the client-side and is responsible for loading (XML) data and rendering the application using the received data, without actually reloading the page in the browser.<br />
This means that JavaScript would be used instead of HTML/JSP to render the server data. Also, the server-side is much thinner and not really in need of any web framework (as all it does is receive messages and return XML data).</p>
<h3>Conclusion</h3>
<p>The principles of SOFEA seem very far away from today. There are several flaws with implementing in the suggested manor:</p>
<ul>
<li>The web clients (browsers) of today <span style="text-decoration: line-through;">are not good enough to handle</span> could have problems handling as much logic as a large web site would require (given that old IE versions have so many users, ca 70-85%)</li>
<li>The client code (JavaScript) and architecture is not really mature/good enough to handle this much logic, given that it needs to be bullet-proof, easy to test etc (EDIT: unless using GWT or similar &#8211; it&#8217;s at least difficult to manage)</li>
<li>Developing applications would take much more time (hence be more expensive) as more manual labour is required to render content using JavaScript instead of letting the JSP engine do it with JSP/HTML/PHP/etc</li>
</ul>
<p><strong>Everything points to NOT implementing it in such a manor.</strong> At least not at this time, partly because the browser/client market isn&#8217;t ready for it.</p>
<h3>Is there an other way?</h3>
<p>Yes, there are other solutions to the main issue; changing pages without actually reloading the container (browser).</p>
<p>One suggested solution could be an extension to our model in Taikai, where AJAX can be used in combination with both XML, HTML/JSP and JSON, hence giving us the possibility to smoothly serve a full JSP page using AJAX.</p>
<h3>A brief description of how it <em>could </em>be solved:</h3>
<ul>
<li>Make a JavaScript &#8220;controller&#8221; handle all URL requests to the server, in order to bind the answer to a certain action.</li>
<li>Set up &#8220;View XML files&#8221; for all views that are to be loaded with AJAX. The view could look something like this:</li>
</ul>
<pre style="padding-left:30px;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xmlRoot&gt;
&lt;title&gt;Document title&lt;/title&gt;
&lt;styles&gt;
&lt;src&gt;/css/foo.css&lt;/src&gt;
&lt;src&gt;/css/bar.css&lt;/src&gt;
&lt;/styles&gt;
&lt;scripts&gt;
&lt;src&gt;/js/foo.js&lt;/src&gt;
&lt;src&gt;/js/bar.js&lt;/src&gt;
&lt;/scripts&gt;
&lt;content id="targetContainerId"&gt;
&lt;![CDATA[&lt;jsp:include file="foo.jsp" /&gt;]]&gt;
&lt;/content&gt;
&lt;/xmlRoot&gt;</pre>
<ul>
<li>When returning the response from the server, the returning page would be the pre-defined XML (as per above).</li>
<li>The controller parses the contents of the returned XML file and performs its magic:</li>
</ul>
<ol>
<li>Changing the document title</li>
<li>Loading new styles and scripts (and possibly unloading old ones to keep the page slim)</li>
<li>Updating the content element (with id=&#8221;targetContainerId&#8221;) with the provided content, which has been rendered by the JSP engine and therefore taking advantage of its power (i.e. JSTL, HTML tags etc etc).</li>
<li>Updating the browser history using hash (#) technique, allowing for back/forward movement while remaining in the same page container</li>
</ol>
<h3>The main advantages with such a solution would be:</h3>
<ul>
<li>Allowing developers to create content using known and powerful formats, such as HTML and JSP</li>
</ul>
<ol>
<li>Very important in respect to time efficiency</li>
<li>Still allows for easier debugging and development</li>
<li>No need to put too much logic on the JavaScript side, i.e. creating elements etc (although it could still be done in some components, if needed/wanted)</li>
</ol>
<ul>
<li>Still providing the user with the quicker experience of a site without (or with few) full page reloads</li>
</ul>
<h3>Remaining questions:</h3>
<ul>
<li>Would there be any risk of memory leaks, especially in older Internet Explorer browsers? And is there an easy way of eliminating these?</li>
<li>Is the support for &#8220;hash history technique&#8221; good enough in all major browsers?</li>
</ul>
<h3>References</h3>
<ul>
<li><a href="http://www.slideshare.net/andre.neubauer/sofea-soui-web-future-without-web-frameworks-presentation">Presentation of a suggested full SOFEA solution with AJAX and Comet</a></li>
<li><a href="http://css.dzone.com/news/choosing-an-ajax-framework">Discussion on a SOFEA development project</a></li>
<li><a href="http://bittwiddler.wordpress.com/2008/05/04/sofea-is-beautiful/">Summary of the large &#8220;Life above&#8230;&#8221; document and subjective comments</a></li>
<li><a href="http://azeditech.com/node/44">Comments on SOFEA flaws</a></li>
<li><a href="http://groups.google.com/group/sofea/topics">SOFEA Google Group with discussions</a></li>
<li><a href="http://raibledesigns.com/rd/entry/re_life_above_the_service">Matt Raible&#8217;s views on why and why not to use SOFEA</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sommestad.net/2009/03/changing-page-without-reloading-browser-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

