<?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>LogikDevelopment &#187; Html</title>
	<atom:link href="http://www.logikdev.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.logikdev.com</link>
	<description>&#34;Il n&#039;y a pas de problème, il n&#039;y a que des solutions. L&#039;esprit de l&#039;homme invente ensuite le problème.&#34; André Gide</description>
	<lastBuildDate>Fri, 27 Aug 2010 08:54:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Validate file size prior upload</title>
		<link>http://www.logikdev.com/2010/08/26/validate-file-size-prior-upload/</link>
		<comments>http://www.logikdev.com/2010/08/26/validate-file-size-prior-upload/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 20:53:37 +0000</pubDate>
		<dc:creator>smoreau</dc:creator>
				<category><![CDATA[Html]]></category>
		<category><![CDATA[ActiveX]]></category>
		<category><![CDATA[file input]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[fileSize function]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.logikdev.com/?p=687</guid>
		<description><![CDATA[If I ask you what is the most complex thing in HTML, what would you reply? For me, it would be the file upload (or maybe character encoding, but this is not the topic! ). One of the problem around the file upload functionality is that there is, no matter what, a file size limit [...]]]></description>
			<content:encoded><![CDATA[<p>If I ask you what is the most complex thing in HTML, what would you reply?<br />
For me, it would be the file upload (or maybe character encoding, but this is not the topic! <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ).</p>
<p>One of the problem around the file upload functionality is that there is, no matter what, a file size limit set on the server. The limit could be 100Kb such as 100Mb depending on the configuration of the server.<br />
But what happens if the user tries to upload a file bigger than the limit?<br />
It&#8217;s simple, the file is going to be uploaded on the server until the limit is reached. Once it happens, the server returns an error message to the client.<br />
Well, this is not ideal!<br />
Indeed, depending on the connection speed of the user, the error message could be displayed a few minutes later. And you know how impatient users are! <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>So obviously, the solution would be to validate the file size before the upload starts.<br />
To do that, we can simply use the <code>fileSize</code> Javascript function against the upload field.<br />
But, surprising enough, this function doesn&#8217;t work on Internet Explorer! <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_evil.gif' alt=':evil:' class='wp-smiley' /> </p>
<p>And the only solution I found to get the file size with IE was using ActiveX:</p>
<pre class="brush: jscript;">
var oas = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;);
var e = oas.getFile(document.forms[0].file.value);
var size = e.size;
</pre>
<p>Finally, here is the whole Javascript function to validate the file size:</p>
<pre class="brush: jscript;">
function validateFileSize(file, maxSize) {
	if (navigator.appName==&quot;Microsoft Internet Explorer&quot;) {
		if (file.value) {
			var oas = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;);
			var e = oas.getFile(file.value);
			var size = e.size;
		}
	} else {
		if (file.files[0]!=undefined) {
			var size = file.files[0].fileSize;
		}
	}
	if (size!=undefined &amp;&amp; size &gt; maxSize)
		return false;
	return true;
}
</pre>
<p>with <code>file</code> the file input field to validate and <code>maxSize</code> the maximum size in bits.</p>
<p>For example, you can call this function as follow:</p>
<pre class="brush: jscript; light: true;">
validateImageSize(document.forms[0].file, 500000)
</pre>
<p><br/>I successfully tested this code on:</p>
<ul>
<li>Google Chrome 6;</li>
<li>Firefox 3.6;</li>
<li>Internet Explorer 6;</li>
<li>Internet Explorer 7.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.logikdev.com/2010/08/26/validate-file-size-prior-upload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The message tags of MyFaces and RichFaces</title>
		<link>http://www.logikdev.com/2010/05/06/message-tags-of-myfaces-and-richfaces/</link>
		<comments>http://www.logikdev.com/2010/05/06/message-tags-of-myfaces-and-richfaces/#comments</comments>
		<pubDate>Thu, 06 May 2010 19:25:37 +0000</pubDate>
		<dc:creator>smoreau</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[FacesMessage]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[message tag]]></category>
		<category><![CDATA[MyFaces]]></category>
		<category><![CDATA[RichFaces]]></category>

		<guid isPermaLink="false">http://www.logikdev.com/?p=472</guid>
		<description><![CDATA[Working on an application using MyFaces and RichFaces, I had no choice but understand what is the difference between the message tag provided by Myfaces (h:message) and the message tag overridden by RichFaces (rich:message). These tags allow to display information about the first FacesMessage that is assigned to the component referenced by the &#8220;for&#8221; attribute. [...]]]></description>
			<content:encoded><![CDATA[<p>Working on an application using MyFaces and RichFaces, I had no choice but understand what is the difference between the message tag provided by Myfaces (<code>h:message</code>) and the message tag overridden by RichFaces (<code>rich:message</code>).</p>
<p>These tags allow to display information about the first FacesMessage that is assigned to the component referenced by the &#8220;for&#8221; attribute. The difference is that the RichFaces tag has some extra functionalities such as Ajax rendering, error markers and predefined css class names.<br />
Have a look at the following page for more details: <a target="_blank" href="http://livedemo.exadel.com/richfaces-demo/richfaces/message.jsf">http://livedemo.exadel.com/richfaces-demo/richfaces/message.jsf</a></p>
<p>This is all nice and well but it is not the only difference. Indeed, the HTML code generated by both these frameworks will also be different!</p>
<p>First of all, let&#8217;s see how the tag <code>&lt;h:message styleClass="errormsg" for="element"/&gt;</code> will be transformed. If there is no message to display, nothing will be generated (which is a good behaviour). However, if a message is present, the tag will be replaced by the following HTML code:</p>
<pre class="brush: xml;">
&lt;span class=&quot;errormsg&quot;&gt;Required.&lt;/span&gt;
</pre>
<p>So far, so good!</p>
<p>But now let&#8217;s check what code RichFaces is generating for the tag <code>&lt;rich:message styleClass="errormsg" for="element"/&gt;</code>.<br />
The following is the code created if there is NO message to render:</p>
<pre class="brush: xml;">
&lt;span class=&quot;rich-message errormsg&quot; id=&quot;form:j_id255&quot;&gt;
    &lt;span class=&quot;rich-message-label&quot;&gt;&lt;/span&gt;
&lt;/span&gt;
</pre>
<p>And here is the code which will replace the RichFaces tag if there is a message to display:</p>
<pre class="brush: xml;">
&lt;span id=&quot;bookingform:j_id255&quot; class=&quot;rich-message errormsg&quot;&gt;
    &lt;span class=&quot;rich-message-label&quot;&gt;Required.&lt;/span&gt;
&lt;/span&gt;
</pre>
<p>As you can see, the main difference is that RichFaces is wrapping the original <code>span</code> tag into another <code>span</code> tag. But, it is also generating some code even if there is no message to display! You would ask why is it doing that? The response is simple. The wrapper span element is necessary for RichFaces to Ajax-render the message tag if an error message has to be displayed for the targeting element.</p>
<p>So make sure you don&#8217;t put any padding or margin style in your custom CSS class which I called &#8216;errormsg&#8217; in my example. Otherwise, you might have a gap when you were expecting nothing&#8230; (this happened to me) <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.logikdev.com/2010/05/06/message-tags-of-myfaces-and-richfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Onclick event is not fired on IE</title>
		<link>http://www.logikdev.com/2009/12/08/onclick-event-is-not-fired-on-ie/</link>
		<comments>http://www.logikdev.com/2009/12/08/onclick-event-is-not-fired-on-ie/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 23:05:58 +0000</pubDate>
		<dc:creator>smoreau</dc:creator>
				<category><![CDATA[Html]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[onclick]]></category>
		<category><![CDATA[Return key]]></category>
		<category><![CDATA[RichFaces]]></category>

		<guid isPermaLink="false">http://www.logikdev.com/?p=175</guid>
		<description><![CDATA[I am pretty sure everybody knows that Internet Explorer has &#8220;a few&#8221; bugs&#8230; You didn&#8217;t? Alright, better to stay on your little cloud and leave this blog right away! For the others, I will talk about the JavaScript event onclick which is not fired when the following requirements are matched: In a form; There is [...]]]></description>
			<content:encoded><![CDATA[<p>I am pretty sure everybody knows that Internet Explorer has &#8220;a few&#8221; bugs&#8230;  <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_rolleyes.gif' alt=':roll:' class='wp-smiley' /><br />
You didn&#8217;t? <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_eek.gif' alt='8-O' class='wp-smiley' /> Alright, better to stay on your little cloud and leave this blog right away!</p>
<p>For the others, I will talk about the JavaScript event <strong>onclick</strong> which is not fired when the following requirements are matched:</p>
<ul>
<li>In a form;</li>
<li>There is only ONE input text element;</li>
<li>There is one button which has an <code>onclick</code> event assigned;</li>
<li>You press the &#8216;Enter&#8217; button inside the input text element.</li>
</ul>
<p>For a better understanding, let&#8217;s now take the following example:</p>
<pre class="brush: xml;">
&lt;html&gt;
    &lt;head&gt;&lt;title&gt;Test&lt;/title&gt;&lt;head&gt;
    &lt;body&gt;
        &lt;form&gt;
            &lt;input type=&quot;text&quot; id=&quot;t1&quot;/&gt;
            &lt;input type=&quot;submit&quot; onclick=&quot;alert('onclick fired!'); return true;&quot;/&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>As you can see, there is nothing difficult in this code.<br />
Well, that doesn&#8217;t mean Internet Explorer can handle it&#8230;  <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </p>
<p>The bug occurs if you press the &#8216;Enter&#8217; button inside the input text element using Internet Explorer. Indeed, the <code>onclick</code> event is not fired and the text &#8216;onclick fired!&#8217; is not display to the user! However, it works perfectly fine on Firefox and Safari.</p>
<p>The funny thing is this code works on Internet Explorer if you add another input text, even if it is hidden!<br />
Why? Don&#8217;t ask me! <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_neutral.gif' alt=':-|' class='wp-smiley' /> </p>
<p>Anyway, the following example works on IE:</p>
<pre class="brush: xml;">
&lt;html&gt;
    &lt;head&gt;&lt;title&gt;Test&lt;/title&gt;&lt;head&gt;
    &lt;body&gt;
        &lt;form&gt;
            &lt;input type=&quot;text&quot; id=&quot;t1&quot;/&gt;
            &lt;input type=&quot;text&quot; style=&quot;display:none&quot;/&gt;
            &lt;input type=&quot;submit&quot; onclick=&quot;alert('onclick fired!'); return true;&quot;/&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p><br/>Why are we assigning an <code>onclick</code> event to the submit button?<br />
It could be for a lot of reasons, but the main one is probably to validate the form before submitting the data.</p>
<p>By the way, RichFaces is very often using this event on the submit buttons.<br />
So remember to add a hidden input text to your form if you want to allow users to use the &#8216;Return&#8217; key. <img src='http://www.logikdev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.logikdev.com/2009/12/08/onclick-event-is-not-fired-on-ie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
