<?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>maxheapsize.com &#187; Web</title>
	<atom:link href="http://maxheapsize.com/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://maxheapsize.com</link>
	<description>Oliver Wehrens on Programming and Agile</description>
	<lastBuildDate>Thu, 25 Feb 2010 08:28:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Selenium2 for web testing (and not Selenium IDE)</title>
		<link>http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/</link>
		<comments>http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 05:38:15 +0000</pubDate>
		<dc:creator>Oliver Wehrens</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[selenium ide]]></category>
		<category><![CDATA[selenium2]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[webdriver]]></category>

		<guid isPermaLink="false">http://maxheapsize.com/?p=393</guid>
		<description><![CDATA[
			
				
			
		
Selenium IDE
Selenium is well know for automatic testing web pages. It does support many browsers, operating systems and languages. A Selenium IDE exists to aid you creating automated tests. 
It is possible to write extensions in JavaScript to have data driven tests. If you organize your selenium tests in a way that you split  [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fmaxheapsize.com%2F2010%2F01%2F04%2Fusing-selenium-2-for-web-testing%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=?url=http%3A%2F%2Fmaxheapsize.com%2F2010%2F01%2F04%2Fusing-selenium-2-for-web-testing%2F&amp;source=owehrens&amp;style=normal" height="61" width="51" /><br />
			</a>
		</div>
<h3>Selenium IDE</h3>
<p><a href="http://seleniumhq.org">Selenium</a> is well know for automatic testing web pages. It does support many <a href="http://seleniumhq.org/about/platforms.htm">browsers, operating systems and languages<a/>. A <a href="http://seleniumhq.org/projects/ide/">Selenium IDE</a> exists to aid you creating automated tests. </p>
<div class="wp-caption alignleft" style="width: 313px"><img alt="Selenium" src="http://maxheapsize.com/static/selenium.png" title="Selenium IDE" width="303" height="177" /><p class="wp-caption-text">Selenium IDE</p></div>
<p>It is possible to write extensions in JavaScript to have data driven tests. If you organize your selenium tests in a way that you split  the pages and forms in components, you can  load up new data for the tests (written in xml) to fill out forms differently for each use case. The Selenium IDE will be of a great help here since you start develop the tests in the IDE and later &#8216;just&#8217; parametrize the pages. With a couple of more javascript magic you can run these as well in <a href="http://seleniumhq.org/projects/remote-control/">Selenium Remote Control</a> (Selenium RC for short). This even works for running  the tests in continuous integration systems like Hudson or Teamcity.</p>
<p>Great Stuff.</p>
<h3>The problem.</h3>
<p>The drawback coding up your tests with the Selenium IDE is: <b>HTML</b>.  </p>
<p>You will end up with some test suites including many test scenarios. It will be one big ball of </p>
<pre class="brush: xml;">
&lt;tr&gt;
  &lt;td&gt;type&lt;/td&gt;
  &lt;td&gt;accountnumber:Value&lt;/td&gt;
  &lt;td&gt;82892892811&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;type&lt;/td&gt;
  &lt;td&gt;accountAmount:Value&lt;/td&gt;
  &lt;td&gt;2345.33&lt;/td&gt;
&lt;/tr&gt;
</pre>
<p>You will build components and you will end up with GotoIf and Label statements. Back to Basic programming from the 80ties. Without more javascript extensions you also can&#8217;t reuse combinations of scenarios. </p>
<p>While this works pretty ok: I&#8217;m a programmer and do have a <strong>problem</strong> with the <strong>quality of the produced code</strong>. It&#8217;s <strong>easy to mess up</strong>. It&#8217;s <strong>not safe for refactoring</strong>. To extend functionality you need to have javascript knowledge. Depending on your company profile (e.g. java shop) , this might be a problem.  Having a dedicated tester on the team certainly helps to overcome these obstacles, but if everybody in the team just once in a while looks into the Selenium IDE tests, the quality and the reliability of the code will not improve. Not to mention all the <strong>copy and paste</strong>. Been there, done that.</p>
<h3>Selenium 2</h3>
<p>A much nicer approach for me would be something like this:</p>
<pre class="brush: java;">
WebDriver driver  = new FirefoxDriver();
AppWebTest test = new AppWebTest(driver, &quot;http://myapp.com/login&quot;);
LoggedInUser user = test.login(&quot;user&quot;, &quot;password&quot;);
Account account = user.createNewAccount(&quot;DemoAccount&quot;);
account.addPerson(PersonFactory.createPersonWithNoIncome());
...
account.verify();
</pre>
<p>This would log in a user, creates an account and assigns a person to it. Everybody could <strong>read and understand</strong> it. Furthermore you can easily reuse components and logic. I would imagine that creating a DSL, matchers and finders is everything one would need to have a very nice test scenario.</p>
<p>All that is already possible with Selenium 1 and the language bindings (more or less). </p>
<p>Just with the release of the first alpha of Selenium 2 mid december 2009 it became just a little bit easier.</p>
<p>Selenium 2 is the <strong>combined effort</strong> of Google&#8217;s Webdriver and Selenium. Webdriver tries to <a href="http://google-opensource.blogspot.com/2009/05/introducing-webdriver.html">tackle</a> Seleniums problems with Javascript and the security model as well as the complex Selenium RC API. </p>
<blockquote><p>
Selenium is written in JavaScript which causes a significant weakness: browsers impose a pretty strict security model on any JavaScript that they execute in order to protect a user from malicious scripts.<br />
&#8230;<br />
Additionally, being a mature product, the API for Selenium RC has grown over time, and as it has done so it has become harder to understand how best to use it. For example, it&#8217;s not immediately obvious whether you should be using &#8220;type&#8221; instead of &#8220;typeKeys&#8221; to enter text into a form control. Although it&#8217;s a question of aesthetics, some find the large API intimidating and difficult to navigate.
</p></blockquote>
<p>Webdriver does not use JavaScript to control the web browser but <strong>uses native controls</strong>, e.g. an extension for Firefox or the native automation extensions of IE. Furthermore it introduces an object based API instead of following Seleniums directory based approach.</p>
<p>So given the above example the login method would look something like this:</p>
<pre class="brush: java;">
 public LoggedInUser login(String userName, String password) {
    driver.get(url);
    driver.findElement(By.id(&quot;user&quot;)).sendKeys(userName);
    driver.findElement(By.id(&quot;password&quot;)).sendKeys(password);
    driver.findElement(By.id(&quot;login&quot;)).click();

    LoggedInUser user = new LoggedInUser(driver);

    WebElement startPage = driver.findElement(By.id(&quot;startPage&quot;));

    assertThat(startPage().getText()).isEqualTo(&quot;Start&quot;);
    return user;
  }
</pre>
<p>You can take this to any level. It took me just a few hours to model the above use case with componentized input elements. </p>
<p>With a bit more abstraction addPerson looks something like the following code. Whatever is needed to add a person to an account will be replayed. This is what Selenium IDE would normally do.</p>
<pre class="brush: java;">
public void addPerson(Person person) {
    jumpToAccountOverView();
    clickOnLink(&quot;menu:Overview&quot;);
    clickOnLink(&quot;table_personTable:link_newPerson&quot;);

    inputGuiElement(person.getTitle());
    inputGuiElement(person.getLastName());
...
    clickSave();
</pre>
<p>And now for the best part. You <strong>don&#8217;t really need a real web browser</strong>. Selenium 2 supports 4 WebDriver: </p>
<ul>
<li>Firefox</li>
<li>Chrome</li>
<li>Internet Explorer (on Windows)</li>
<li>HtmlUnit</li>
</ul>
<h3>HtmlUnit</h3>
<p>With enabled JavaScript on HtmlUnit (it uses Rhino, so not all JavaScript tricks might work, could be a drawback depending on your scenario) I can run my test as <strong>TestNG or JUnit</strong> test case. No need for a Selenium RC anymore. <strong>No  browsers running locally</strong> or on remote machine listing to ports to execute tests and transmitting results back. </p>
<p>It is very useful to have the Selenium RC take screen shots during it&#8217;s run. Selenium 2 can&#8217;t do this right now (and with HtmlUnit never can). But by simply integrating some logging in the components and elements and you know right away where things went wrong.<br />
Developing with the <strong>Selenium IDE</strong> might seem like a must, but during the work on my prototype all I needed was Firebug and a XPath Searcher. I <strong>did not miss it</strong> at all. To do integration tests you could test all components independently and one at a time. Once these work, chain them together and let them run as unit tests. Did I mention <strong>HtmlUnit is fast</strong> ? </p>
<h3>Conclusion</h3>
<p>I barely dug into the webdriver code, I played around with it for a couple of hours and I&#8217;m sure there more is stuff (and bugs) to find. Given that Selenium 2 is in alpha 1 stage right now I expect very nice things coming out of it. It certainly looks like the way to go. </p>
<p>Another strong contender is <a href="http://webtest.canoo.com/webtest/manual/WebTestHome.html">Canoo WebTest</a>. I will have a look at this one in another post.</p>
<p><strong>Update Ajax and HtmlUnit</strong> 1/5/2010 </p>
<p>It does not seem to work. You need a real browser to get dynamically content re-rendered through Ajax. </p>
<p>A method waiting for an id to be rendered (or timeout after x seconds) could look like this:</p>
<pre class="brush: java;">
  public void waitForElementOrTimeout(String idToWaitFor, int timeout) {
    long end = System.currentTimeMillis() + timeout * 1000;
    RenderedWebElement resultsDiv = null;
    while (System.currentTimeMillis() &lt; end) {
      try {
        resultsDiv = (RenderedWebElement) driver.findElement(By.id(idToWaitFor));
      }
      catch (NoSuchElementException e) {
        //
      }
      if (resultsDiv != null &amp;&amp; resultsDiv.isDisplayed()) {
        break;
      }
    }
    assertThat(resultsDiv).isNotNull();
  }
</pre>
<p>This will either find the element specified or throw an assertion (updated example from the selenium 2 page).</p>
<img src="http://maxheapsize.com/?ak_action=api_record_view&id=393&type=feed" alt="" /><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/&amp;title=Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/&amp;title=Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29&amp;url=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/&amp;title=Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/&amp;title=Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/&amp;bm_description=Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/&amp;title=Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/&amp;title=Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.sphere.com/sphereit/http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/" rel="nofollow" title="Add to&nbsp;SphereIt"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/sphereit.png" title="Add to&nbsp;SphereIt" alt="Add to&nbsp;SphereIt" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/&amp;title=Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Using+Selenium2+for+web+testing+%28and+not+Selenium+IDE%29+@+http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://maxheapsize.com/2010/01/04/using-selenium-2-for-web-testing/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Getting started with JSF 2 (and Maven)</title>
		<link>http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/</link>
		<comments>http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 21:21:39 +0000</pubDate>
		<dc:creator>Oliver Wehrens</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jsf]]></category>
		<category><![CDATA[jsf2]]></category>

		<guid isPermaLink="false">http://maxheapsize.com/?p=270</guid>
		<description><![CDATA[
			
				
			
		
I use Apache Trinidad at work and since JSF 2 is now final I decided to play with it a bit.
Of course this is going to be the classic Hello World example (as there are many other like this around the web).
First you need to setup a simple Maven project. 
The file layout should be [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fmaxheapsize.com%2F2009%2F07%2F03%2Fgetting-started-with-jsf-2-and-maven%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=?url=http%3A%2F%2Fmaxheapsize.com%2F2009%2F07%2F03%2Fgetting-started-with-jsf-2-and-maven%2F&amp;source=owehrens&amp;style=normal" height="61" width="51" /><br />
			</a>
		</div>
<p>I use Apache Trinidad at work and since JSF 2 is now final I decided to play with it a bit.</p>
<p>Of course this is going to be the classic Hello World example (as there are many other like this around the web).</p>
<p>First you need to setup a simple Maven project. </p>
<p>The file layout should be something like that.</p>
<div class="wp-caption alignnone" style="width: 300px"><img alt="Directory Layout for JSF 2 Ajax Demo" src="http://maxheapsize.com/static/JSF2AjaxDemoFileLayout.png" title="Directory Layout for JSF 2 Ajax Demo" width="290" height="234" /><p class="wp-caption-text">Directory Layout for JSF 2 Ajax Demo</p></div>
<p>After that change your pom.xml to include the servlet and jsf2 libs.</p>
<pre class="brush: xml;">
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.maxheapsize&lt;/groupId&gt;
  &lt;artifactId&gt;jsf2demo&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;jsf2demo Maven Webapp&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
      &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
      &lt;version&gt;2.0.0-b13&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
      &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
      &lt;version&gt;2.0.0-b13&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;jstl&lt;/artifactId&gt;
      &lt;version&gt;1.2&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
      &lt;version&gt;2.5&lt;/version&gt;
    &lt;/dependency&gt;

  &lt;/dependencies&gt;
  &lt;build&gt;
    &lt;finalName&gt;jsf2demo&lt;/finalName&gt;
  &lt;/build&gt;

  &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;maven2-repository.dev.java.net&lt;/id&gt;
      &lt;name&gt;Java.net Repository for Maven&lt;/name&gt;
      &lt;url&gt;http://download.java.net/maven/2&lt;/url&gt;
    &lt;/repository&gt;
  &lt;/repositories&gt;

&lt;/project&gt;
</pre>
<p>First we are going to create the managed bean to hold the name we are going to enter.</p>
<pre class="brush: java;">
package com.maxheapsize.jsf2demo;

import javax.faces.bean.*;
import java.io.Serializable;

@ManagedBean
@SessionScoped
public class HelloWorldBean implements Serializable {

  private String name = &quot;&quot;;

  @ManagedProperty(value = &quot;#{demoService}&quot;)
  private Service service;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public void setService(Service service) {
    this.service = service;
  }

  public String getReverseName() {
    return service.reverse(name);
  }
}
</pre>
<p>To demonstrate the dependency injection with JSF 2 I use a service to reverse the name. Simply add the @ManagedProperty with the name of the service and it will get injected. Of course we need the service. Here it is:</p>
<pre class="brush: java;">
package com.maxheapsize.jsf2demo;

import javax.faces.bean.*;

@ManagedBean(name=&quot;demoService&quot;)
@ApplicationScoped
public class Service {

  public String reverse(String name) {
    return new StringBuffer(name).reverse().toString().toLowerCase();
  }
}
</pre>
<p>Very simple&#8230;isn&#8217;t it ?</p>
<p>The only thing what&#8217;s missing is the web.xml and the webpage itself.</p>
<p>The web.xml is pretty straight forward and should not show any surprises.</p>
<pre class="brush: xml;">
&lt;!DOCTYPE web-app PUBLIC
    &quot;-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN&quot;
    &quot;http://java.sun.com/dtd/web-app_2_3.dtd&quot; &gt;
&lt;web-app&gt;
  &lt;display-name&gt;Web Application&lt;/display-name&gt;

  &lt;servlet&gt;
    &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;

  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;

  &lt;context-param&gt;
    &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
    &lt;param-value&gt;Development&lt;/param-value&gt;
  &lt;/context-param&gt;
&lt;/web-app&gt;
</pre>
<p>The index.xhtml has some differences from earlier versions of JSF. First, JSF now supports Ajax out of the box. To have this enabled you need to load the jsf.js javascript library. The inputText tag binds to our managed bean and includes an f:ajax tag. This tag determines which part should be rerendered (in this case the element with the id reverseName). F:ajax will execute on value holding components always with an &#8216;onchange&#8217; event and on action components (like commandButtons) with an &#8216;onclick&#8217; event.<br />
The output will trigger the injected service in our managed bean and return the reversed input string.</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
        &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot;
      xmlns:f=&quot;http://java.sun.com/jsf/core&quot;
      xmlns:h=&quot;http://java.sun.com/jsf/html&quot;&gt;

&lt;h:head&gt;
  &lt;title&gt;JSF Demo&lt;/title&gt;
&lt;/h:head&gt;
&lt;h:body&gt;
  &lt;h:outputScript name=&quot;jsf.js&quot; library=&quot;javax.faces&quot; target=&quot;body&quot;&gt;
&lt;/h:outputScript&gt;
  &lt;h1&gt;Ajax JSF 2 Demo&lt;/h1&gt;
  &lt;h:form&gt;

    &lt;h:inputText id=&quot;name&quot; value=&quot;#{helloWorldBean.name}&quot;&gt;
      &lt;f:ajax render=&quot;reverseName&quot;/&gt;
    &lt;/h:inputText&gt;

    &lt;h:commandButton value=&quot;Say reverse Hi via Ajax&quot;&gt;
      &lt;f:ajax execute=&quot;name&quot; render=&quot;reverseName&quot;/&gt;
    &lt;/h:commandButton&gt;
    &lt;h:outputText id=&quot;reverseName&quot; value=&quot;#{helloWorldBean.reverseName}&quot;/&gt;
  &lt;/h:form&gt;

&lt;/h:body&gt;
&lt;/html&gt;
</pre>
<div class="wp-caption alignnone" style="width: 406px"><img alt="JSF 2 Ajax Demo" src="http://maxheapsize.com/static/JSF2AjaxDemo.png" title="JSF 2 Ajax Demo" width="396" height="107" /><p class="wp-caption-text">JSF 2 Ajax Demo</p></div>
<p>And that&#8217;s it. Sure it&#8217;s a simple example, but so far I do like the minimal configuration and the ajax integration.</p>
<img src="http://maxheapsize.com/?ak_action=api_record_view&id=270&type=feed" alt="" /><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/&amp;title=Getting+started+with+JSF+2+%28and+Maven%29" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/&amp;title=Getting+started+with+JSF+2+%28and+Maven%29" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Getting+started+with+JSF+2+%28and+Maven%29&amp;url=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/&amp;title=Getting+started+with+JSF+2+%28and+Maven%29" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/&amp;title=Getting+started+with+JSF+2+%28and+Maven%29" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/&amp;bm_description=Getting+started+with+JSF+2+%28and+Maven%29" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/&amp;title=Getting+started+with+JSF+2+%28and+Maven%29" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/&amp;title=Getting+started+with+JSF+2+%28and+Maven%29" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.sphere.com/sphereit/http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/" rel="nofollow" title="Add to&nbsp;SphereIt"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/sphereit.png" title="Add to&nbsp;SphereIt" alt="Add to&nbsp;SphereIt" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/&amp;title=Getting+started+with+JSF+2+%28and+Maven%29" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Getting+started+with+JSF+2+%28and+Maven%29+@+http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://maxheapsize.com/2009/07/03/getting-started-with-jsf-2-and-maven/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Getting the Browsers GeoLocation with HTML 5</title>
		<link>http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/</link>
		<comments>http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 08:00:23 +0000</pubDate>
		<dc:creator>Oliver Wehrens</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[html 5]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[LBS]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://maxheapsize.com/?p=200</guid>
		<description><![CDATA[
			
				
			
		
Until now it was almost impossible to get the GeoLocation of a user browsing your site. You could try to use several services to more or less guess the current position. Most of the time they where using the IP address to tackle the problem. This was not very reliable when it came to mobile [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fmaxheapsize.com%2F2009%2F04%2F11%2Fgetting-the-browsers-geolocation-with-html-5%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=?url=http%3A%2F%2Fmaxheapsize.com%2F2009%2F04%2F11%2Fgetting-the-browsers-geolocation-with-html-5%2F&amp;source=owehrens&amp;style=normal" height="61" width="51" /><br />
			</a>
		</div>
<p>Until now it was almost impossible to get the <strong>GeoLocation</strong> of a user browsing your site. You could try to use several services to more or less guess the current position. Most of the time they where using the IP address to tackle the problem. This was <strong>not very reliable</strong> when it came to mobile devices. </p>
<p>Ever since the iPhone hit the market mobile adoption of the web grew exponentially. Google threw in Android and I&#8217;m sure some Windows Mobile phones do have GPS as well.  According to some talks at <a href="http://www.re-publica.de">re:publica 09</a> the big telco carriers such as T-Mobile and Vodafone see their <strong>future in the mobile (geolocation aware) web</strong>.</p>
<p>Even though these devices had the capabilities to get the current location,  website developers are still facing the problem that they can <strong>not access the positioning hardware of the phone</strong>. There was almost no way for (mobile) web developers to get the location of the user. There are some solution out there but you needed to install extra software which is not always possible on a phone. </p>
<p>Fortunately W3C is working on the <b><a href="http://dev.w3.org/html5/spec/Overview.html">HTML 5</a></b> standard which includes JavaScript <b>access to the <a href="http://dev.w3.org/geo/api/spec-source.html">browsers location</a></b> (at least I hope it will be included). The latest beta of <a href="http://en-us.www.mozilla.com/en-US/firefox/3.1b3/releasenotes/">Firefox 3.1 (beta3)</a> already supports that API.   If you don&#8217;t have a GPS system in your computer you can install an <a href="https://addons.mozilla.org/en-US/firefox/addon/8420 ">addon</a> to set your location. Rumors has it that Apple will release the upcoming <strong>iPhone 3.0</strong> OS with a location aware browser and Google will do the same with one of the next updates of <strong>Android</strong>.</p>
<p>To test that I wrote a small <a href="http://maxheapsize.com/static/html5geolocationdemo.html">geolocation aware demo webpage</a> with some JavaScript to pull out the information. If you are accessing it with Firefox 3.1b3+ (plugin installed and configured with your position) you will be prompted for unveiling your location to the website. If you do so it will show you your current position on the map and print out the address. </p>
<div class="wp-caption alignnone" style="width: 500px"><img alt="Allow access to the browsers GeoLocation" src="http://maxheapsize.com/static/html5geolocation01.jpg" title="Allow access to the browsers GeoLocation" width="490" height="482" /><p class="wp-caption-text">Allow access to the browsers GeoLocation</p></div>
<div class="wp-caption alignnone" style="width: 500px"><img alt="Showing the GeoLocation of the Browser" src="http://maxheapsize.com/static/html5geolocation02.jpg" title="Showing the GeoLocation of the Browser" width="490" height="527" /><p class="wp-caption-text">Showing the GeoLocation of the Browser</p></div>
<p>To access this information all you need to do is:</p>
<pre class="brush: jscript;">
    function showMap(position) {
      // Show a map centered at
      // (position.coords.latitude, position.coords.longitude).
    }
    // One-shot position request.
    navigator.geolocation.getCurrentPosition(showMap);
</pre>
<p>Once this feature is widely available in mobile browsers (I do hope for this summer) my bet is that we will see a whole bunch of websites doing all sort of crazy things with these information. I&#8217;m a big Location Based Services (LBS) fan and I can&#8217;t wait to see people taking advantage of this.</p>
<p> <strong>Update</strong> Firefox 3.5.x uses Google&#8217;s Geolocation service if no other way can be used. This is halfway accurate. It gathers information about nearby wireless access points and your computer’s IP address. No more plugin needed.</p>
<img src="http://maxheapsize.com/?ak_action=api_record_view&id=200&type=feed" alt="" /><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/&amp;title=Getting+the+Browsers+GeoLocation+with+HTML+5" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/&amp;title=Getting+the+Browsers+GeoLocation+with+HTML+5" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Getting+the+Browsers+GeoLocation+with+HTML+5&amp;url=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/&amp;title=Getting+the+Browsers+GeoLocation+with+HTML+5" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/&amp;title=Getting+the+Browsers+GeoLocation+with+HTML+5" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/&amp;bm_description=Getting+the+Browsers+GeoLocation+with+HTML+5" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/&amp;title=Getting+the+Browsers+GeoLocation+with+HTML+5" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/&amp;title=Getting+the+Browsers+GeoLocation+with+HTML+5" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.sphere.com/sphereit/http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/" rel="nofollow" title="Add to&nbsp;SphereIt"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/sphereit.png" title="Add to&nbsp;SphereIt" alt="Add to&nbsp;SphereIt" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/&amp;title=Getting+the+Browsers+GeoLocation+with+HTML+5" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Getting+the+Browsers+GeoLocation+with+HTML+5+@+http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://maxheapsize.com/2009/04/11/getting-the-browsers-geolocation-with-html-5/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>IE7 caches rendered elements?</title>
		<link>http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/</link>
		<comments>http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 20:19:57 +0000</pubDate>
		<dc:creator>Oliver Wehrens</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[ie7]]></category>

		<guid isPermaLink="false">http://maxheapsize.com/?p=164</guid>
		<description><![CDATA[
			
				
			
		
I&#8217;m tasked with some css tweaking to our current product. We need to implement a &#8216;Print Preview&#8217; screen so the customer can see how this looks before printing. Css supports exactly this use case with the @media notation.
So far so good.
Now Internet Explorer gives me some headache. Basically it looks like that if I render [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fmaxheapsize.com%2F2009%2F03%2F30%2Fie7-caches-rendered-element%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=?url=http%3A%2F%2Fmaxheapsize.com%2F2009%2F03%2F30%2Fie7-caches-rendered-element%2F&amp;source=owehrens&amp;style=normal" height="61" width="51" /><br />
			</a>
		</div>
<p>I&#8217;m tasked with some css tweaking to our current product. We need to implement a &#8216;Print Preview&#8217; screen so the customer can see how this looks before printing. Css supports exactly this use case with the @media notation.</p>
<p>So far so good.</p>
<p>Now Internet Explorer gives me some headache. Basically it looks like that if I render a page and then render the same page again with a slightly different style sheet, the lovely IE (7) will cache the width/text-align of the element. That means formerly right aligned text now looks like center aligned. Using FireBug under Firefox confirms the correct right aligned styled text. Even using the IE Developer Toolbar shows the correct style sheet information and element. Still, it renders sort of centered. By accident the right border of the text is exactly as far away from the left border as in the previous rendering. If I add any attribute to the text cell (or delete an attribute) all of the sudden the text will be rendered right aligned exactly how it should have been in the first place. </p>
<p>My guess is that IE remembers the width and alignment of the text cell from the previous page (why else the centered text appears to be the size). Deleting/adding an element via the developer tools forces a refresh and voila it renders how it should be.</p>
<p>I hate it.</p>
<div class="wp-caption alignnone" style="width: 275px"><img alt="First rendering of the text cell" src="http://www.maxheapsize.com/static/ie_align_01.jpg" title="First rendering of the text cell" width="265" height="22" /><p class="wp-caption-text">First rendering of the text cell</p></div> 
<div class="wp-caption alignnone" style="width: 429px"><img alt="Rendering with almost the same style sheet" src="http://www.maxheapsize.com/static/ie_align_02.jpg" title="Rendering with almost the same style sheet" width="419" height="28" /><p class="wp-caption-text">Rendering with almost the same style sheet</p></div>
<div class="wp-caption alignnone" style="width: 439px"><img alt="Identifying the cell with the IE developer toolbar" src="http://www.maxheapsize.com/static/ie_align_03.jpg" title="Identifying the cell with the IE developer toolbar" width="429" height="28" /><p class="wp-caption-text">Identifying the cell with the IE developer toolbar</p></div>
<div class="wp-caption alignnone" style="width: 524px"><img alt="Deleting the id attribute with the Developer Toolbar" src="http://www.maxheapsize.com/static/ie_align_04.jpg" title="Deleting the id attribute with the Developer Toolbar" width="514" height="89" /><p class="wp-caption-text">Deleting the &#39;id&#39; attribute with the Developer Toolbar</p></div>
<div class="wp-caption alignnone" style="width: 429px"><img alt="Voila, just after deleting the attribute, the cell renders how it should have been" src="http://www.maxheapsize.com/static/ie_align_05.jpg" title="Voila, just after deleting the attribute, the table cell renders how it should have been" width="419" height="30" /><p class="wp-caption-text">Voila, just after deleting the attribute, the cell renders how it should have been</p></div>
<p>I guess there is a solution for this, I just don&#8217;t know it. In any case&#8230;.this is unexpected behavior.</p>
<p>On top of that: using css and Apache Trindad with a print preview on screen makes it hard to manipulate the css for the printout since I just don&#8217;t know the names of the css classes nor the imported Trinidad css file name (and I do have pre compiled/packaged css file where I have to restart the server every time if I do some changes).</p>
<p>*rant off*</p>
<img src="http://maxheapsize.com/?ak_action=api_record_view&id=164&type=feed" alt="" /><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/&amp;title=IE7+caches+rendered+elements%3F" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/&amp;title=IE7+caches+rendered+elements%3F" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=IE7+caches+rendered+elements%3F&amp;url=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/&amp;title=IE7+caches+rendered+elements%3F" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/&amp;title=IE7+caches+rendered+elements%3F" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/&amp;bm_description=IE7+caches+rendered+elements%3F" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/&amp;title=IE7+caches+rendered+elements%3F" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/&amp;title=IE7+caches+rendered+elements%3F" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.sphere.com/sphereit/http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/" rel="nofollow" title="Add to&nbsp;SphereIt"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/sphereit.png" title="Add to&nbsp;SphereIt" alt="Add to&nbsp;SphereIt" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/&amp;title=IE7+caches+rendered+elements%3F" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+IE7+caches+rendered+elements%3F+@+http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://maxheapsize.com/2009/03/30/ie7-caches-rendered-element/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
