tag:blogger.com,1999:blog-239399802024-03-07T17:16:49.573+11:00Java and other thingsAnonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.comBlogger126125tag:blogger.com,1999:blog-23939980.post-85403744402753546712011-04-07T01:39:00.002+10:002011-04-07T01:42:44.921+10:00Surprise<p>I was washing the dishes after dinner tonight. I was going to put the cuttlery away when I got surprised.</p><p><a href="http://www.flickr.com/photos/hanuska/5595010211/"><img src="http://farm6.static.flickr.com/5308/5595010211_f17d384b8b_m.jpg" alt="Surprise!"/></a></p><p>I love you son!</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com1tag:blogger.com,1999:blog-23939980.post-61149996338166699332011-04-07T00:59:00.002+10:002011-04-07T01:03:13.001+10:00Sokoban<p>My wife and I were having dinner tonight. As it usually happens out little son finished quickly and was getting restless. So we put him down from his chair and carried on with our meals. Soon after he pulled his chair from the table and pushed it to the door that leads to our backyard. I kept an eye on him, just like any parents would do with a boy who is always up to something. So he pulled this chair to the door, climbed on top of it and the victoriously stood on it, giving me the biggest smile he could. His eye were saying <cite>"Look dad! I did it!"</cite></p><p>Then I realized what he was up to. He put his little hand up and tried to reach for the air-conditioning unit above him. Near the ceiling. I was impressed with the little guy’s thinking. He used the same logic we (big guys) would use to reach to places that we naturally cannot reach as our bodies do not extend that far. He just underestimated the distance. He is only two. Almost. I praised him for his effort and I told him that he’s done well and he will get there but it may take a few years until he is big enough.</p><p>At that very moment I realized that for these little ones with no limits, no boundaries pre-set in their minds the sky is the true limit.</p><p>After I asked him to come down (just to be safe) he started pushing that chair around. He maneuvered with it around the kitchen and eventually made it to the very spot he took this chair from. <a href="http://en.wikipedia.org/wiki/Sokoban">Sokoban</a>! The only movement my son decided to use was to push the chair. It was fun for him, as well as for me watching him. When he made it do the destination, it dawned on me. He just performed a real-life version of Sokoban. Wow! The kiddo is smart and I wish I was back in 80-ties to re-invent the popular computer game :-)</p><p>Don’t limit your kids. Let them explore, invent and make up their own rules for this world they live in.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com2tag:blogger.com,1999:blog-23939980.post-21442188749101753102010-09-07T13:00:00.004+10:002010-09-07T14:05:50.650+10:00404! Why? Where from?<p>Alright, so you got 404'd! Things aren't that bad because you <a href="http://hanuska.blogspot.com/2010/09/handling-http-404-page-not-found.html">handled it nicely</a>, but the real question you have on the tip of your tongue is <cite>"What URL caused this 404?"</cite></p><p>The request could receive the following attributes that can indicate what caused the error<p><h2>Where did it come from?</h2><p>To get the original URL of the request that is in trouble, look at <strong>javax.servlet.error.request_uri</strong> request attribute.</p><code><pre style="color:blue">String uri = (String) request.getAttribute("javax.servlet.error.request_uri");</pre></code><h2>What caused it?</h2><p>To cause of the error can be a HTTP error or an exception that was not handled by the web application and propagated all the way up. The three attributes that will give you more insight are:<ul><br /><li><strong>javax.servlet.error.status_code:</strong><br/>An Integer telling the error status code, if any</li><li><strong>javax.servlet.error.exception_type:</strong><br/>A Class instance indicating the type of exception that caused the error, if any</li><li><strong>javax.servlet.error.message:</strong><br/>A String telling the exception message, passed to the exception constructor</li><li><strong>javax.servlet.error.exception</strong>:<br/>A Throwable object that is the actual exception thrown</li></ul></p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-8796599096591375062010-09-07T10:31:00.004+10:002010-09-07T14:05:38.238+10:00Handling HTTP 404 - Page Not Found<p>If you develop web applications, you are most likely familiar with Java Servlets and Java Server Pages (JSP). JSPs can be accessed by a path that directly relates to their relative location to the web app's content root directory. Servlets however are typically accessed via path that match URL patterns defined for each servlet in the servlet mapping element of the deployment descriptor (web.xml).</p><p>What happens if a user types in a URL that will reach your web application, but does not map to to any of your servlets nor JSPs? Most likely this occurrence will be handler by the servlet container itself by sending HTTP 404 code back to the user's browser. A <a href="http://en.wikipedia.org/wiki/HTTP_404">404 page</a> will be displayed. 404 is a <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error">HTTP response status code</a> that indicates that <cite>a resource could not be found but may be available again in the future.</cite> Most of the servlet containers do not serve user-friendly 404 pages.</p><p>You are better off handling 404 by the web application itself. The content of the 404 page can be then customized to suit your web application's needs. You could take a <a href="http://www.hongkiat.com/blog/60-really-cool-and-creative-error-404-pages/">funny approach</a> or present something more helpful, e.g. a sitemap.</p><p>Example from <a href="http://www.youanditee.com">YOU & I tee</a> - <a href="http://www.youanditee.com">couple t-shirts</a>:<br/><a href="http://www.flickr.com/photos/youanditee/4966498748/"><img src="http://farm5.static.flickr.com/4125/4966498748_740b90461a_m_d.jpg" alt="404 Page Not Found"/></a></p><p>So how do we do this?</p><h2>Step 1 - Create error page description</h2><p>Add an error-page element to your web applications deployment descriptor. Open web.xml file and add a section like the following:</p><code><pre style="color:blue"><error-page><br /> <error-code>404</error-code><br /> <location>/error404.jsp</location><br /></error-page></pre></code><h2>Step 2 - Create error JSP</h2><p>At the location as specified in step 1 create a new JSP file that will serve the content you desire. And that's it really.</p><h2>Handling exceptions</h2><p>In a similar fashion you can handle uncaught exceptions that would otherwise end up in the user's browser. For example:<p><code><pre style="color:blue"><error-page><br /> <exception-type>java.lang.RuntimeException</exception-type><br /> <location>/exception.jsp</location><br /></error-page></pre></code><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-33827075669333431022010-06-27T02:22:00.003+10:002010-06-27T02:35:20.329+10:00JavaZone Trailer: Java 4-ever<p>This is an absolutely awesome movie trailer!</p><p><object width="520" height="317"><param value="http://www.youtube.com/v/KrfpnbGXL70&hl=en_US&fs=1&hd=1" name="movie"><param value="true" name="allowFullScreen"><param value="always" name="allowscriptaccess"><embed width="520" height="317" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://www.youtube.com/v/KrfpnbGXL70&hl=en_US&fs=1&hd=1"/></object></p><p>...from the director of <strong>JAVATAR</strong> and <strong>.NOT</strong></p>
<br /><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-64108048759400794672010-05-03T13:40:00.005+10:002010-05-03T13:51:24.175+10:00How to wire a constant in Spring<p><a href="http://www.springsource.org/">Spring</a> is a great framework for dependency injection. It helps creating new instances and inject them with references to other objects via constructor arguments or setter methods.</p><p>To create a new instance of a class one simply declares a new bean</p><pre style="color:blue"><bean id="firstDay" class="com.mypackage.Day"><br /> <constructor-arg type="java.lang.Integer" value="1" /><br /></bean></pre><p>But what if you do not want to create a new instance. Perhaps you already have a class with instances declared as publicly accessible constants (public static) and you just want to access them in the wiring process.</p><p>It's easy to get a hold of a constant. Simply use the following</p><pre style="color:blue"><util:constant id="firstDay" static-field="com.mypackage.Day.MONDAY"/></pre><p>For this to work you'll need to include the following</p><pre style="color:blue"><beans<br /> xmlns="http://www.springframework.org/schema/beans"<br /> ...<br /> xmlns:util="http://www.springframework.org/schema/util"<br /> xsi:schemaLocation="http://www.springframework.org/schema/util ..."<br />></pre><p>So there you go, now you have constants wired.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com1tag:blogger.com,1999:blog-23939980.post-16607052477778346962010-01-08T01:13:00.003+11:002010-01-08T01:22:52.675+11:00Xmas Party 2009<p><a href="http://www.hothouse.com.au/">HotHouse</a> had a great <a href="http://blog.hothouse.com.au/2010/01/06/hothouse-christmas-party/">Christmas party</a> at <a href="http://www.peatsbite.com.au/">Peats Bite</a> restaurant last year.</p><p><img src="http://farm5.static.flickr.com/4033/4212772466_1321356186.jpg" alt="drink"></p><p>See the rest of the photos in my <a href="http://www.flickr.com/photos/hanuska/sets/72157622941393223/">photo set</a>.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com1tag:blogger.com,1999:blog-23939980.post-61369413141801044872009-09-03T22:52:00.002+10:002009-09-03T23:08:44.940+10:00jQuery and checkboxes<p>Let's start with a simple checkbox like this:</p><pre style="color: blue;"><input type="checkbox" name="foo" value="bar" /></pre><p>To check whether this checkbox is checked you can do either of the following two alternatives:</p><pre style="color: blue;">$('input[name=foo]').is(':checked')<br />$('input[name=foo]').attr('checked')</pre><p>To check the checkbox we can use the attr() function</p><pre style="color: blue;">$('input[name=foo]').attr('checked', true);</pre><p>And likewise to uncheck it</p><pre style="color: blue;">$('input[name=foo]').attr('checked', false);</pre><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-79414386917597887822009-07-31T11:15:00.004+10:002009-07-31T11:28:00.252+10:00Leveraging Google to build your business<p>I read a nice post this morning about <a href="http://www.coderoshi.com/2009/07/build-business-with-google.html">building business with Google</a> by Eric at <a href="http://www.coderoshi.com/">過労死 Death by Overcoding</a>.</p><p>It covers many aspects that may be involved in administering your business needs, such as:<ul><li>Domain registration/host/email/office apps</li><li>Phone Management</li><li>Blog</li><li>The Application</li><li>Payments</li><li>AdWords</li><li>Analytics</li><li>Integration/Optimization</li></ul></p><p>I recommend reading it to anyone who is starting up a web business. Following the steps mentioned in that blog post can be a real timesaver. And you do not need to hire an admin to do it all.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-34771590899777151322009-07-30T17:02:00.005+10:002009-07-30T22:27:41.501+10:00Detect an AJAX request<p>Many web applications use AJAX nowadays. In a typical scenario, one fills out a form, which is then submitted to the server. If you don't use AJAX or JavaScript is disabled, your form should still submit with no problems. And you receive a new page. If you use unobtrusive enhancement via JavaScript, the form is submitted to the server and the page is updated with the result without a full page reload.</p><p>While developing with Grails writing Java and Groovy code, I noticed that a typical pattern is to create two actions in a controller. One to handle normal HTTP POST <em>(e.g. <strong>save</strong> action)</em> and one to handle HTTP POST coming from an AJAX request <em>(e.g. <strong>saveAjax</strong> action)</em>. The two actions are almost identical. They perform the same business logic. The only difference is what is returned from each action. A <em>normal</em> action renders a new page. An AJAX one returns whatever your flavor is: XML, JSON, HTML, plain text.</p><p>So is there a way to tell the requests (ordinary and AJAX) apart?</p><p>You guessed it, there is. AJAX request comes with a special header - <strong>X-Requested-With</strong>. I usually have my controllers to extend my BaseController, which has a couple of useful methods that I use. <strong>isAjax(request)</strong> is one of them. And this is what it looks like.</p><code><pre style="color: blue;"><br />public static boolean isAjax(request) {<br /> return "XMLHttpRequest".equals(request.getHeader("X-Requested-With"));<br />}<br /></pre></code><p>I hope you'll find it useful. The all you need to do in your action is this:</p><code><pre style="color: blue;"><br />def save = {<br /><br /> // business logic<br /> // ...<br /><br /> if (isAjax(request)) {<br /> render([ /* data */ ] as JSON)<br /> }<br /> else {<br /> // render or redirect here<br /> render(view: 'save', model: [ /* model data */ ])<br /> }<br />}</pre></code><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com6tag:blogger.com,1999:blog-23939980.post-52026126758363457972009-07-30T16:35:00.004+10:002009-07-30T16:48:29.420+10:00Grails.org has a new home page design<p>I absolutely love the new design of the <a href="http://grails.org/">grails.org</a> home page. It's sleek, clean, easy to find what you need. Simply brilliant!</p><p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjdqIhNjcwUCGlh7wUv9PWNBbtE2Qy7tb9whWt9yPIJGJ1h-NMSOWlKlw5xyq5ppcmHwfa27ntvh-G70W7FxWjS8ljf2IvHAT2e95Du6YLITx51xdxljJuammgExzpQJ3_zTdo/s1600-h/grails.png"><img style="margin: 0pt 10px 10px 0pt; cursor: pointer; width: 200px; height: 107px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjdqIhNjcwUCGlh7wUv9PWNBbtE2Qy7tb9whWt9yPIJGJ1h-NMSOWlKlw5xyq5ppcmHwfa27ntvh-G70W7FxWjS8ljf2IvHAT2e95Du6YLITx51xdxljJuammgExzpQJ3_zTdo/s200/grails.png" alt="" id="BLOGGER_PHOTO_ID_5364139048169741778" border="0" /></a></p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-73868537851709538892009-03-13T10:03:00.003+11:002009-03-13T10:13:41.166+11:00Visual Event<p>This is a really neat tool by <a href="http://www.sprymedia.co.uk/">Allan Jardine</a>, a UI developer! It makes it so easy and visual to see what even handlers are attached to the elements of a page. Great addition to my toolbox!</p><blockquote>When working with events in Javascript, it is often easy to loose track of what events are subscribed where. This is particularly true if you are using a large number of events, which is typical in a modern interface employing progressive enhancement. Javascript libraries also add another degree of complexity to listeners from a technical point of view, while from a developers point of view they of course can make life much easier! But when things go wrong it can be difficult to trace down why this might be.</blockquote><p>Read the whole article about <a href="http://www.sprymedia.co.uk/article/Visual+Event">Visual Event</a></p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-69754606456341617062009-01-18T00:59:00.003+11:002009-01-18T01:13:00.557+11:00jQuery 1.3 upgrade & selector bug<p>I've just upgraded my website to jQuery 1.3. First thing that broke was the attribute selector. This was well documented in the <a href="http://docs.jquery.com/Release:jQuery_1.3">jQuery 1.3 Release Notes</a> - <a href="http://docs.jquery.com/Release:jQuery_1.3#Upgrading">Upgrading</a> as well as in the <a href="http://docs.jquery.com/Selectors">documentation</a>. So this was easily fixed.</p><p>Another problem I had was with a selector matching <select> tags, such as</p><pre>$('.size select')</pre><p>For some reason it is no longer matching the <select> tag, but it's <option> tags instead. There is plenty of buzz about how jQuery switched to <a href="http://sizzlejs.com/">Sizzle.js</a> selector engine and all the performance gains. I have not found any information pointing to the change that causes by selector bug. Navigating to the parent node solved the issue for me, but it's more like an ugly hack rather than expected behavior.</p><pre>$('.size select').parent()</pre><p>Anybody else noticed this problem?</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com2tag:blogger.com,1999:blog-23939980.post-78670070711412394802009-01-03T23:24:00.003+11:002009-01-04T00:13:06.848+11:00Tagline<p>It has been quite a few busy weeks since my last post. I was heavily snowed down with work on my website. Then there was Christmas and new years celebrations.</p><p>Happy new year, everybody! On the optimistic note: <blockquote>Let the new year be better than it is going to be!</blockquote> :-)</p><p>What am I doing right now?</p><p>I am thinking about a tag line for my new website. The site will be selling special t-shirts for couples. These t-shirts will have funny designs split 50:50. So the big question is what should the tag line say?</p><p>Couple of my <i>(pretty bad)</i> ideas:<ul><li><a href="http://www.coupletshirts.com">Couple T-Shirts</a> ...because one is not complete</li><li><a href="http://www.coupletshirts.com">Couple T-Shirts</a> two is better than one</li><li><a href="http://www.coupletshirts.com">Couple T-Shirts</a> one for you, one for your +1</li></ul></p><p>I would like to hear your suggestions.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com4tag:blogger.com,1999:blog-23939980.post-43280489999622986272008-12-05T16:06:00.003+11:002008-12-05T16:27:09.107+11:00Colors for the webDo you need to find interesting photos that would enhance your website and would perfectly match its color scheme? I found a perfect tool for that job.</p><h3><a href="http://labs.ideeinc.com/multicolr/?1">Multicolr Search Lab</a> by Idée Inc.</h3><p>And these are the images that match colors of my blog:<br/><ol style="margin:0;padding:0;list-style-type:none;"><br /><li><a href="http://labs.ideeinc.com/multicolr/?1#colors=ea9225;">orange</a><br/><a href="http://www.flickr.com/photos/hanuska/3084166466/"><img src="http://farm4.static.flickr.com/3153/3084166466_1941678a41_m.jpg" alt="orange color" style="border:1px solid #000; padding:2px;margin:10px 0;"/></a></li><br /><li><a href="http://labs.ideeinc.com/multicolr/?1#colors=ea9225,1c3d78;">orange & blue</a><br/><a href="http://www.flickr.com/photos/hanuska/3084166474/"><img src="http://farm4.static.flickr.com/3243/3084166474_e17f3059b6_m.jpg" alt="orange and blue colors" style="border:1px solid #000; padding:2px;margin:10px 0;"/></a></li><br /><li><a href="http://labs.ideeinc.com/multicolr/?1#colors=1c3d78;">blue</a><br/><a href="http://www.flickr.com/photos/hanuska/3084166460/"><img src="http://farm4.static.flickr.com/3107/3084166460_044dacfec2_m.jpg" alt="blue color" style="border:1px solid #000; padding:2px;margin:10px 0;"/></a></li><br /></ol></p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-12258233173349543932008-12-05T15:17:00.005+11:002008-12-05T16:26:49.823+11:00Easy Groovy Iteration<h2>The problem</h2><p>Let's say we want to check the correct mimetype and file extension of the file being uploaded. In a typical Java way I would write something like this:</p><p><pre style="color:blue;">boolean isRightType = "image/jpeg".equals(contentType)<br /> || "image/png".equals(contentType)<br /> || "image/x-png".equals(contentType);<br /><br />boolean isRightFileExt = filename.endsWith(".png")<br /> || filename.endsWith(".jpg")<br /> || filename.endsWith(".jpeg");<br /></pre><p><h2>Groovy solution</h2><p>The Groovy way is much simpler and more elegant.</p><p><pre style="color:blue;">private static CONTENT_TYPES = ["image/jpeg", "image/png", "image/x-png"]<br />private static FILE_EXTENTIONS = [".png", ".jpg", ".jpeg"]<br />...<br />boolean isRightType = CONTENT_TYPES.any { it.equals(contentType) }<br />boolean isRightFileExt = FILE_EXTENTIONS.any { filename.endsWith(it) }<br /></pre><p><p>This was just a small example. What I really find useful are some of the following constructs that make my programming life really pleasant</p><h2>Groovy Iteration</h2><h3>each</h3><p>Simple collection iteration</p><p><pre style="color:blue;">def fibList = [1, 1, 2, 3, 5, 8, 13]<br />fibList.each { println it } // prints all of the numbers in the list<br /></pre></p><h3>any</h3><p>If you need to find out if any element of the collection meets the condition.</p><p><pre style="color:blue;">def fibList = [1, 1, 2, 3, 5, 8, 13]<br />assert fibList.any { it == 3 }<br />assert fibList.any { it - 2 > 10 }<br /></pre></p><p>This is pretty much equivalent to a Java construct</p><p><pre style="color:blue;">boolean any(List<E> list, Condition cond)<br /> for (E e : list) {<br /> if (cond.meets(e)) {<br /> return true;<br /> }<br /> }<br /> return false;<br />}<br /></pre></p><h3>every</h3><p>If you need to find out if any element of the collection meets the condition.</p><p><pre style="color:blue;">def fibList = [1, 1, 2, 3, 5, 8, 13]<br />assert fibList.every { it > 0 }<br /></pre></p><p>This is pretty much equivalent to a Java construct</p><p><pre style="color:blue;">boolean every(List<E> list, Condition cond)<br /> for (E e : list) {<br /> if (!cond.meets(e)) {<br /> return false;<br /> }<br /> }<br /> return true;<br />}<br /></pre></p><h3>collect</h3><p>If you need to create a new collection that contains each element of the original collection transformed in some way.</p><p><pre style="color:blue;">def fibList = [1, 1, 2, 3, 5, 8, 13]<br />assert fibList.collect { it - 1 } == [0, 0, 1, 2, 4, 7, 12]<br /></pre></p><p>This is pretty much equivalent to a Java construct</p><p><pre style="color:blue;">List<E> every(List<E> list, Command command)<br /> List<E> result = new ArrayList<E>(list.size());<br /> for (E e : list) {<br /> result.add(command(e));<br /> }<br /> return result;<br />}<br /></pre></p><h3>findAll</h3><p>If you need to create a new collection that contains all elements that meet the condition.</p><p><pre style="color:blue;">def fibList = [1, 1, 2, 3, 5, 8, 13]<br />assert fibList.findAll { it > 1 && it < 5 } == [2, 3]<br /></pre></p><p>This is pretty much equivalent to a Java construct</p><p><pre style="color:blue;">List<E> findAll(List<E> list, Condition cond)<br /> List<E> result = new ArrayList<E>(list.size());<br /> for (E e : list) {<br /> if (!cond.meets(e)) {<br /> result.add(e);<br /> }<br /> }<br /> return result;<br />}<br /></pre></p><h3>find</h3><p>If you need to find first element that matches the condition.</p><p><pre style="color:blue;">def fibList = [1, 1, 2, 3, 5, 8, 13]<br />assert fibList.find { it > 1 } == 2<br /></pre></p><p>This is pretty much equivalent to a Java construct</p><p><pre style="color:blue;">E findAll(List<E> list, Condition cond)<br /> for (E e : list) {<br /> if (!cond.meets(e)) {<br /> return e;<br /> }<br /> }<br /> return null;<br />}<br /></pre></p><h2>References</h2><p><ul><li><a href="http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/">Groovy Makes Iteration Easy</a> by Ted Naleid</li></ul></p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com3tag:blogger.com,1999:blog-23939980.post-10189126399410434412008-11-22T00:01:00.003+11:002008-11-22T00:08:55.824+11:00CSS Naming Conventions<p>This is a great article about <a href="http://woork.blogspot.com/2008/11/css-coding-semantic-approach-in-naming.html">CSS coding: semantic approach in naming convention</a>.</p><p>I am keeping this link for any time I will start a new project and will need to look back at some good advise for CSS naming conventions.</p><p>Surprisingly I was not far off with my currently undergoing project <a href="http://www.barsorrento.com/">bar sorrento</a>.</p><p>An image is worth a thousand words.</p><p><a href="http://woork.blogspot.com/2008/11/css-coding-semantic-approach-in-naming.html"><img src="http://lh4.ggpht.com/_TqPdHmAEwTM/SSBz-YOu2RI/AAAAAAAACnA/WKAiu0pvFO8/sem.png"/></a></p><p>Nevertheless, I recommend you read the full story.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-19840481547765715572008-11-21T00:15:00.003+11:002008-11-21T00:31:47.690+11:00Gmail Themes<h3>I'm loving new Gmail Themes!</h3><p>The <a href="http://blogoscoped.com/archive/2008-05-19-n72.html" title="Will Gmail get themes?">big question</a> has been finally answered.</p><p>Official <a href="http://gmailblog.blogspot.com/">Gmail Blog</a> <a href="http://gmailblog.blogspot.com/2008/11/spice-up-your-inbox-with-colors-and.html" title="spice up your inbox with colors">announced</a> addition of themes today. Users of Gmail can choose from around 30 themes. No need for styling Gmail with Firefox plugins like <a href="https://addons.mozilla.org/en-US/firefox/addon/2108">Stylish</a> and a <a href="http://www.hicksdesign.co.uk/journal/google-reader-theme">theme</a> from John Hicks <i>(although I liked it quite a lot for some time - until I had to change machine and re-install everything, again)</i>.</p><p><img src="http://2.bp.blogspot.com/_JE4qNpFW6Yk/SSSRNDDTP7I/AAAAAAAAAMU/LWtu9klI-Bo/s1600/skins_grid.png" /></p><p>My favorite: <b>Shiny</b>! Just like my laptop.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-71681358926079836742008-11-19T14:29:00.004+11:002008-11-19T15:51:05.003+11:00Track 404 with Google Analytics<p><a href="http://www.flickr.com/photos/raster/58795861/"><img src="http://farm1.static.flickr.com/31/58795861_8325908a6f_m.jpg" style="float: left; padding: 4px; border: 1px solid #000; margin-right: 10px; margin-bottom: 10px;" title="photo by raster"/></a>For many of us it is important as well as interesting to see where our customers go, which pages they visit. Tracking the pages is quite simple with <a href="http://www.google.com/analytics/">Google Analytics</a>. However the question is: "How do you track the pages that do not exist?"</p><p>If you configure your server or web application to <a href="http://hanuska.blogspot.com/2008/11/grails-and-404-page-not-found.html">handle 404 error</a> - page not found (I strongly recommend you <a href="http://www.barsorrento.com/404">do</a>) you will have a template page that is displayed every time the user navigates to an invalid URL - a page that does not exist.</p><p>So, how do we do this? How do we track our customers that somehow got lost and landed in a location that does not exists, at least not as a valid location that would provide them with the information that they expected.</p><p>It's quite easy. If you search for more information you may come across Google Analytics blog post <a href="http://analytics.blogspot.com/2006/09/tip-tracking-404-pages.html">Tracking 404 Pages</a>, which is now outdated as the new <b>ga</b> script is recommended instead of old <b>urchin</b>. The best source for the answer is Google documentation itself. Simply follow <a href="http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=86927">these instructions</a>.</p><p style="font-family: 'Trebuchet MS',Trebuchet,Verdana,Sans-Serif; font-style:normal; color:blue;"><script type="text/javascript"><br /> var pageTracker = _gat._getTracker("UA-xxxxx-x");<br /> pageTracker._trackPageview("/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer);<br /></script></p><blockquote>This code sends a virtual pageview of "/404.html?page=[pagename.html?queryparameter]&from=[referrer]" to your account, where [pagename.html?queryparameters] is the missing page name and referrer is the page URL from where the user reached the 404 page.</blockquote><p>Then simply look for /404.html in your Top Content report.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-18849208627237896232008-11-17T10:47:00.004+11:002008-11-17T11:09:35.557+11:00Grails and 404 Page Not Found<p>Every good website should have a nice 404 page. This is the page that is displayed when your customers or clients navigate to a destination that does not exist, by typing an invalid URL.</p><p>Grails does not give you a nice implementation of 404 error (or any other than 500 error). You need to implement it yourself.</p><p>If you search the Internet for examples of how to implement 404 Page Not Found error in Grails, most of the results talk about the following scenario:</p><pre style="color:blue">class UrlMappings {<br /> static mappings = {<br /> "500"(controller:"errors", action:"serverError")<br /> "404"(controller:"errors", action:"notFound")<br /> "403"(controller:"errors", action:"forbidden")<br /> }<br />}</pre><p>The previous piece of declaration resides inside <b>UrlMappings.groovy</b> and what it means is that if an error occurs, the request is redirected to <b>errors</b> controller which will execute in case of 404 the <b>notFound</b> action. This action could be as simple as</p><pre style="color:blue">def notFound = {<br /> render(view:"/notFound")<br />}</pre><p>This is all good, but if it is all you need to do (render a view - <b>notFound.gsp</b>) you may as well express it declaratively inside <b>UrlMappings.groovy</b></p><pre style="color:blue">class UrlMappings {<br /> static mappings = {<br /> "500"(view:'/error')<br /> "404"(view:'/notFound')<br /> "403"(view:'/forbidden')<br /> }<br />}</pre><p>This way you won't need a controller class at all. All you need are GSP files in the locations declared in the mappings.</p><p>References<ul><li><a href="http://grails.org/doc/1.0.x/guide/6.%20The%20Web%20Layer.html#6.4.4%20Mapping%20to%20Response%20Codes">Mapping Response Codes</a> Grails documentation</li><li><a href="http://jira.codehaus.org/browse/GRAILS-3219?focusedCommentId=141293#action_141293">404 UrlMapping does not work with Tomcat</a></li><li><a href="http://amorproximi.blogspot.com/2008/07/more-on-grails-declarative-error.html">More on Grails declarative error handling</a></li></ul></p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com1tag:blogger.com,1999:blog-23939980.post-4922823002343996802008-11-12T18:25:00.005+11:002008-11-12T21:50:14.328+11:00Grails Logging<p>Configuring logging in Grails is not as simple one would think. Grails uses Log4J as its logging framework. Log4J configuration is stored in the <b>log4j.properties</b> file. In Grails, this file is generated from <b>Config.groovy</b> source file.</p><p>The official <a href="http://grails.org/Logging">Grails Logging</a> documentation says that if you want to have a different logging levels for let's say a specific controller, all controllers and the rest of your application, you should define the logging levels as:<p><pre style="color:blue;">grails.'app.controller.YourOtherController'="off,stdout"<br />grails.'app.controller'="info,stdout"<br />grails.app="error,stdout"<br /></pre><p>Yes, those ticks are required, otherwise you get an error message <i>(No such property: context for class: java.lang.String)</i>. Don't ask me why. What is also important is the order. Children need to go first.</p><p>So that is what the official documentation and few blogs say.</p><p>Grails allows you to configure your production, development and testing environments differently if required. I configured Log4J the way that common properties are grouped and placed outside the environment dependent ones. But no matter how I tweaked it, I could not make it to work. For some reason the parent's or child's definition overrides the other, or causes an error.</p><p>But there is a solution to this problem after all. Instead of <b>dot notation</b>, use <b>curly braces</b>. Like in the following example:</p><pre style="color:blue;">environments {<br /> development {<br /> ...<br /> log4j {<br /> appender.stdout = ...<br /> rootLogger="error,logfile,stdout"<br /> logger {<br /> grails {<br /> app {<br /> controller="debug"<br /> }<br /> }<br /> }<br /> }<br /> }<br /> production {<br /> ...<br /> }<br />}<br /><br />// log4j configuration<br />log4j {<br /> appender.logfile=...<br /> appender.stacktraceLog=...<br /> rootLogger="debug,logfile"<br /> logger {<br /> grails="error"<br /> StackTrace="error,stacktraceLog"<br /> ...<br /> }<br /> additivity.StackTrace=false<br />}<br /></pre><p>This works. Tested with Grails 1.0.3.</p><p>Related articles:<ul><li><a href="http://grails.org/Logging">Grails logging</a> - official documentation,</li><li><a href="http://groups.google.com/group/groovymn/browse_thread/thread/ba085c36ca21591f?pli=1">Logging configuration</a> - Groovy Users of Minnesota,</li><li><a href="http://blog.sinequanon.net/2008/09/grails-logging/">Grails logging</a> - sine qua non</li></ul></p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com1tag:blogger.com,1999:blog-23939980.post-66477232213381306432008-11-11T09:45:00.007+11:002008-11-11T11:59:21.013+11:00What The Font ?!<p>I am creating a website for my wife's coffee shop and I needed to find out the font type they used on the signs and the menus. I was really wondering how I could identify the font.</p><p>It turned out to be quite simple. Thanks to <a href="http://www.myfonts.com/WhatTheFont/">WhatTheFont?!</a></p><p>The process was following:</p><ol><li>This morning I snapped a photo of the sign,<br /><a href="http://www.flickr.com/photos/hanuska/3020538324/"><img style="border: 1px solid rgb(0, 0, 0); padding: 4px; margin-top: 6px;" src="http://farm4.static.flickr.com/3141/3020538324_e5f29f39d9_m.jpg" /></a></li><li>Slightly modified it in <a href="http://www.gimp.org/">GIMP</a>,<br /><img style="border: 1px solid rgb(0, 0, 0); padding: 4px; margin-top: 6px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipXg6f4IESzWjw6MDOPJJz8ZvuaowXjA-Jdly8MaMp3JLJmNxg-cqqrZND6uSKSQnp8RjJp2cmz-AZGApyc72LN3-4PQFcucpHn8oXJ_2_DLXe5LnCsRJpwlvtfZDw13vh4lT8/s400/bs_fixed_small.gif" /></li><li>uploaded it to <a href="http://www.myfonts.com/WhatTheFont/">WhatTheFont?!</a>,</li><li>and voilà, the font is <a href="http://www.linotype.com/43410/isonormregular-font.html">Isonorm</a><br/><img style="border: 1px solid rgb(0, 0, 0); padding: 4px; margin-top: 6px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLGUc6hZGxsYD5BYWuf9G5cSL_vcG6_NtbNqALOVj1WHc0oREfepvYokMmQ37Bm5Y5tZH0pPpvtO6eJMoFYkw1KPW-EwWcckOvxw3W8B9AZDAX4v5UP9fnzXbp3vwzXY3JvtHG/s400/font_small.png"/><br /></li></ol><p></p><p>Yeah, I know. It is not quite quite the same, the letter "r" looks a bit different, but other than that, it's a perfect match. I am quite happy with it. Much better than going through thousands of fonts manually.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com0tag:blogger.com,1999:blog-23939980.post-5005712279149534472008-11-11T09:26:00.006+11:002008-11-11T15:43:13.308+11:00Testing on IE6, IE7 and IE8<p>Have you ever needed to test your web app in multiple versions if Internet Explorer? It is not quite common to have IE6 and IE7 (or IE8) installed on the same computer side by side.</p><p><a href="http://www.tech-recipes.com/rx/1188/ie7_use_ie6_ie7_together/">It</a> <a href="http://blogs.msdn.com/ie/archive/2006/11/30/ie6-and-ie7-running-on-a-single-machine.aspx">is</a> <a href="http://tredosoft.com/IE7_standalone">possible</a>. But if you have already upgraded to IE7, there is no going back. Or is there?</p><p>Well, you can still test on both browsers. Microsoft quite conveniently produced a free Virtual PC image for IE6 compatibility testing. Go to <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF&displaylang=en">Internet Explorer Application Compatibility VPC Image</a> page, where you can download images for IE 6, 7 and 8 Beta 2.</p><p><ul><li><b>Internet Explorer 6</b> on Windows XP SP3</li><li><b>Internet Explorer 7</b> on Windows XP SP2</li><li><b>Internet Explorer 8 Beta 2</b> on Windows XP SP3</li><li><b>Internet Explorer 7</b> on Windows Vista</li></ul></p><p>All you need to run these images is <a href="http://www.microsoft.com/windows/products/winfamily/virtualpc/default.mspx">Microsoft Virtual PC</a>. It's all free.</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com3tag:blogger.com,1999:blog-23939980.post-48757519856134842932008-11-09T21:11:00.000+11:002008-11-09T21:13:38.201+11:00hCard microformat validator<p>I was creating a contact page for a website and I wanted to use <a href="http://microformats.org/wiki/hcard">hCard</a> <a href="http://microformats.org/">microformat</a> to encode the address, telephone, fax and the geo location. After I created it, I looked for a way to quickly validate it and I found</p><h3 style="background: transparent url(http://hcard.geekhood.net/i/logo.png) no-repeat scroll 0 0; padding-left: 45px; line-height: 1.5;"><a href="http://hcard.geekhood.net/" style="color: black; font-family: 'Solex Medium','Myriad Web','Myriad Pro','Calibri','Arial',sans-serif; font-size: 1.6em;">hCard micro<span style="color:#666;">format</span> Validator <small style="vertical-align: top;">1.0</small></a></h3><p>What a great service! I must tell you, this service is super easy to use. Just type in a URL of the page that contains hCard data and get the results instantly. I read the spec but... I still made few mistakes that were promptly brought to my attention.</p><p>I made a typo and instead of <strong>adr</strong> I used <strong>addr</strong>, which rendered couple of nested elements invalid. Ok, that was a quick fix.</p><p>The telephone number is shop's <span style="font-style: italic;">(this website is for a retail store)</span> and I marked the telephone number as shop, which is invalid. The valid values are: <span style="font-family: courier new;">home, work, pref, fax, cell, voice, video, pager, car, msg, modem, bbs, isdn, pcs</span>. Another easy fix! The same went for the fax number.</p><p>Lastly, the email address that I entered was of a domain that did not register itself yet. The message I got was:</p><blockquote>Lookup of e-mail's domain “notyetregistered.com.au” failedVerify that e-mail address is correct.</blockquote><p>Wow, I did not expect such a thorough check!</p><p>Another good point for this validator is that it not only tells you what is wrong, but it also links to a FAQ page where the problem is explained.</p><p>Well done and thank you! Now this contact page validates 100%!</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com1tag:blogger.com,1999:blog-23939980.post-9775312131398639192008-11-07T15:32:00.004+11:002008-11-07T15:43:24.320+11:00Fatal Error in the logs by Grails<p>I recently started working on a project using Grails and the following message in the logs appeared consistently and annoyed me quite a lot.<p><pre>[Fatal Error] :-1:-1: Premature end of file.</pre><p>So I started digging through the code and searching the web for an answer. And I found it. It is a bug that has been reported to Grails and you can find it at <a href="http://jira.codehaus.org/browse/GRAILS-3088">GRAILS-3088</a>. It apparently affects Grails 1.0.3 (which I am using) and it should be fixed in next release, 1.0.4.</p><p>The bug is triggered with each request from Firefox 3 and Opera 9.5 and even Firefox 2 if you render the response as "text/xml" using</p><pre>withFormat { xml { render(contentType:"text/xml"){ ... } } }</pre><p>The current <a href="http://jira.codehaus.org/browse/GRAILS-3088?focusedCommentId=138950#action_138950">workaround suggested</a> by Graeme Rocher is to edit <strong>Config.groovy</strong> file and remove (or comment out) "text/xml" from the Grails MIME types mapping<p><pre>grails.mime.types = [ html: ['text/html','application/xhtml+xml'],<br />// xml: ['text/xml', 'application/xml'],<br /> text: 'text-plain',<br /></pre><p>This works for me. No more annoying messages in the logs. I am not quite sure how or if it affects XML responses. But I do not need those for now, so I will worry about that later, if I need to</p><div class="blogger-post-footer"><script type="text/javascript"><!--
google_ad_client="ca-pub-3388433133102440";
google_ad_width=160;
google_ad_height=600;
google_ad_format="160x600_as";
google_ad_type="text";
google_color_border="F6F6F6";
google_color_bg="F6F6F6";
google_color_link="B8A80D";
google_color_url="B8A80D";
google_color_text="9E5205";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>Anonymoushttp://www.blogger.com/profile/11568089987006666223noreply@blogger.com1