<?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>Jorge Albaladejo</title>
	<atom:link href="http://jorgealbaladejo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jorgealbaladejo.com</link>
	<description>Hard &#38; Soft design...</description>
	<lastBuildDate>Mon, 06 Feb 2012 22:00:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Publish to Facebook page or application&#8217;s wall with PHP</title>
		<link>http://jorgealbaladejo.com/2011/06/13/publish-to-facebook-page-or-applications-wall-with-php/</link>
		<comments>http://jorgealbaladejo.com/2011/06/13/publish-to-facebook-page-or-applications-wall-with-php/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 14:57:48 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Social Networks]]></category>
		<category><![CDATA[Web Security]]></category>
		<category><![CDATA[application wall]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[page wall]]></category>
		<category><![CDATA[PHP API]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=875</guid>
		<description><![CDATA[Just after implementing the Twitter Oauth API to publish tweets from a PHP application, I thought that doing the same with Facebook would be a piece of cake. Well, not quite, although I&#8217;ve finally managed to have the messages published to a page wall, or even to an application&#8217;s page wall from an automated script. [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify">Just after implementing the <a href="http://dev.twitter.com/doc" target="_blank" rel="external">Twitter Oauth API</a> to publish tweets from a PHP application, I thought that doing the same with Facebook would be a piece of cake. Well, not quite, although I&#8217;ve finally managed to have the messages published to a page wall, or even to an application&#8217;s page wall from an automated script. In this article I explain some of the problems I encountered and how to solved them. I hope this example may be of help if you are having trouble with this.</p>
<p><span id="more-875"></span></p>
<h3>Publishing to a page&#8217;s wall</h3>
<p style="text-align:justify">According to the <a href="http://developers.facebook.com/docs/authentication/#app-login" target=" _blank" rel="external">Facebook documentation</a>, we need to register an application in order to use it to publish messages to a page&#8217;s wall. The process is explained on that page, so this should be a good moment to read it.</p>
<p style="text-align:justify">The process could be summarized as follows:</p>
<ol>
<li>Create an application.</li>
<li>Get the token for that application to manage the user&#8217;s pages (where the user is administrator of those pages).</li>
<li>Get the specific token for that application through the user to a precise page.</li>
</ol>
<p style="text-align:justify">While it should have been worked as it is explained on the documentation, I was having the following error:</p>
<p style="text-align:justify;font-style:italic;">(#200) The user hasn&#8217;t authorized the application to perform this action</p>
<p style="text-align:justify">So&#8230; why? According to the documentation, <em>manage_pages</em> is the only permission required for an application to access a page, and everything seemed in order. Actually, it wasn&#8217;t. After some tests going back and forth and some googleing, I realized I didn&#8217;t have enough scope, and adding <em>publish_stream</em> and <em>read_stream</em> seemed to be a requirement for the application to actually write to page&#8217;s wall. In addition, <em>offline_access</em> would produce a token that does not expire.</p>
<p style="text-align:justify">Once this issue fixed, the following steps should lead to a successful publication in a page&#8217;s wall from an external script:</p>
<ol>
<li>Register your application <a href="http://developers.facebook.com/setup/" target="_blank" rel="external">here</a>.</li>
<li>Obtain access to manage pages from the authorized page administrator<br />
	<em>https://www.facebook.com/dialog/oauth?client_id=$id&#038;client_secret=$secret&#038;redirect_uri=$uri&#038;scope=publish_stream,offline_access,read_stream,manage_pages&#038;response_type=token</em></li>
<li>Get an access token to the precise page of that administrator<br />
	<em>https://graph.facebook.com/me/accounts?access_token=$all_apps_token</em></li>
<li>Now you should be able to publish to that page with this token through a POST call to<br />
	<em>https://graph.facebook.com/$page_id/feed</em></li>
</ol>
<p style="text-align:justify">Here you are an example in PHP that uses this token to publish messages:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" rel="external"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p875code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8752"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code" id="p875code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Facebook
<span style="color: #009900;">&#123;</span>	    
    <span style="color: #009933; font-style: italic;">/**
     * @var The page id to edit
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$page_id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'XXX'</span><span style="color: #339933;">;</span>	
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var the page access token given to the application above
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$page_access_token</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'YYY'</span><span style="color: #339933;">;</span>	
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var The back-end service for page's wall
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$post_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Constructor, sets the url's
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Facebook<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'https://graph.facebook.com/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">page_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/feed'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Manages the POST message to post an update on a page wall
     * 
     * @param array $data
     * @return string the back-end response
     * @private
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> message<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>   
        <span style="color: #666666; font-style: italic;">// need token</span>
        <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'access_token'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">page_access_token</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// init</span>
        <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_init" rel="external"><span style="color: #990000;">curl_init</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <a href="http://www.php.net/curl_setopt" rel="external"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <a href="http://www.php.net/curl_setopt" rel="external"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <a href="http://www.php.net/curl_setopt" rel="external"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <a href="http://www.php.net/curl_setopt" rel="external"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// execute and close</span>
        <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_exec" rel="external"><span style="color: #990000;">curl_exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <a href="http://www.php.net/curl_close" rel="external"><span style="color: #990000;">curl_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// end</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$return</span><span style="color: #339933;">;</span>        
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">message</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array" rel="external"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'message'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'The status header'</span><span style="color: #339933;">,</span> 
                          <span style="color: #0000ff;">'link'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://theurltopoint.to'</span><span style="color: #339933;">,</span> 
                          <span style="color: #0000ff;">'picture'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://thepicturetoinclude.jpg'</span><span style="color: #339933;">,</span>
                          <span style="color: #0000ff;">'name'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Name of the picture, shown just above it'</span><span style="color: #339933;">,</span> 
                          <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Full description explaining whether the header or the picture'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3 style="margin-top:20px">Publishing to an app&#8217;s wall</h3>
<p style="text-align:justify">In some cases, we might want to publish to the application&#8217;s wall itself, so that there is no need to have a second application to publish to the first one&#8217;s wall.</p>
<p style="text-align:justify">According to <a href="http://stackoverflow.com/questions/691425/how-do-you-post-to-the-wall-on-a-facebook-page-not-profile" target="_blank" rel="external">some of the discussions</a> on the matter that can be found on the internet, this should work by simply using $page_id as the target and the same $page_id to request the manage_pages permission.</p>
<p style="text-align:justify">In this case, we would follow the same process explained above, but slightly simplified:</p>
<ol>
<li>Register your application <a href="http://developers.facebook.com/setup/" target="_blank" rel="external">here</a>.</li>
<li>Obtain an access code for your application<br />
	<em>https://graph.facebook.com/oauth/access_token?type=client_cred&#038;client_id=$id&#038;client_secret=$secret</em></li>
<li>Now you should be able to publish to the application&#8217;s wall with the token obtained through a POST call to<br />
	<em>https://graph.facebook.com/$app_id/feed</em></li>
</ol>
<p style="text-align:justify">However, Following the steps above, I obtained an error again:</p>
<p style="text-align:justify;font-style:italic;">
{&#8220;error&#8221;:{&#8220;type&#8221;:&#8221;OAuthException&#8221;,&#8221;message&#8221;:&#8221;(#200) Posts where the actor is a page cannot also include a target_id&#8221;}}</p>
<p style="text-align:justify">Which was way confusing since there shouldn&#8217;t be any limitation according to Facebook&#8217;s documentation. After some searching and reading literature about (<a href="http://www.sergiy.ca/post-on-facebook-app-wall-and-fan-page-wall-as-admin/" target="_blank" rel="external">here</a> and <a href="http://developers.facebook.com/docs/reference/javascript/" target="_blank" rel="external">here</a>), I discovered that publishing from an application to its own wall is doable, and in fact it works very well with the <a href="http://developers.facebook.com/docs/reference/javascript/" target="_blank" rel="external">JS API</a> provided by Facebook.</p>
<p style="text-align:justify">Then why the JS API would achieve the goal while its web service sister just throws a mystic error? It was quite obvious that they had to be using somewhat different service url&#8217;s&#8230; after inspecting the HTTP calls made by the JS API and was surprised to found that it is actually a <strong>GET</strong> (instead of <em>POST</em> call):</p>
<p style="text-align:justify;font-style:italic;">https://graph.facebook.com/$app_id/feed?access_token=$token&#038;callback=FB.ApiServer._callbacks.$some_callback_id&#038;message=Hello%2C%20World!&#038;method=post&#038;pretty=0&#038;sdk=joey</p>
<p style="text-align:justify">I just had to test this new url with the parameters of my application, and this time it just worked as expected:</p>
<p style="text-align:justify;font-style:italic;">https://graph.facebook.com/$app_id/feed?access_token=$api_access_token&#038;message=Hello%2C%20World!<strong>&#038;method=post</strong></p>
<p style="text-align:justify">This is the only solution I have found so far to be able to publish messages from PHP on behalf of an application itself. It is a bit awful, but I haven&#8217;t found any other way to make this work, and the documentation provided by Facebook seems like knocking on a wall.</p>
<p style="text-align:justify">Has anybody found any better solution for this problem? Comments are welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/06/13/publish-to-facebook-page-or-applications-wall-with-php/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Internet Explorer limits nested @import CSS statements</title>
		<link>http://jorgealbaladejo.com/2011/05/28/internet-explorer-limits-nested-import-css-statements/</link>
		<comments>http://jorgealbaladejo.com/2011/05/28/internet-explorer-limits-nested-import-css-statements/#comments</comments>
		<pubDate>Sat, 28 May 2011 07:15:23 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[Client-side]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[nested @import]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=860</guid>
		<description><![CDATA[I have been lately working on a collection of home-made widgets based on Dojo. This architecture has been designed to reuse elements and so there are widgets inside widgets, the code is arranged and structured, CSS is imported in a waterfall model, and everything should be fine and working properly. Until Internet Explorer. Let&#8217;s not [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify">I have been lately working on a collection of home-made widgets based on Dojo. This architecture has been designed to reuse elements and so there are widgets inside widgets, the code is arranged and structured, <strong>CSS is imported in a waterfall model</strong>, and everything should be fine and working properly.</p>
<p style="text-align:justify"><strong>Until Internet Explorer.</strong></p>
<p style="text-align:justify">Let&#8217;s not talk about its mystic JavaScript errors, DOM random model interpretations and box model hacks. I had heard about the <strong>32 @import CSS statements limit</strong> before (<a href="http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/ad1b6e88-bbfa-4cc4-9e95-3889b82a7c1d/" target="_blank" rel="external">here</a>, <a href="http://blogs.telerik.com/blogs/posts/10-05-03/internet_explorer_css_limits.aspx" target="_blank" rel="external">here</a> and <a href="http://john.albin.net/ie-css-limits/single-style-test.html" target="_blank" rel="external">here</a>), but what we were experiencing was different: <strong>beyond a given number of nested CSS imports</strong>, it seemed like stylesheets stopped being loaded. This was a big WTF the first time we spotted the problem, and blindly fixed it by adding twice the deeper @import sentences into the higher level CSS files. After all, it worked then.</p>
<p style="text-align:justify">But after a bad night of guilty conscience that issue came back to me, and I decided to do some tests on the issue so that some light be thrown on this dark matter. This was the plan: a simple HTML file with a number of divs (with a border and height definitions to make them visible by default), and a set of CSS files that where imported in waterfall mode, each one of them assigning the background color of one div according to its nesting level. The rupture point would be spotted where <strong>div&#8217;s started to look blank</strong>. Something like this:</p>
<p><span id="more-860"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" rel="external"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p860code6'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8606"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code" id="p860code6"><pre class="html" style="font-family:monospace;">&lt;html&gt;
	&lt;head&gt;
		&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;style01.css&quot; /&gt;
	&lt;/head&gt;
	&lt;style type=&quot;text/css&quot;&gt;
		body div{
			height: 30px;
			margin: 5px;
			border: 1px solid #000;
		}
	&lt;/style&gt;
	&lt;body&gt;
		&lt;div class=&quot;style01&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;style02&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;style03&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;style04&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;style05&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;style06&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;style07&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;style08&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;style09&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;style10&quot;&gt;&lt;/div&gt;
	&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p style="text-align:justify">The CSS files would look all like this one (style01.css):</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" rel="external"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p860code7'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8607"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p860code7"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@import url(&quot;style02.css&quot;);</span>
&nbsp;
.style01<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#111</span><span style="color: #00AA00;">;</span>	
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p style="text-align:justify">And so on (style02.css, etc):</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" rel="external"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p860code8'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8608"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p860code8"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@import url(&quot;style03.css&quot;);</span>
&nbsp;
.style02<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#222</span><span style="color: #00AA00;">;</span>	
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p style="text-align:justify">And up to 10 nested levels, in my test. What the result was? Every major modern browser (Firefox, Chrome, Opera, Safari) produced the expected result:</p>
<p><img src="http://jorgealbaladejo.com/wp-content/uploads/2011/05/css_test_all_browsers-600x177.png" alt="Results of the CSS test for all major modern browsers" title="Results of the CSS test for all major modern browsers" width="600" height="177" class="aligncenter size-medium wp-image-861" /></p>
<p style="text-align:justify">On the contrary, under <strong>Internet Explorer 8 and, moreover, 9</strong>, the result matched the little &#8216;panic moment&#8217; we had when dealing with our nested collection of widgets:</p>
<p><img src="http://jorgealbaladejo.com/wp-content/uploads/2011/05/css_test_ie-600x173.png" alt="" title="Results of the CSS test for Internet Explorer" width="600" height="173" class="aligncenter size-medium wp-image-862" /></p>
<p style="text-align:justify">Which actually confirmed that <strong>Internet Explorer limits nested @import CSS statements to three</strong> from the first linked external stylesheet. In the example, up to style04.css. In a production environment this is not a big deal since all CSS files are going to be packed into a single minified and compressed bundle, but it really can piss your day off in development environments should you not be aware of this behavior.</p>
<p style="text-align:justify">Once again, a reason to make me think of IE as a bad joke of a real browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/05/28/internet-explorer-limits-nested-import-css-statements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Engineering principles for web applications</title>
		<link>http://jorgealbaladejo.com/2011/05/22/engineering-principles-for-web-applications/</link>
		<comments>http://jorgealbaladejo.com/2011/05/22/engineering-principles-for-web-applications/#comments</comments>
		<pubDate>Sun, 22 May 2011 11:20:51 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[Project Management]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[black boxes]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[engineering principles]]></category>
		<category><![CDATA[modularity]]></category>
		<category><![CDATA[quality assurance]]></category>
		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=846</guid>
		<description><![CDATA[Since I work as a web developer, I have noticed that basic engineering principles are not always being consistently applied to web applications design, architecture and development. I am talking about modularity, black-box design, documentation and quality assurance, among others. Modularity It may seem trivial for small-medium web sites and the 80% of the web [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify">Since I work as a web developer, I have noticed that basic engineering principles are not always being consistently applied to web applications design, architecture and development. I am talking about <strong>modularity</strong>, <strong>black-box design</strong>, <strong>documentation </strong>and <strong>quality assurance</strong>, among others.</p>
<p><span id="more-846"></span></p>
<h3>Modularity</h3>
<p style="text-align:justify">It may seem trivial for small-medium web sites and the 80% of the web interfaces on the net. However, this matter becomes crucial for medium-big applications with complex interfaces and functionality. A good application architecture consists also on a good modularity design:</p>
<ul>
<li>All functions related should become a module.</li>
<li>Modules must have a low coupling (high isolation), so that if a bug occurs, it affects only one module and some neighbors at most.</li>
<li>The interfaces between the modules should be as small as possible.</li>
<li>The interchange of messages through these interfaces must be also minimized.</li>
</ul>
<p style="text-align:justify">A good modular design produces an architecture than is extendable, maintainable, adaptable and reusable, thus allowing to reach further goals. A lock of modular design just produces a bunch of unsustainable &#8220;spaghetti code&#8221;, eventually.</p>
<h3>Black boxes</h3>
<p style="text-align:justify">Another concept on the line of thought of modular design is black boxes. Engineering likes black boxes, they are useful, modular, isolated, independent, and provide a smart set of independent pieces that abstract their internal logic from outside.</p>
<p style="text-align:justify">Basically, a black box is an element whose implementation is unknown to us, but which is well-documented and produces an expected output, given a known input. This implies also abstraction and encapsulation: no inner property should be accessed or changed from outside the box, nothing from other parts of the application should affect the internal structure or functionality, and an I/O interface should be created so that this black box is only used as it was designed to. It is not about &#8220;protecting&#8221; the classes from malicious uses. It is to avoid ourselves incorrectly using these classes when their implementation is no longer in mind after several months of their creation. It is easy to forget a tree on a big, big, forest.</p>
<p style="text-align:justify">The beauty of this approach is that test plans are easier to design, code is written faster and programmers can rely on every piece of the application doing exactly what it is meant to. Black boxes become the cornerstone on which big applications&#8217; architecture must lean.</p>
<h3>Documentation</h3>
<p style="text-align:justify">I&#8217;ve heard a lot of excuses from all kind of developers not to write a proper documentation. I, too, have used it sometimes, in darker times when I was learning how things should be done. That&#8217;s why I spot them easily:</p>
<ul>
<li>Release dates are tight and I barely can finish functionality.</li>
<li>The code is self-explanatory.</li>
<li>I will write it when I&#8217;m finished with this.</li>
<li>I just don&#8217;t have the time to write documentation.</li>
<li>&#8230;</li>
</ul>
<p style="text-align:justify">Unfortunately, I have to say there is <strong>no excuse</strong> not to write documentation; moreover, it should be done first, before start writing a line of code: comment out what the function you are coding is to do, add a few lines explaining the process to get it, and don&#8217;t hesitate to add as many side information as you want. I know that pride about &#8216;not writing silly comments every good programmer should not need to understand the code&#8217;, and it is wrong.</p>
<p style="text-align:justify">Programmers are not magicians, they don&#8217;t read minds! Everyone has different coding styles, skills and languages, and it is not obvious for one to understand what a piece of code should do, just reading the code. It may be clear what it <strong>does</strong> but that might be wrong and the source of a bug being tracked for hours.</p>
<p style="text-align:justify">Not only have I seen many people spend many ours of their valuable time tracking &#8216;esoteric&#8217; bugs through unreadable, unbearable, non-documented code, I&#8217;ve lost myself months of my short life figuring out the architecture and purpose of entire applications just because the last programmer &#8220;didn&#8217;t have the time to write documentation&#8221;.</p>
<p style="text-align:justify">Can you imagine the loss for the company? Huge, indeed. Finally documentation has its toll paid back, one way or another. I&#8217;d rather like not to waste my time, don&#8217;t you?</p>
<h3>Quality assurance</h3>
<p style="text-align:justify">Another almost forgotten issue regarding web development is quality assurance. Deadlines are tight, developers are stressed, the application looks nice, so&#8230; who cares if a variable is missing or a method of a class goes nuts? It is unlikely to happen, we all have tested functionality and everything works.</p>
<p style="text-align:justify">Well, that&#8217;s again a wrong argument. Experience says that the cost of solving a bug is more than ten times the amount of resources needed to prevent it from the beginning. Think of it:</p>
<ol>
<li>A customer has the application exploding when she tries to use a functionality we hadn&#8217;t previously tested.</li>
<li>She calls customer support, this produces several messages going back and forth from one part to another until the bug description reaches the development team.</li>
<li>A developer, usually not the one that wrote the code, has to spend hours deciphering it (remember about documentation?), reproducing the bug, understanding the underlying problem and fixing it. If this code is more than a few months old, the effort to reload it on a mental representation is several times bigger than if the bug was fixed on the initial development cycle.</li>
<li>A new version / patch has to be released and delivered to one or all clients, producing service temporary interruptions.</li>
<li>Excuses, apologies, unhappy costumers, official communications explaining how to fix the bug&#8230;</li>
</ol>
<p style="text-align:justify">Why wouldn&#8217;t we prefer to test thoroughly the application and fix all critical failures before moving to production? Are architects, or Aeronautics engineers forced to deliver their work without ensuring quality? Then why are we, software companies?</p>
<h3>Conclusions</h3>
<p style="text-align:justify">This traditional point of view of Engineering processes (it has actually been long time used for Electronics design) might seem outdated when applied to web applications, and more precisely web &#8220;2.0&#8243; systems. Nowadays, projects need to develop fast, deploy quickly and have a soon ROI. Is it a misunderstanding to still apply these four principles?</p>
<p style="text-align:justify">It is not, in my opinion. While it might seem meaningless for that 80% of medium-small web sites based on a few interfaces and some custom CMS&#8217;s, it is absolutely necessary for bigger home-brew apps. Otherwise, spaghetti-code, lack of documentation, coupled modules and many other big mistakes shall occur and the time is to come were our beloved application will need to be rewritten from scratch, or fall into oblivion.</p>
<p style="text-align:justify">I am afraid I have seen it before, and not just once.</p>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/05/22/engineering-principles-for-web-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Java profiler</title>
		<link>http://jorgealbaladejo.com/2011/05/15/simple-java-profiler/</link>
		<comments>http://jorgealbaladejo.com/2011/05/15/simple-java-profiler/#comments</comments>
		<pubDate>Sun, 15 May 2011 08:29:00 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[profiler]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=833</guid>
		<description><![CDATA[This is a small collection of Java classes to provide a simple profiling functionality: include it into your application to register the time consumption of your function calls. It may come in handy where a particularly slow module has been spotted and there is no need for a more complex profiling system Besides of a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify">This is a small collection of Java classes to provide a simple profiling functionality: include it into your application to register the time consumption of your function calls. It may come in handy where a particularly slow module has been spotted and there is no need for a more complex profiling system</p>
<p style="text-align:justify">Besides of a time line of the application execution, it creates an histogram to present where your application spends more resources and what the most called functions are.</p>
<p><span id="more-833"></span></p>
<p style="text-align:justify">Take a look to the launcher example for usage:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" rel="external"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p833code10'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p83310"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
</pre></td><td class="code" id="p833code10"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">Profiler.Profiler</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> launcher <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * @param args
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky" rel="external"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		Profiler pf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Profiler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pf.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pf.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">219</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;one&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">123</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;two&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">245</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;one&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;two&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;one&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;one&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;one&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;one&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;two&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;two&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">checkPoint</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;two&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		pf.<span style="color: #006633;">endCheckPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pf.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">194</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		pf.<span style="color: #006633;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky" rel="external"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>pf.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p style="text-align:justify;margin-top:20px">The code above will produce:</p>
<pre style="border:1px solid #ccc; padding:10px;">
The whole process took          821.556 milliseconds

1171994752050889 >> one took    122.580 milliseconds
1171994874654460 >> two took    245.045 milliseconds
1171995119708510 >> one took     13.648 milliseconds
1171995133362201 >> two took     25.382 milliseconds
1171995158749506 >> one took      0.005 milliseconds
1171995158757886 >> one took      0.003 milliseconds
1171995158764312 >> one took      0.004 milliseconds
1171995158771017 >> one took      0.003 milliseconds
1171995158777442 >> two took      0.003 milliseconds
1171995158783867 >> two took      0.003 milliseconds
1171995158790013 >> two took      0.064 milliseconds

Profiler information
CheckPoint     Frequency         Time      % Time
one                    6      136.244      16.58%
two                    5      270.498      32.93%
</pre>
<p style="text-align:justify;margin-top:20px">Download the code <a href="/portfolio/java/profiler.zip">here</a>. Please feel free to use it, adapt it and don&#8217;t forget to send me back your changes!</p>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/05/15/simple-java-profiler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Making Lotus Domino WebDAV actually work</title>
		<link>http://jorgealbaladejo.com/2011/04/16/making-lotus-domino-webdav-actually-work/</link>
		<comments>http://jorgealbaladejo.com/2011/04/16/making-lotus-domino-webdav-actually-work/#comments</comments>
		<pubDate>Sat, 16 Apr 2011 18:16:56 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[Lotus Domino]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Server-side]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[lotus domino]]></category>
		<category><![CDATA[webdav]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=826</guid>
		<description><![CDATA[Configuring Lotus Domino WebDAV for third-party tools development has had us struggling a few days until we succeeded on make it actually work. There is a good article here that explains the basis of allowing WebDAV into your server. However, that&#8217;s not all of it. The method above will never work unless you set the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify">Configuring Lotus Domino WebDAV for third-party tools development has had us struggling a few days until we succeeded on make it actually work. There is <a href="http://www.codestore.net/store.nsf/unid/FISR-6U8SN7" target="_blank" rel="external">a good article here</a> that explains the basis of allowing WebDAV into your server.</p>
<p style="text-align:justify">However, that&#8217;s not all of it. The method above will never work unless you set the right permissions for the user &#8216;anonymous&#8217; to the database you want to access. That&#8217;s it: individual database access must be configured, as it is explained <a href="http://www-12.lotus.com/ldd/doc/domino_notes/Rnext/help6_admin.nsf/f4b82fbb75e942%20a6852566ac0037f284/9ba6f9d0158ccf7c85256c1d00397996?OpenDocument" target="_blank" rel="external">here</a>. The <a href="http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=/com.ibm.designer.domino.main.doc/H_EDITING_AND_MANAGING_DATABASE_RESOURCES_USING_THIRD_PARTY_TOOLS_EX.html" target="_blank" rel="external">official reference</a> can be also of help, although a bit outdated.</p>
<p style="text-align:justify">Even then, we had a lot of trouble working with the WebDAV enabled browsing. Under Windows 7 with Explorer, it seemed not allow any kind of file copying &#8211; but it allowed to create folders and files by right clicking directly on the directory, though. Also, we were having problems on MAC OS Finder in form of random write errors. All this stuff was pretty confusing and unclear on every forum and blog that we visited for help.</p>
<p><span id="more-826"></span></p>
<p style="text-align:justify">So, eventually, we found out a solution: do not use Explorer nor Finder at all! There are good WebDAV tools that work much like an FTP client (like <a href="http://cyberduck.ch" target="_blank" rel="external">Cyberduck</a> or <a href="http://www.bitkinex.com/webdavclient" target="_blank" rel="external">BitKinex&#8217;s WebDAV client</a> that work very well and do not present the problems we had with the OS built-in clients.</p>
<p style="text-align:justify">In addition, both clients support authentication, which allows to connect using our own credentials instead of having to <a href="http://www-12.lotus.com/ldd/doc/domino_notes/Rnext/help6_admin.nsf/f4b82fbb75e942%20a6852566ac0037f284/9ba6f9d0158ccf7c85256c1d00397996?OpenDocument" target="_blank" rel="external">open the database access</a> to all anonymous connections (a clearly potential security breach). We just had to configure the database to support &#8216;design locking&#8217; since it is used by some WebDAV clients on write operations.</p>
<p style="text-align:justify">To sum up, the key points to make Lotus Domino WebDAV work are:</p>
<ul>
<li>Configure the server to <a href="http://www.codestore.net/store.nsf/unid/FISR-6U8SN7" target="_blank" rel="external">allow WebDAV connections</a>. This is done once for all databases.</li>
<li>Configure the database for design blocking (required for some clients) &#8211; no need to change access permissions!!</li>
<li>Use any other WebDAV client than the OS&#8217;s built-in ones.</li>
</ul>
<p style="text-align:justify"><strong>Update:</strong> It seems like Domino requires specific permission rules for the databases being accessed via WebDAV. A user &#8216;Anonymous&#8217; is required with explicitely no access at all: otherwise, when trying to connect with your own user, being a web interface (whose default user is, by the way, &#8216;Anonymous&#8217;), Domino seems to stop processing access rules at this profile, therefore not allowing any further connection.</p>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/04/16/making-lotus-domino-webdav-actually-work/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Workaround to dynamically load CSS resources</title>
		<link>http://jorgealbaladejo.com/2011/04/10/workaround-to-dynamically-load-css-resources/</link>
		<comments>http://jorgealbaladejo.com/2011/04/10/workaround-to-dynamically-load-css-resources/#comments</comments>
		<pubDate>Sun, 10 Apr 2011 13:41:21 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[Client-side]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[asynchronous CSS]]></category>
		<category><![CDATA[dojo.requireCSS]]></category>
		<category><![CDATA[dynamic CSS]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=815</guid>
		<description><![CDATA[I have been struggling for a while to find a way to dynamically load CSS resources in a coherent and reliable manner. As I am working with dojo on my current project, I started with using its event connectors for a classical approach: creating a DOM link element with the desired CSS resource and adding [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify">I have been struggling for a while to find a way to dynamically load CSS resources in a coherent and reliable manner. As I am working with <a href="http://dojotoolkit.org/" target="_blank" rel="external">dojo</a> on my current project, I started with using its event connectors for a classical approach: creating a DOM link element with the desired CSS resource and adding it to the document&#8217;s header programmatically.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" rel="external"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p815code13'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p81513"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p815code13"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getCSS<span style="color: #009900;">&#40;</span>filename<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> fileref <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  fileref.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  fileref.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span> filename<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> handleLoad <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">connect</span><span style="color: #009900;">&#40;</span>fileref<span style="color: #339933;">,</span> <span style="color: #3366CC;">'onload'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>		
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'the element '</span> <span style="color: #339933;">+</span> evt.<span style="color: #660066;">target</span>.<span style="color: #660066;">src</span>  <span style="color: #339933;">+</span> <span style="color: #3366CC;">' loaded'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
    dojo.<span style="color: #660066;">disconnect</span><span style="color: #009900;">&#40;</span>handleLoad<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> handleError <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">connect</span><span style="color: #009900;">&#40;</span>fileref<span style="color: #339933;">,</span> <span style="color: #3366CC;">'onload'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>		
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'the element '</span> <span style="color: #339933;">+</span> evt.<span style="color: #660066;">target</span>.<span style="color: #660066;">src</span>  <span style="color: #339933;">+</span> <span style="color: #3366CC;">' failed loading'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
    dojo.<span style="color: #660066;">disconnect</span><span style="color: #009900;">&#40;</span>handleError<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><span id="more-815"></span></p>
<p style="text-align:justify">While this approach should normally be the right one, there is a problem with the &#8216;onload&#8217; event that should be fired after the link DOM element has been inserted into the page header and the CSS file has been loaded. However, Firefox is not firing the onload event for CSS link elements, and IE is doing it only the first time; that&#8217;s to say, the code above will hardly work and if it does, it will not take the browser&#8217;s cache into account. What a mess!</p>
<p style="text-align:justify">There is another approach that seems to work, though. After all, CSS is only text, and another way to add CSS to your pages is through &#8216;style&#8217; elements. So the technique would consist on creating a DOM style element, loading its content with an AJAX call for the CSS file (or dynamic service!), then adding this content as the inner DOM element text. Well, there are small differences between IE and the other browsers, but <a href="http://www.phpied.com/dynamic-script-and-style-elements-in-ie/" target="_blank" rel="external">the solution</a> is working for me.</p>
<p style="text-align:justify">After reading in the <a href="http://bugs.dojotoolkit.org" target="_blank" rel="external">dojo Trac</a> that there is not such a thing as a <a href="http://bugs.dojotoolkit.org/ticket/5402" target="_blank" rel="external">&#8216;dojo.requireCSS&#8217;</a> component (which by the way works neatly for JS files), I found that the workaround explained above could be easily implemented with this framework. The reason that the example suggested is not become official is that, due to browser&#8217;s inconsistencies, it is not possible to control the onload events (it is based on link, not style elements). However, we can apply the workaround to the <a href="http://bugs.dojotoolkit.org/attachment/ticket/5402/requireCss.js" target="_blank" rel="external">suggested dojo library</a> to make it work. The next code block explains the result:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" rel="external"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p815code14'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p81514"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
</pre></td><td class="code" id="p815code14"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">provide</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;dojo.requireCss&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> cssCounter <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> cssInFlight <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> cssInFlightIntvl <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> cssStartTime <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> cssCache <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> callback <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> _watchCssInFlight <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//summary: watches to make sure all css files have loaded.</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> stillWaiting <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>cssInFlight<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> param <span style="color: #000066; font-weight: bold;">in</span> cssInFlight<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> param <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				console.<span style="color: #660066;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'waiting for '</span> <span style="color: #339933;">+</span> param<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				stillWaiting <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>stillWaiting<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">//Make sure we have not reached the timeout stage.</span>
			<span style="color: #003366; font-weight: bold;">var</span> waitInterval <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>dojo.<span style="color: #660066;">config</span>.<span style="color: #660066;">cssWaitSeconds</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>cssStartTime <span style="color: #339933;">+</span> waitInterval<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> err <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Timed out waiting for css files: &quot;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>param <span style="color: #000066; font-weight: bold;">in</span> cssInFlight<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					err <span style="color: #339933;">+=</span> param <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; &quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000066; font-weight: bold;">throw</span> err<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">//All loaded. Clean up.</span>
			console.<span style="color: #660066;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;all done&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			clearInterval<span style="color: #009900;">&#40;</span>cssInFlightIntvl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			cssInFlightIntvl <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// finally, launch callback if any</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>callback <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				callback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	dojo.<span style="color: #660066;">requireCss</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #006600; font-style: italic;">/*String*/</span>resourceName<span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">/*function*/</span>func<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//summary: Converts the resource name (&quot;some.thing&quot;) to a CSS URL</span>
		<span style="color: #006600; font-style: italic;">//(http://some.domain.com/path/to/some/thing.css), then adds the CSS file</span>
		<span style="color: #006600; font-style: italic;">//to the page. Full urls can be passed in (instead of a &quot;some.thing&quot; resourceName.</span>
		<span style="color: #006600; font-style: italic;">//It also registers this CSS file with the dojo loader. This</span>
		<span style="color: #006600; font-style: italic;">//means that if you do a dojo.addOnLoad() callback after calling this function,</span>
		<span style="color: #006600; font-style: italic;">//the addOnLoad callback will not be fired until the CSS file has loaded.</span>
		<span style="color: #006600; font-style: italic;">//Note that style sheets may be evaluated in a different order than the order</span>
		<span style="color: #006600; font-style: italic;">//they appear in the DOM. If you want precise ordering of style rules, make</span>
		<span style="color: #006600; font-style: italic;">//one call to this function, then in a dojo.addOnLoad() callback, load the other,</span>
		<span style="color: #006600; font-style: italic;">//and repeat this call structure until you load all the stylesheets.</span>
		<span style="color: #006600; font-style: italic;">//Example:</span>
		<span style="color: #006600; font-style: italic;">//		dojo.requireCss(&quot;some.thing&quot;);</span>
		<span style="color: #006600; font-style: italic;">//		dojo.requireCss(&quot;http://some.domain.com/path/to/some/thing.css&quot;);</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Customization: avoid the process if the resource was loaded before</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cssCache<span style="color: #009900;">&#91;</span>resourceName<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			console.<span style="color: #660066;">debug</span><span style="color: #009900;">&#40;</span>resourceName <span style="color: #339933;">+</span> <span style="color: #3366CC;">' was already loaded'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//Translate resource name to a file path</span>
		<span style="color: #003366; font-weight: bold;">var</span> path <span style="color: #339933;">=</span> resourceName<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>path.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			path <span style="color: #339933;">=</span> dojo._getModuleSymbols<span style="color: #009900;">&#40;</span>resourceName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.css'</span><span style="color: #339933;">;</span>
			path <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>path.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'/'</span> <span style="color: #339933;">||</span> path.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\w+:/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">:</span> dojo.<span style="color: #660066;">baseUrl</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> path<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>dojo.<span style="color: #660066;">config</span>.<span style="color: #660066;">cacheBust</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			path <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>path.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;?&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">&quot;?&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&amp;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> String<span style="color: #009900;">&#40;</span>dojo.<span style="color: #660066;">config</span>.<span style="color: #660066;">cacheBust</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\W+/g</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//Create the style node</span>
		<span style="color: #003366; font-weight: bold;">var</span> style <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">doc</span>.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;style&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		style.<span style="color: #660066;">type</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;text/css&quot;</span><span style="color: #339933;">;</span>
		cssInFlight<span style="color: #009900;">&#91;</span>path<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> style<span style="color: #339933;">;</span>			
		console.<span style="color: #660066;">debug</span><span style="color: #009900;">&#40;</span>path <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; created&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Customization: add it to an internal register so that it is not loaded twice</span>
		cssCache<span style="color: #009900;">&#91;</span>resourceName<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// now get the content with support for hooks</span>
		dojo.<span style="color: #660066;">xhrGet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span>path<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">then</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>style.<span style="color: #660066;">styleSheet</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// IE	</span>
				<span style="color: #003366; font-weight: bold;">var</span> imports <span style="color: #339933;">=</span> response.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/@import\s+url\s*\(\s*['|&quot;]([^'|&quot;]+)['|&quot;]\s*\);?/g</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>imports<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					iMax <span style="color: #339933;">=</span> imports.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
					<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>iMax<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						imports<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/['|&quot;]([^'|^&quot;]+)['|&quot;]/</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						dojo.<span style="color: #660066;">requireCss</span><span style="color: #009900;">&#40;</span>RegExp.$<span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				style.<span style="color: #660066;">styleSheet</span>.<span style="color: #660066;">cssText</span> <span style="color: #339933;">=</span> response<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// the others</span>
				style.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">createTextNode</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
			<span style="color: #009900;">&#125;</span>		    
&nbsp;
			console.<span style="color: #660066;">debug</span><span style="color: #009900;">&#40;</span>path <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; loaded&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">delete</span> cssInFlight<span style="color: #009900;">&#91;</span>path<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> func <span style="color: #339933;">==</span> <span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				func<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
		    <span style="color: #000066; font-weight: bold;">return</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//Attach the node to document.</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">headElement</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>._headElement <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;head&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">//Head element may not exist, particularly in html</span>
			<span style="color: #006600; font-style: italic;">//html 4 or tag soup cases where the page does not</span>
			<span style="color: #006600; font-style: italic;">//have a head tag in it. Use html element, since that will exist.</span>
			<span style="color: #006600; font-style: italic;">//Seems to be an issue mostly with Opera 9 and to lesser extent Safari 2</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066; font-weight: bold;">this</span>._headElement<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">this</span>._headElement <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		console.<span style="color: #660066;">debug</span><span style="color: #009900;">&#40;</span>path <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; adding to head&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">this</span>._headElement.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>style<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//Start the inflight watch.</span>
		cssStartTime <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>cssInFlightIntvl<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			cssInFlightIntvl <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span>_watchCssInFlight<span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// some public functions</span>
	dojo.<span style="color: #660066;">requireCss</span>.<span style="color: #660066;">setCallback</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #006600; font-style: italic;">/*Function*/</span>func<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> func <span style="color: #339933;">==</span> <span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			callback <span style="color: #339933;">=</span> func<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p style="text-align:justify"><strong>Note</strong>: The <a href="http://bugs.dojotoolkit.org/attachment/ticket/5402/requireCss.js" target="blank" rel="external">original code</a> by jburke on the <a href="http://bugs.dojotoolkit.org/" target="blank" rel="external">dojo Trac</a> project has been slightly modified to add functionality and to avoid some bugs. In particular:</p>
<ul>
<li>The function _watchCssInFlight has been simplified to its limits due to an error on IE (an infinite waiting loop was started). However, I&#8217;d recommend to take the original version and test it on your project, since the functionality it adds is beyond this simplified version&#8217;s one.</li>
<li>A cssCache has been added so that resources are only loaded once.</li>
<li>IE does not originally support style.appendChild(textNode), so <a href="http://www.phpied.com/dynamic-script-and-style-elements-in-ie/" target="blank" rel="external">a workaround</a> is needed to do so.</li>
<li>@import clauses in dynamic style tags are not supported by IE. To fix that, requireCss is now a recursive function: each CSS file loaded is scanned for @import declarations (take a look at the <a href="http://www.webreference.com/js/column5/backreferences.html" target="blank" rel="external">regexp!</a>), and for every new CSS imported, an asynchronous call is done. Because files are only loaded once, this matches the normal browser behavior to solve this particular problem.</li>
<li>A callback can be set so that it is fired once all CSS resources in the current page have been loaded. It can be useful to control CSS loading, then launch JS asynchronous loading (with dojo.require, for instance), or any other action. The module could be extended to accept also callbacks after individual elements have been loaded.</li>
</ul>
<p style="text-align:justify">Further tests have to be done with this component, and I take no responsibility if you use it for your own projects, but it has already solved a problem for me and, as far as I&#8217;ve checked, it is working on the latest versions of Firefox, IE, Safari, Opera and Chrome. Until there is an official solution to this integrated in the dojo toolkit, this fills the gap.</p>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/04/10/workaround-to-dynamically-load-css-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why iframes in rich web applications are evil</title>
		<link>http://jorgealbaladejo.com/2011/04/03/why-iframes-in-rich-web-applications-are-evil/</link>
		<comments>http://jorgealbaladejo.com/2011/04/03/why-iframes-in-rich-web-applications-are-evil/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 11:05:26 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[Client-side]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[Web Security]]></category>
		<category><![CDATA[iframes]]></category>
		<category><![CDATA[rich applications]]></category>
		<category><![CDATA[web applications]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=796</guid>
		<description><![CDATA[I write this post claiming to heavens that you (as a web developer figuring out whether to use or not iframes) will read and follow my advice. Not only for me, nor for you, but for a better world. Let&#8217;s say you are in charge of porting a desktop application to the web environment; you [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify">I write this post claiming to heavens that you (as a web developer figuring out whether to use or not iframes) will read and follow my advice. Not only for me, nor for you, but for a better world.</p>
<p style="text-align:justify">Let&#8217;s say you are in charge of porting a desktop application to the web environment; you have to change the paradigm and start using CSS, JS (lukily even a framework like Dojo) and finally HTML. Your webapp has menus, submenus, a lot of stuff and many different forms, interfaces and views to present and collect the information to and from the user.</p>
<p style="text-align:justify">And at some point you discover what iframes are, and may you think &#8220;they might well pay the effort, I can create every single interface separately and finally integrate them into the full framework, like a puzzle&#8221;. Don&#8217;t. They are not worthy, and you&#8217;ll find out why too late. Seriously, while iframes are useful in some practical situations (when there is absolutely no other solution), they bring in some major drawbacks when used to build the interfaces of your rich web app:</p>
<p><span id="more-796"></span></p>
<ul>
<li>The JS top layer application does not know about, and therefore cannot access, the DOM elements in inner frames.</li>
<li>CSS heritance is not respected, so there is no way to ensure what the inner frame is going to look like &#8211; unless CSS files are loaded again (see below).</li>
</ul>
<p style="text-align:justify">As a consequence of this two effects, both related to the very nature of an iframe (to load an external page into your site), every CSS and JS file must be loaded again in every inner frame so that the app can run, which produces a waste of server&#8217;s resources and slows the page load, which in turn impacts on user experience. Of course you can compile your files in production to alleviate this, but it is not going to fix the maintenance problems and the hacks and turnarounds that you&#8217;ll need to apply in order to get your web app working as expected. Not to talk about big applications: centralizing the logic of your SAAS in one main class is going to be very painful due to the limitations said above. And not centralizing such kind of huge logic (that&#8217;s to say, classical event-driven approach) can turn your best efforts to create a coherent code into a considerable mess. When your application grows and you realize about these limitations, there is not going to be a turnaround, and you&#8217;ll have to deal with an unstoppable monster.</p>
<p style="text-align:justify">Yeah, yeah, I know: they come in handy; they are easy to implement; they are useful and shinny; but moreover, they are very, very evil. Please, stop using them! If you ever have had to refactor a medium sized JS application based on iframes, you surely know what I&#8217;m talking about&#8230; otherwise, please, do yourself a favor (and to the ones that will come after you) and avoid those damn iframes. Please! I beg you!</p>
<p style="text-align:justify">Further reading:</p>
<ul>
<li><a href="http://blog.archive.jpsykes.com/126/dojo-and-iframes-tip/index.html" target="_blank" rel="external">http://blog.archive.jpsykes.com/126/dojo-and-iframes-tip/index.html</a></li>
<li><a href="http://www.thespanner.co.uk/2007/09/09/iframes-are-evil/" target="_blank" rel="external">http://www.thespanner.co.uk/2007/09/09/iframes-are-evil/</a></li>
<li><a href="http://stackoverflow.com/questions/96748/are-iframes-a-terrible-idea" target="_blank" rel="external">http://stackoverflow.com/questions/96748/are-iframes-a-terrible-idea</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/04/03/why-iframes-in-rich-web-applications-are-evil/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>E/R Zero or One to Many relationships</title>
		<link>http://jorgealbaladejo.com/2011/03/27/er-zero-or-one-to-many-relationships/</link>
		<comments>http://jorgealbaladejo.com/2011/03/27/er-zero-or-one-to-many-relationships/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 15:34:48 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[database design]]></category>
		<category><![CDATA[E/R modeling]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=787</guid>
		<description><![CDATA[While 1:n, 1:1 and n:m relationships are thoroughly used to design logical database models, there another another kind, {0&#124;1}:n that may come in handy in some cases. Lets analyze this relationship carefully. Imagine a relationship between students and classrooms. Every classroom can have N students, meaning this zero, one, or many pupils. From the other [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify">While 1:n, 1:1 and n:m relationships are thoroughly used to design logical database models, there another another kind, {0|1}:n that may come in handy in some cases. Lets analyze this relationship carefully.</p>
<p style="text-align:justify">Imagine a relationship between students and classrooms. Every classroom can have N students, meaning this zero, one, or many pupils. From the other side, every student must have a classroom, otherwise she won&#8217;t be allowed to study. This is a classic 1:n relationship, used in most of the real cases that we may encounter.</p>
<p style="text-align:justify">But what if, let&#8217;s say, a student had finished her studies and, however, wasn&#8217;t deleted from the database? (just to keep the records and other sensible information). In that case, the statement &#8216;every student must have one and only one classroom&#8217; would be wrong. Instead, we could say &#8216;every student can have one classroom or none&#8217;. Now we are talking about zero or one to many relationships.</p>
<p><span id="more-787"></span></p>
<p style="text-align:justify">A practical situation for this type of relationships are tree structures on auto-referenced tables. For instance, a category tree where every tuple can have a parent or none (thus being at root level). While a possible solution to this problem might be to create a &#8216;fake&#8217; root element that all the others inherit from unless said otherwise, this approach forces the design to include a &#8216;meta element&#8217;, not meant to represent data at all. That&#8217;s to say, it has to be programmatically removed from all database queries so not to have it poking around.</p>
<p style="text-align:justify">The right solution to this problem is making the foreign key nullable so that we can effectively represent the case when there is no parent while respecting relational integrity. In addition, the cascading options on deletion should be set as &#8216;set null&#8217; so that a possible deletion of a classroom does not delete all the students that might be related:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" rel="external"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p787code16'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78716"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p787code16"><pre class="mysql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- ------------------------------------------</span>
<span style="color: #808080; font-style: italic;">-- Table classrooms </span>
<span style="color: #808080; font-style: italic;">-- ------------------------------------------</span>
<a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=CREATE" rel="external"><span style="color: #990099; font-weight: bold;">CREATE</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=TABLE" rel="external"><span style="color: #990099; font-weight: bold;">TABLE</span></a> classrooms<span style="color: #FF00FF;">&#40;</span>
  classroomID <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=INT" rel="external"><span style="color: #999900; font-weight: bold;">INT</span></a> <a href="http://dev.mysql.com/doc/refman/%35%2E%31/en/non-typed-operators.html" rel="external"><span style="color: #CC0099; font-weight: bold;">NOT</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=NULL" rel="external"><span style="color: #9900FF; font-weight: bold;">NULL</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=AUTO_INCREMENT" rel="external"><span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span></a> <span style="color: #000033;">,</span>
  classroomName <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=VARCHAR" rel="external"><span style="color: #999900; font-weight: bold;">VARCHAR</span></a><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span> <a href="http://dev.mysql.com/doc/refman/%35%2E%31/en/non-typed-operators.html" rel="external"><span style="color: #CC0099; font-weight: bold;">NOT</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=NULL" rel="external"><span style="color: #9900FF; font-weight: bold;">NULL</span></a> <span style="color: #000033;">,</span>
  <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=PRIMARY%20KEY" rel="external"><span style="color: #990099; font-weight: bold;">PRIMARY KEY</span></a> <span style="color: #FF00FF;">&#40;</span>classroomID<span style="color: #FF00FF;">&#41;</span>
<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=ENGINE" rel="external"><span style="color: #990099; font-weight: bold;">ENGINE</span></a> <span style="color: #CC0099;">=</span> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=INNODB" rel="external"><span style="color: #990099; font-weight: bold;">InnoDB</span></a><span style="color: #000033;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- ------------------------------------------</span>
<span style="color: #808080; font-style: italic;">-- Table students</span>
<span style="color: #808080; font-style: italic;">-- ------------------------------------------</span>
<a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=CREATE" rel="external"><span style="color: #990099; font-weight: bold;">CREATE</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=TABLE" rel="external"><span style="color: #990099; font-weight: bold;">TABLE</span></a> students <span style="color: #FF00FF;">&#40;</span>
  studentID <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=INT" rel="external"><span style="color: #999900; font-weight: bold;">INT</span></a> <a href="http://dev.mysql.com/doc/refman/%35%2E%31/en/non-typed-operators.html" rel="external"><span style="color: #CC0099; font-weight: bold;">NOT</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=NULL" rel="external"><span style="color: #9900FF; font-weight: bold;">NULL</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=AUTO_INCREMENT" rel="external"><span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span></a> <span style="color: #000033;">,</span>
  studentName <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=VARCHAR" rel="external"><span style="color: #999900; font-weight: bold;">VARCHAR</span></a><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">50</span><span style="color: #FF00FF;">&#41;</span> <a href="http://dev.mysql.com/doc/refman/%35%2E%31/en/non-typed-operators.html" rel="external"><span style="color: #CC0099; font-weight: bold;">NOT</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=NULL" rel="external"><span style="color: #9900FF; font-weight: bold;">NULL</span></a> <span style="color: #000033;">,</span>
  classroomID <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=INT" rel="external"><span style="color: #999900; font-weight: bold;">INT</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=DEFAULT" rel="external"><span style="color: #990099; font-weight: bold;">DEFAULT</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=NULL" rel="external"><span style="color: #9900FF; font-weight: bold;">NULL</span></a> <span style="color: #000033;">,</span>
  <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=PRIMARY%20KEY" rel="external"><span style="color: #990099; font-weight: bold;">PRIMARY KEY</span></a> <span style="color: #FF00FF;">&#40;</span>studentID<span style="color: #FF00FF;">&#41;</span> <span style="color: #000033;">,</span>
  <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=CONSTRAINT" rel="external"><span style="color: #990099; font-weight: bold;">CONSTRAINT</span></a> fk_students_classrooms
    <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=FOREIGN%20KEY" rel="external"><span style="color: #990099; font-weight: bold;">FOREIGN KEY</span></a> <span style="color: #FF00FF;">&#40;</span>classroomID<span style="color: #FF00FF;">&#41;</span>
    <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=REFERENCES" rel="external"><span style="color: #990099; font-weight: bold;">REFERENCES</span></a> classrooms.classroomID
    <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=ON" rel="external"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=DELETE" rel="external"><span style="color: #990099; font-weight: bold;">DELETE</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=SET" rel="external"><span style="color: #990099; font-weight: bold;">SET</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=NULL" rel="external"><span style="color: #9900FF; font-weight: bold;">NULL</span></a>
    <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=ON" rel="external"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=UPDATE" rel="external"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=CASCADE" rel="external"><span style="color: #990099; font-weight: bold;">CASCADE</span></a>
<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=ENGINE" rel="external"><span style="color: #990099; font-weight: bold;">ENGINE</span></a> <span style="color: #CC0099;">=</span> <a href="http://search.mysql.com/search?site=refman-%35%31&amp;q=INNODB" rel="external"><span style="color: #990099; font-weight: bold;">InnoDB</span></a><span style="color: #000033;">;</span></pre></td></tr></table></div>

<p style="text-align:justify">Further reading: <a href="http://stackoverflow.com/questions/2530215/model-a-zero-or-one-to-many-relationship" target="_blank" rel="external">here</a> and <a href="http://stackoverflow.com/questions/925203/any-example-of-a-necessary-nullable-foreign-key" target="_blank" rel="external">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/03/27/er-zero-or-one-to-many-relationships/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t forget the (web) interface</title>
		<link>http://jorgealbaladejo.com/2011/03/15/dont-forget-the-web-interface/</link>
		<comments>http://jorgealbaladejo.com/2011/03/15/dont-forget-the-web-interface/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 19:15:11 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[Client-side]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[client-side]]></category>
		<category><![CDATA[interface programming]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[web performance]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=781</guid>
		<description><![CDATA[As a web developer, I am normally more into the back-end stuff: PHP, MVC, performance, page generation time, queries optimization and such stuff. However, it is a good idea not to forget the big picture (which is something that I tend to, by the way): server-side performance and stability are critical, but the client-side interface [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify">As a web developer, I am normally more into the back-end stuff: PHP, MVC, performance, page generation time, queries optimization and such stuff. However, it is a good idea not to forget the big picture (which is something that I tend to, by the way): server-side performance and stability are critical, but the client-side interface (JS, DOM Events, etc) plays also a significant part when talking about loading time, server load and overall performance.</p>
<p style="text-align:justify">In these times where cloud computing has settled and means to stay, it is very likely that our web interface is going to use several toolkits, libraries, widgets, plugins from different frameworks (such as jQuery, Dojo, Mootools), which, if used out of a coherent system, will produce a lot of server calls to download the related resources. Not only this adds up to server load, but it also can increase total load time by several magnitudes, which, in turn, makes the user feel that the entire web application is slow and crappy.</p>
<p style="text-align:justify">Just a few details we should never forget when optimizing our web interfaces to avoid the effect above (and this goes more as a self-reminder than as a hint):</p>
<ul>
<li>Use the right headers so that your image, CSS and JS files are kept in browser&#8217;s cache.</li>
<li>Make sure that gzip compression is active on the server.</li>
<li>Minify the JS/CSS files before putting them in a production environment.</li>
<li>Use sprites for GUI pictures.</li>
<li>Use a dynamic loader that grabs the related resources on-demand and asynchronously.</li>
<li>Combine JS/CSS files into modules.</li>
</ul>
<p style="text-align:justify">There are, of course, many more things you can do to ensure that your application runs smoothly, but the ones above are relatively easy to apply, and produce results in the middle / short term.</p>
<p>Any suggestions? Comments are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/03/15/dont-forget-the-web-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New MVCLight v0.1a released</title>
		<link>http://jorgealbaladejo.com/2011/01/19/new-mvclight-v0-1a-released/</link>
		<comments>http://jorgealbaladejo.com/2011/01/19/new-mvclight-v0-1a-released/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 14:46:22 +0000</pubDate>
		<dc:creator>Jorge Albaladejo</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[Web Architecture]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVCLight]]></category>

		<guid isPermaLink="false">http://jorgealbaladejo.com/?p=764</guid>
		<description><![CDATA[I have had the time lately to build a basic MVC framework in PHP, based on the great tutorial by PHPro.org. It has been designed to be light though structured and functional. It is intended for people who need to develop home-brew solutions and are not happy with the footprint of other frameworks, or for [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I have had the time lately to build a basic MVC framework in PHP, based on the <a href="http://www.phpro.org/tutorials/Model-View-Controller-MVC.html" target="_blank" rel="external">great tutorial</a> by <a href="http://www.phpro.org/" target="_blank" rel="external">PHPro.org</a>.</p>
<p style="text-align: justify;">It has been designed to be light though structured and functional. It is intended for people who need to develop home-brew solutions and are not happy with the footprint of other frameworks, or for those who just want to have fun while creating their own MVC system.</p>
<p style="text-align: justify;">If you are interested, visit the page for documentation and download <a href="http://jorgealbaladejo.com/about/mvclight/" target="_self">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jorgealbaladejo.com/2011/01/19/new-mvclight-v0-1a-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

