<?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>Stefan Sobek Blog</title>
	<atom:link href="http://www.sobek.info/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sobek.info/blog</link>
	<description>Writing about IT, Software Engineering, sports and other stuff</description>
	<lastBuildDate>Mon, 24 Jan 2011 12:50:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>In Excel einen Bereich uneditierbar machen</title>
		<link>http://www.sobek.info/blog/2011/01/24/in-excel-einen-bereich-uneditierbar-machen/</link>
		<comments>http://www.sobek.info/blog/2011/01/24/in-excel-einen-bereich-uneditierbar-machen/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 12:50:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MS-Office]]></category>
		<category><![CDATA[Deutsch]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Office Tips]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=321</guid>
		<description><![CDATA[Problem
Ein bestimmter Bereich eines Excel-Sheets soll nur bearbeitbar sein. Der Rest des Arbeitsblattbereiches soll gesperrt werden.
Lösung
Da gibt es mehrere Lösungen, jedoch bin ich auf die nachfolgende gestoßen, die sehr simpel und effektiv ist.
Nehmen wir an, der Bereich A1-D10 soll editierbar sein. Alle weiteren Zellen müssen gesperrt werden, ob dort Text steht oder nicht.

Geht in den [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
Ein bestimmter Bereich eines Excel-Sheets soll nur bearbeitbar sein. Der Rest des Arbeitsblattbereiches soll gesperrt werden.</p>
<p><strong>Lösung</strong><br />
Da gibt es mehrere Lösungen, jedoch bin ich auf die nachfolgende gestoßen, die sehr simpel und effektiv ist.</p>
<p>Nehmen wir an, der Bereich A1-D10 soll editierbar sein. Alle weiteren Zellen müssen gesperrt werden, ob dort Text steht oder nicht.</p>
<ul>
<li>Geht in den Visual Basic Editor in Excel (unterschiedlich nach Office-Version &#8211; Office 2007 Tab Entwicklertools)</li>
<li>Dort unter VBAProject mit der rechten Maustaste auf das entsprechende Sheet klicken (z.B. Tabelle1)</li>
<li>&#8220;Code anzeigen&#8221; auswählen</li>
<li>Nun das nachfolgende Snippet einfügen:</li>
</ul>
<p><code>Private Sub Worksheet_Activate()<br />
'Set/restrict sheet's scroll area.<br />
Me.ScrollArea = "A1:D10"<br />
End Sub</code></p>
<p>Jetzt ist bis auf den Bereich A1:D10 jede weitere Zelle auf dem Blatt gesperrt</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2011/01/24/in-excel-einen-bereich-uneditierbar-machen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Z-Index Problems in IE7 and superfish menu plugin</title>
		<link>http://www.sobek.info/blog/2011/01/10/z-index-problems-in-ie7-and-superfish-menu-plugin/</link>
		<comments>http://www.sobek.info/blog/2011/01/10/z-index-problems-in-ie7-and-superfish-menu-plugin/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 15:19:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[IE7 Bug]]></category>
		<category><![CDATA[z-index]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=318</guid>
		<description><![CDATA[Ever had problems in IE7 with z-index css attribute? 
Problem:
The Menu created with superfish plugin for jquery will be shown behind the main content on mouseover. 
Solution:
With Jquery dynamically reverse the CSS zindex stacking order of the page element so that higher elements in HTML source have highter z-index number

?View Code JAVA1
2
3
4
5
6
7
    [...]]]></description>
			<content:encoded><![CDATA[<p>Ever had problems in IE7 with z-index css attribute? </p>
<p><strong>Problem</strong>:<br />
The Menu created with superfish plugin for jquery will be shown behind the main content on mouseover. </p>
<p><strong>Solution:</strong><br />
With Jquery dynamically reverse the CSS zindex stacking order of the page element so that higher elements in HTML source have highter z-index number</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p318code2'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p3182"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p318code2"><pre class="java" style="font-family:monospace;">       	$<span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		var zIndexNumber <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">each</span><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'zIndex'</span>, zIndexNumber<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			zIndexNumber <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">10</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><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Check this link for more information: <a href="http://www.vancelucas.com/blog/fixing-ie7-z-index-issues-with-jquery/">http://www.vancelucas.com/blog/fixing-ie7-z-index-issues-with-jquery/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2011/01/10/z-index-problems-in-ie7-and-superfish-menu-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Override equals, toString and hashCode in Java classes</title>
		<link>http://www.sobek.info/blog/2010/12/11/override-equals-tostring-and-hashcode-in-java-classes/</link>
		<comments>http://www.sobek.info/blog/2010/12/11/override-equals-tostring-and-hashcode-in-java-classes/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 20:02:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[effective java]]></category>
		<category><![CDATA[equals method]]></category>
		<category><![CDATA[hashCode]]></category>
		<category><![CDATA[toString]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=307</guid>
		<description><![CDATA[Override equals
Although some people think it might be easy to override the equals method of a class, you can do it wrong in many cases and this can cause problems.
The easiest case is not to override the equals method, then each class is equals only to itself and equals from object is used. Do this [...]]]></description>
			<content:encoded><![CDATA[<h5>Override equals</h5>
<p>Although some people think it might be easy to override the equals method of a class, you can do it wrong in many cases and this can cause problems.</p>
<p>The easiest case is not to override the equals method, then each class is equals only to itself and equals from object is used. Do this only in following cases:</p>
<ul>
<li>When each instance is inherently unique. For example classes as Thread. These represent active entites rather than values. So for value objects this is no applicable.</li>
<li>You don&#8217;t need a &#8220;logical equality&#8221; test. For example the java.util.Random where it does not make sense to check if two random numbers are equal.</li>
<li>The superclass equals is fully appropriate. E.g. Set -&gt; AbstractSet, List -&gt; AbstractList</li>
<li>The class or the package is private and it is assured that it will not been invoced</li>
</ul>
<p><strong>When to override equals method?</strong></p>
<p>When the logical equality differs from object identity. This is the case for value classes. This class represents a value such as Integer or Date. If these objects will be compared you want to know if the values are the same and not if the objects are the same.</p>
<p>The Java6 specification says about the contract which must be assured when overriding equals:</p>
<p>• Reflexive:Foranynon-nullreferencevaluex,x.equals(x)mustreturntrue.<br />
• Symmetric:Foranynon-nullreferencevaluesxandy,x.equals(y)mustre- turn true if and only if y.equals(x) returns true.<br />
• Transitive:Foranynon-nullreferencevaluesx,y,z,ifx.equals(y)returns true and y.equals(z) returns true, then x.equals(z) must return true.<br />
• Consistent: For any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, pro- vided no information used in equals comparisons on the objects is modified.<br />
• For any non-null reference value x, x.equals(null) must return false.</p>
<p><strong>How should equals be overridden?</strong></p>
<p>This list was taken from Effective Java 2nd Edition.</p>
<ul>
<li>Use the == operator to check if the argument is a reference to this object.</li>
<li>Use the instanceof operator to check if the argument has the correct type.</li>
<li>Cast the argument to the correct type.</li>
<li>For each “significant” field in the class, check if that field of the argument matches the corresponding field of this object.</li>
<li>When you are finished writing your equals method, ask yourself three questions: Is it symmetric? Is it transitive? Is it consistent?</li>
</ul>
<h5>Override hashCode</h5>
<p>Always override hashCode when you override equals.</p>
<p>Here is the contract from the Java specification:</p>
<p>Here is the contract, copied from the Object specification [JavaSE6]:<br />
• Whenever it is invoked on the same object more than once during an execu- tion of an application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execu- tion of an application to another execution of the same application.<br />
• If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.<br />
• It is not required that if two objects are unequal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.</p>
<p>Furthermore two equal objects must have the same hash code.</p>
<p><strong>How to create a good has method?</strong></p>
<p>Here are some tips taken from Effective Java book:</p>
<ul>
<li>Store some constant nonzero value, say 17, in an int variable called result.</li>
<li>For each significant field f in your object (each field taken into account by the equals method, that is), do the following:
<ul>
<li>Compute an int has code c for the field:
<ul>
<li>If the field is a boolean, compute (f ? 1 : 0)</li>
<li>if the field is a byte, char, short, or int, computer (int) f.</li>
<li>If the field is a long, computer (int) (f^&gt;&gt;&gt;32)).</li>
<li>If the field is a float, computer Float.floatToIntBits(f).</li>
<li>If the field is a double, compute Double.doubleToLongBits(f), and then hash the resulting long as in step for long.</li>
<li>If the field is an object reference and this class&#8217;s equals method compares the field by recursively invoking equals, recursively invoke hashCode on the field. If a more complex comparison is required, compute a &#8220;canonical representation&#8221; for this field and invoke hasCode on the canonical representation. If the value of the field is null, return 0 or some other constant.</li>
<li>If the field is an array, treat it as if each element were a separate field. That is, compute a hash code for each significant element by applying these rules recursively, and combine these values per step 2 for byte,short etc. If every element in an array field is significant, you can use one of the Arrays.hasCode methods added in release 1.5.</li>
</ul>
</li>
<li>Combine the has code c computed in step 2 into result as follows:<br />
result = 31 * result + c;</li>
</ul>
</li>
<li>Return result.</li>
<li>When you are finished writing the hashCode method, ask yourself whether equal instances have equal hash codes. Write unit tests to verify your intuition! If equal instances have unequal hash codes, figure out why and fix the problem.</li>
</ul>
<p><strong>Override toString</strong></p>
<p>If you do not override toString method and print an object you usally see something like this PhoneNumber@434b65. Ok, it is clear that this is a phone number, but wouldn&#8217;t it be better to have a representation like &#8220;(0221) 77744499&#8243;?</p>
<p>So when overriding the toString method it should return all of the interesting information contained in the object. If you have large objects or objects with a not conductive state you can return something like &#8220;Yellow pages (2355333 listings)&#8221;.</p>
<p>Provide your toString method with good documentation and describe your format. Here is an example taken from Effective Java 2nd Edition:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p307code5'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p3075"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p307code5"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/** 
* Returns the string representation of this phone number. 
* The string consists of fourteen characters whose format 
* is &quot;(XXX) YYY-ZZZZ&quot;, where XXX is the area code, YYY is 
* the prefix, and ZZZZ is the line number. (Each of the 
* capital letters represents a single decimal digit.) 
* 
* If any of the three parts of this phone number is too small 
* to fill up its field, the field is padded with leading zeros. 
* For example, if the value of the line number is 123, the last 
* four characters of the string representation will be &quot;0123&quot;. 
* 
* Note that there is a single space separating the closing 
* parenthesis after the area code from the first digit of the 
* prefix. 
*/</span>
@Override <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">return</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(%03d) %03d-%04d&quot;</span>, areaCode, prefix, lineNumber<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>If you want not a specific format make something like this:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p307code6'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p3076"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p307code6"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/**
* Returns a brief description of this potion. The exact details 
* of the representation are unspecified and subject to change, 
* but the following may be regarded as typical:
* &quot;[Potion #9: type=love, smell=turpentine, look=india ink]&quot; 
@Override public String toString() { ... }</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2010/12/11/override-equals-tostring-and-hashcode-in-java-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use builder instead of constructor with many attributes</title>
		<link>http://www.sobek.info/blog/2010/12/02/use-builder-instead-of-constructor-with-many-attributes/</link>
		<comments>http://www.sobek.info/blog/2010/12/02/use-builder-instead-of-constructor-with-many-attributes/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 09:28:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[builder pattern]]></category>
		<category><![CDATA[effective java]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=291</guid>
		<description><![CDATA[Imagine you would like to create a payment in banking domain and you have to create an instance with many parameters. The first two parameters are mandatory and the others are optional. You would normally create it like:

?View Code JAVA1
Payment credit = new Payment&#40;Payment.CREDIT, &#34;1000&#34;, &#34;Beneficiary account&#34;, &#34;Beneficiary bank name&#34;, &#34;Remitter account name&#34;, &#34;Remitter bank [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine you would like to create a payment in banking domain and you have to create an instance with many parameters. The first two parameters are mandatory and the others are optional. You would normally create it like:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p291code11'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p29111"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p291code11"><pre class="java" style="font-family:monospace;">Payment credit <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Payment<span style="color: #009900;">&#40;</span>Payment.<span style="color: #006633;">CREDIT</span>, <span style="color: #0000ff;">&quot;1000&quot;</span>, <span style="color: #0000ff;">&quot;Beneficiary account&quot;</span>, <span style="color: #0000ff;">&quot;Beneficiary bank name&quot;</span>, <span style="color: #0000ff;">&quot;Remitter account name&quot;</span>, <span style="color: #0000ff;">&quot;Remitter bank name&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This could be a long line, depending on the number of parameters. Also from the code you don&#8217;t know which parameter you actually set in the constructor. Ok, lets use Java Beans style with getter and setters:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p291code12'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p29112"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p291code12"><pre class="java" style="font-family:monospace;">Payment credit <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Payment<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
credit.<span style="color: #006633;">setType</span><span style="color: #009900;">&#40;</span>Payment.<span style="color: #006633;">CREDIT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
credit.<span style="color: #006633;">setAmount</span><span style="color: #009900;">&#40;</span>1000<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
credit.<span style="color: #006633;">setBeneficiaryAccountName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Beneficiary account name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
credit.<span style="color: #006633;">setBeneficiaryAccountBankName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Beneficiary bank name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
credit.<span style="color: #006633;">setRemitterAccountName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Remitter account name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
credit.<span style="color: #006633;">setRemitterAccountBankName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Remitter bank name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>So far so good, now we know exactly what we set and we use Java Beans spec. But now we have the problem that the creation process is split between multiple calls of the setters. This could lead to an inconsistent state during the creation process. If somewhere between these setter calls a problem occurs, the objects could be initialized incompletely.</p>
<p>What if you could create an instance like the following:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p291code13'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p29113"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p291code13"><pre class="java" style="font-family:monospace;">Payment credit <span style="color: #339933;">=</span> Payment.<span style="color: #006633;">Builder</span><span style="color: #009900;">&#40;</span>Payment.<span style="color: #006633;">CREDIT</span>, <span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">beneficiaryName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Beneficiary name&quot;</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">beneficiaryAccount</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Beneficiary account name&quot;</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">remitterName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Remitter name&quot;</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">remitterAccount</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Remitter account name&quot;</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>We seperated the optional from the mandatory parameters and improved readability. Also this is only one call and so is the instance in a consistent state.</p>
<p>Here is the example code of the class Payment:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p291code14'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p29114"><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
</pre></td><td class="code" id="p291code14"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Payment <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> CREDIT <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> DEBIT <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> type<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// required</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">double</span> amount<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// required</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> beneficiaryAccount<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// required</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> beneficiaryName<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// required</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> remitterName<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// optional</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> remitterAccount<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// optional</span>
&nbsp;
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> Builder <span style="color: #009900;">&#123;</span>
     <span style="color: #666666; font-style: italic;">// Required parameters</span>
     <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> type<span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">double</span> amount<span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// Optional parameters - initialized to default values</span>
     <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> beneficiaryAccount <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> beneficiaryName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> remitterName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> remitterAccount <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">public</span> Builder<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> type, <span style="color: #000066; font-weight: bold;">double</span> amount<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">type</span> <span style="color: #339933;">=</span> type<span style="color: #339933;">;</span>
       <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">amount</span> <span style="color: #339933;">=</span> amount<span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">public</span> Builder beneficiaryAccount <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"><span style="color: #003399;">String</span></a> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> remitterAccount <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
     <span style="color: #000000; font-weight: bold;">public</span> Builder beneficiaryName <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"><span style="color: #003399;">String</span></a> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> remitterAccount <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
     <span style="color: #000000; font-weight: bold;">public</span> Builder remitterName <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"><span style="color: #003399;">String</span></a> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> remitterAccount <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
     <span style="color: #000000; font-weight: bold;">public</span> Builder remitterAccount <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"><span style="color: #003399;">String</span></a> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> remitterAccount <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
     <span style="color: #000000; font-weight: bold;">public</span> Payment build<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Payment<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</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: #000000; font-weight: bold;">private</span> Payment<span style="color: #009900;">&#40;</span>Builder builder<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     type <span style="color: #339933;">=</span> builder.<span style="color: #006633;">type</span><span style="color: #339933;">;</span>
     amount <span style="color: #339933;">=</span> builder.<span style="color: #006633;">amount</span><span style="color: #339933;">;</span>
     beneficiaryAccount <span style="color: #339933;">=</span> builder.<span style="color: #006633;">beneficiaryAccount</span><span style="color: #339933;">;</span>
     beneficiaryName <span style="color: #339933;">=</span> builder.<span style="color: #006633;">beneficiaryName</span><span style="color: #339933;">;</span>
     remitterName <span style="color: #339933;">=</span> builder.<span style="color: #006633;">remitterName</span><span style="color: #339933;">;</span>
     remitterAccount <span style="color: #339933;">=</span> builder.<span style="color: #006633;">remitterAccount</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Examples modified from the Book &#8220;Effective Java&#8221; http://www.amazon.de/gp/product/0321356683</p>
<p>Another great article can you find here: http://www.javablog.ch/2008/08/23/effective-java-builder-pattern/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2010/12/02/use-builder-instead-of-constructor-with-many-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Good programmer or architect</title>
		<link>http://www.sobek.info/blog/2010/10/26/good-programmer-or-architect/</link>
		<comments>http://www.sobek.info/blog/2010/10/26/good-programmer-or-architect/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 10:43:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[J2EE/JEE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Good programmer]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JEE]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=289</guid>
		<description><![CDATA[I recently read in a chapter of Rod Johnsons Book &#8220;expert one-to-one, J2EE Design and Development&#8221; an interesting sentence:
A professional programmer or architect cares more about learning and discovering the best solution than the buzz of finding their own solution to a particular problem.
This is so true. Don&#8217;t waste (project) time with finding a very [...]]]></description>
			<content:encoded><![CDATA[<p>I recently read in a chapter of Rod Johnsons Book &#8220;expert one-to-one, J2EE Design and Development&#8221; an interesting sentence:</p>
<blockquote><p>A professional programmer or architect cares more about learning and discovering the best solution than the buzz of finding their own solution to a particular problem.</p></blockquote>
<p>This is so true. Don&#8217;t waste (project) time with finding a very own solution and reinventing the wheel. Find solutions that fit your needs, learn how they solved the problem. Of course they must fit to your problem with a coerage of lets say >90%. But these solutions are tested. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2010/10/26/good-programmer-or-architect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using attribute values of composite component in commandLink</title>
		<link>http://www.sobek.info/blog/2010/10/14/using-attribute-values-of-composite-component-in-commandlink/</link>
		<comments>http://www.sobek.info/blog/2010/10/14/using-attribute-values-of-composite-component-in-commandlink/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 11:39:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[commandLink]]></category>
		<category><![CDATA[composite component]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[jsf]]></category>
		<category><![CDATA[jsf 2.0]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=284</guid>
		<description><![CDATA[Situation:
You created a composite component in JSF 2.0. This component now should have some attributes which contains direct links. This links should now be declared when you use the component.
Example:

?View Code HTML1
2
3
    &#60;composite:attribute type=&#34;java.lang.String&#34; required=&#34;false&#34;
        name=&#34;logoutURL&#34; default=&#34;/faces/logout.jsf&#34;
        shortDescription=&#34;The [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Situation:</strong><br />
You created a composite component in JSF 2.0. This component now should have some attributes which contains direct links. This links should now be declared when you use the component.<br />
Example:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p284code18'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p28418"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p284code18"><pre class="html" style="font-family:monospace;">    &lt;composite:attribute type=&quot;java.lang.String&quot; required=&quot;false&quot;
        name=&quot;logoutURL&quot; default=&quot;/faces/logout.jsf&quot;
        shortDescription=&quot;The logout URL.&quot; /&gt;</pre></td></tr></table></div>

<p>Later in the implementation you use it like the following example:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p284code19'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p28419"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p284code19"><pre class="html" style="font-family:monospace;">		&lt;h:commandLink action=&quot;#{cc.attrs.helpURL}&quot;
			value=&quot;#{textbundle['status.linktext.logout']}&quot; /&gt;</pre></td></tr></table></div>

<p><strong>Problem</strong><br />
You now get a class cast exception. JSF excepts a String result of a method which you can use in the action attribute of commandLink. Directly putting a String in this result is ok. </p>
<p><strong>Solution</strong><br />
Use toString (although you declared the attribute as type of String)</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p284code20'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p28420"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p284code20"><pre class="html" style="font-family:monospace;">		&lt;h:commandLink action=&quot;#{cc.attrs.helpURL.toString}&quot;
			value=&quot;#{textbundle['status.linktext.logout']}&quot; /&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2010/10/14/using-attribute-values-of-composite-component-in-commandlink/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Load data from csv into html-table</title>
		<link>http://www.sobek.info/blog/2010/06/04/load-data-from-csv-into-html-table/</link>
		<comments>http://www.sobek.info/blog/2010/06/04/load-data-from-csv-into-html-table/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 07:23:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[csv2table]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=278</guid>
		<description><![CDATA[Situation:
Imagine your customer has a bunch of Excel-files which he wanted to display on a website in html-form. 
Problem:
What can you do here? You can write an importer to a database, or let the customer upload the excel file on a webserver and write a parser for the excel files etc. These are all non-trivial [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Situation:</strong><br />
Imagine your customer has a bunch of Excel-files which he wanted to display on a website in html-form. </p>
<p><strong>Problem:</strong><br />
What can you do here? You can write an importer to a database, or let the customer upload the excel file on a webserver and write a parser for the excel files etc. These are all non-trivial solutions for the problem that you want to easily display your information from the csv on a webpage into a table. </p>
<p><strong>Solution: </strong><br />
I found a plugin called jquery csv2table. This is very simple to use. A CSV-file will be read asynchrounosly and a HTML-table will be created of it. So you can simply let your customer load his csv file up and the table will be created automatically. Optional support of sorting, highlighting etc. Link: http://plugins.jquery.com/project/csv2table</p>
<p><strong>Example: </strong></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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p278code22'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p27822"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p278code22"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;view1&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<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: #009900;">&#40;</span><span style="color: #3366CC;">'#view1'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">csv2table</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./data/Book12.csv'</span><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: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>This code will load the data from Book12.csv into the div &#8220;view1&#8243;. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2010/06/04/load-data-from-csv-into-html-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux, Unix, Mac &#8211; Loop filenames with spaces</title>
		<link>http://www.sobek.info/blog/2010/05/10/linux-unix-mac-loop-filenames-with-spaces/</link>
		<comments>http://www.sobek.info/blog/2010/05/10/linux-unix-mac-loop-filenames-with-spaces/#comments</comments>
		<pubDate>Mon, 10 May 2010 14:23:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[loop filenames]]></category>
		<category><![CDATA[shellscript]]></category>
		<category><![CDATA[spaces in linux filenames]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=272</guid>
		<description><![CDATA[Situation 
You want to operate on a linux, unix or mac system some files in a bash script and do some file operations like modifying the text content or moving the files to another location depending on the filename, content or another mathinc pattern. 
Problem 
Wondered why you have problems with windows files in a [...]]]></description>
			<content:encoded><![CDATA[<h5>Situation </h5>
<p>You want to operate on a linux, unix or mac system some files in a bash script and do some file operations like modifying the text content or moving the files to another location depending on the filename, content or another mathinc pattern. </p>
<h5>Problem </h5>
<p>Wondered why you have problems with windows files in a network when looping over them? Linux takes whitespaces in file name as line separator so that echoing the file will cause a separate line and so you cannot operate on this file. </p>
<h5>Solution </h5>
<p>I guess it is called <strong>Instruction Field Separator</strong> or something. You have to set this only to line break and not to whitespaces. First save the old variable content, then set the new content so that the bash do not takes whitespaces as line separators</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p272code24'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p27224"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p272code24"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">OLDIFS</span>=<span style="color: #007800;">$IFS</span>
<span style="color: #007800;">IFS</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-en</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>\b&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> FILE <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.txt)
do
   echo $FILE
done
&nbsp;
$IFS = $OLDIFS</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2010/05/10/linux-unix-mac-loop-filenames-with-spaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jquery introduction part 1</title>
		<link>http://www.sobek.info/blog/2010/04/01/jquery-introduction-part-1/</link>
		<comments>http://www.sobek.info/blog/2010/04/01/jquery-introduction-part-1/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 09:00:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery introduction]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=262</guid>
		<description><![CDATA[Why jquery or why use a js-lib at all?
There are many Javascript libraries on the market, e.g. script.aculo.us, jquery, dojo, Prototype and so on. For most of the tasks there is no special reason why jquery. It ist mostly a matter of actual knowledge of the developers to keep learning time low when there is [...]]]></description>
			<content:encoded><![CDATA[<h3><strong>Why jquery or why use a js-lib at all?</strong></h3>
<p>There are many Javascript libraries on the market, e.g. script.aculo.us, jquery, dojo, Prototype and so on. For most of the tasks there is no special reason why jquery. It ist mostly a matter of actual knowledge of the developers to keep learning time low when there is a basic knowledge available. Some JS-libs have an easier handling e.g. of json than other, in detail using json in jquery is simpler than in prototype.</p>
<p>Why should you use a js-lib at all? There are several reasons:</p>
<h4><strong>Simpler syntax and less code</strong></h4>
<p>Imagine you want to modify every div-element which has class &#8220;payment&#8221; assigned and want to set the background color to &#8220;#cccccc&#8221; to these elements.<br />
You have something like this:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code29'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26229"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p262code29"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;list&quot;&gt;
  &lt;div class=&quot;payment&quot;&gt;some text&lt;/div&gt;
  &lt;div&gt;some text&lt;/div&gt;
  &lt;div class=&quot;payment&quot;&gt;some text&lt;/div&gt;
  &lt;div class=&quot;payment&quot;&gt;some text&lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>With normal JS you could do the job like this:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code30'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26230"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p262code30"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> list <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'list'</span><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> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> list.<span style="color: #660066;">childNodes</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><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>list.<span style="color: #660066;">childNodes</span>.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;payment&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	list.<span style="color: #660066;">childNodes</span>.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">backgroundColor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#cccccc'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Ok, six lines of code and moderate readable but what with all browser support? Umpf. And imagine this is a simple example.</p>
<p>With jquery you do:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code31'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26231"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p262code31"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.payment'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background-color'</span> <span style="color: #339933;">,</span> <span style="color: #3366CC;">'#cccccc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And this runs in all browsers.</p>
<h4><strong>Better readability</strong></h4>
<p>Isn&#8217;t the example above better readable? You use css-selectors for selecting elements in javascript.</p>
<p>E.g. you want to remove the class from the div elements which are childs of the div with id &#8220;list&#8221;.</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p262code32'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p26232"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p262code32"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div#list div.payment'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><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: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'payment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<h4><strong>Better and easier extendability </strong></h4>
<p>You can simply create own plugins.</p>
<h4><strong>Multi-Browser compatibility</strong></h4>
<p>Nearly all functions will run in every browser.</p>
<h3><strong>There are often some cons why you should not use js-libs:</strong></h3>
<h4><strong>Big libray included</strong></h4>
<p>Yes it can be but e.g. with jquery you can use the compressed version for the live version. This will have only round about ~50k. And browser will cache the js file.</p>
<h4><strong>Higher loading times</strong></h4>
<p>Travering can be a costy thing, true. But with newer version it will become faster.</p>
<h3><strong>Conclusion</strong></h3>
<p>So I recommend using jquery because of the better readability, extendability and the separation of concerns.</p>
<h3><strong>Tip of the day: </strong></h3>
<p>Do not put JS-code inside html document when not needed. Use event-handling in outsourced js-file.</p>
<p>More infos about jquery you can find under <a title="jquery" href="http://www.javascriptkata.com/2007/05/29/3-reasons-why-i-use-jquery/" target="_blank">http://www.javascriptkata.com/2007/05/29/3-reasons-why-i-use-jquery/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2010/04/01/jquery-introduction-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Permanent Menu in Typo3</title>
		<link>http://www.sobek.info/blog/2010/03/30/permanent-menu-in-typo3-2/</link>
		<comments>http://www.sobek.info/blog/2010/03/30/permanent-menu-in-typo3-2/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 12:26:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Typo3]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[permanent menu]]></category>
		<category><![CDATA[typoscript]]></category>

		<guid isPermaLink="false">http://www.sobek.info/blog/?p=73</guid>
		<description><![CDATA[To fix some menu entries in your menu so that they are displayed all the time use the following sample code:

?View Code JAVASCRIPT1
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
lib.mainMenu.alwaysActivePIDlist = 3,4,5
#  main menu
lib.mainMenu= HMENU
lib.mainMenu.entryLevel = 0
#  show these uids of sites no matter where we are lib.mainMenu.alwaysActivePIDlist  = 3,4,5 lib.mainMenu &#123;
# erstes level
1 = TMENU
1.wrap = &#38;lt;ul  [...]]]></description>
			<content:encoded><![CDATA[<p>To fix some menu entries in your menu so that they are displayed all the time use the following sample code:</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?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p73code34'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p7334"><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
</pre></td><td class="code" id="p73code34"><pre class="javascript" style="font-family:monospace;">lib.<span style="color: #660066;">mainMenu</span>.<span style="color: #660066;">alwaysActivePIDlist</span> <span style="color: #339933;">=</span> 3<span style="color: #339933;">,</span>4<span style="color: #339933;">,</span>5
#  main menu
lib.<span style="color: #660066;">mainMenu</span><span style="color: #339933;">=</span> HMENU
lib.<span style="color: #660066;">mainMenu</span>.<span style="color: #660066;">entryLevel</span> <span style="color: #339933;">=</span> 0
#  show these uids of sites no matter where we are lib.<span style="color: #660066;">mainMenu</span>.<span style="color: #660066;">alwaysActivePIDlist</span>  <span style="color: #339933;">=</span> 3<span style="color: #339933;">,</span>4<span style="color: #339933;">,</span>5 lib.<span style="color: #660066;">mainMenu</span> <span style="color: #009900;">&#123;</span>
# erstes level
1 <span style="color: #339933;">=</span> TMENU
1.<span style="color: #660066;">wrap</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>ul  id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;topnavigation&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>ul<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
1<span style="color: #009900;">&#123;</span>
  # no state<span style="color: #339933;">:</span> normale  Formatierung
  NO<span style="color: #009900;">&#123;</span>
    wrapItemAndSub <span style="color: #339933;">=</span>  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  # act state<span style="color: #339933;">:</span> gültig von der rootseite  bis zur aktuellen Seite
  ACT<span style="color: #339933;">=</span>1
  ACT<span style="color: #009900;">&#123;</span>
    wrapItemAndSub <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>li  <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;menu-level1-active&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  # cur state<span style="color: #339933;">:</span> gültig für die aktuelle  Seite
  CUR<span style="color: #339933;">=</span>1
  CUR<span style="color: #009900;">&#123;</span>
    wrapItemAndSub <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>li  <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;menu-level1-current-active&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  # ifsub state<span style="color: #339933;">:</span> gültig für seiten die  unterseiten haben
  IFSUB<span style="color: #339933;">=</span>1
  IFSUB<span style="color: #009900;">&#123;</span>
    wrapItemAndSub <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>li  <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;menu-level1-with-subpage&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
# zweites level
2 <span style="color: #339933;">=</span> TMENU
2.<span style="color: #660066;">wrap</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>ul  <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;menu-level2&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>ul<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
2<span style="color: #009900;">&#123;</span>
  NO<span style="color: #009900;">&#123;</span>
    wrapItemAndSub <span style="color: #339933;">=</span>  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  ACT<span style="color: #339933;">=</span>1
  ACT<span style="color: #009900;">&#123;</span>
  wrapItemAndSub <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>li  <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;menu-level2-active&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  CUR<span style="color: #339933;">=</span>1
  CUR<span style="color: #009900;">&#123;</span>
    wrapItemAndSub <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>li  <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;menu-level2-current-active&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  IFSUB<span style="color: #339933;">=</span>1
  IFSUB<span style="color: #009900;">&#123;</span>
    wrapItemAndSub <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>li  <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;menu-level2-with-subpage&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;|&amp;</span>lt<span style="color: #339933;">;/</span>li<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.sobek.info/blog/2010/03/30/permanent-menu-in-typo3-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

